Skip to content

Commit

Permalink
rm Progress Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ivborissov committed Jan 31, 2025
1 parent eb2a0c4 commit 7fd98b3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/monte_carlo.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RemoteChannel used for progress monitoring in parallel setup
const progch = RemoteChannel(()->Channel{Bool}(), 1)
# const progch = RemoteChannel(()->Channel{Bool}(), 1)

# as in SciMLBase
DEFAULT_REDUCTION(u,data,I) = append!(u, data), false
Expand Down Expand Up @@ -41,7 +41,7 @@ function mc(
parameters_variation::Vector{P}, # input of `mc` level
num_iter::Int;
verbose=false,
progress_bar=false,
#progress_bar=false,
alg=DEFAULT_ALG,
reltol=DEFAULT_SIMULATION_RELTOL,
abstol=DEFAULT_SIMULATION_ABSTOL,
Expand All @@ -61,11 +61,11 @@ function mc(
parameters_variation_nt = NamedTuple(parameters_variation)

#(parallel_type == EnsembleSerial()) # tmp fix
p = Progress(num_iter, dt=0.5, barglyphs=BarGlyphs("[=> ]"), barlen=50, enabled = progress_bar)
#p = Progress(num_iter, dt=0.5, barglyphs=BarGlyphs("[=> ]"), barlen=50, enabled = progress_bar)

function prob_func(prob,i,repeat)
verbose && println("Processing iteration $i")
progress_bar && (parallel_type != EnsembleDistributed() ? next!(p) : put!(progch, true))
#progress_bar && (parallel_type != EnsembleDistributed() ? next!(p) : put!(progch, true))

prob_i = remake_prob(scenario, generate_params(parameters_variation_nt, i); safetycopy)
return prob_i
Expand Down Expand Up @@ -94,7 +94,7 @@ function mc(
reduction = reduction_func,
safetycopy = false
)

#=
if progress_bar && (parallel_type == EnsembleDistributed())
@sync begin
@async while take!(progch)
Expand All @@ -114,6 +114,7 @@ function mc(
end
end
else
=#
solution = solve(prob, alg, parallel_type;
trajectories = num_iter,
reltol = reltol,
Expand All @@ -123,7 +124,7 @@ function mc(
save_everystep = false,
kwargs...
)
end
#end

return MCResult(solution.u, has_saveat(scenario), scenario)
end
Expand Down Expand Up @@ -204,7 +205,7 @@ function mc(
parameters_variation::Vector{PP},
num_iter::Int;
verbose=false,
progress_bar=false,
#progress_bar=false,
alg=DEFAULT_ALG,
reltol=DEFAULT_SIMULATION_RELTOL,
abstol=DEFAULT_SIMULATION_ABSTOL,
Expand All @@ -228,12 +229,12 @@ function mc(
lc = length(scenario_pairs)
iter = collect(Iterators.product(1:lp,1:lc))

p = Progress(num_iter, dt=0.5, barglyphs=BarGlyphs("[=> ]"), barlen=50, enabled=progress_bar)
#p = Progress(num_iter, dt=0.5, barglyphs=BarGlyphs("[=> ]"), barlen=50, enabled=progress_bar)

function prob_func(prob,i,repeat)
iter_i = iter[i]
verbose && println("Processing scenario $(iter_i[2]) iteration $(iter_i[1])")
progress_bar && (parallel_type != EnsembleDistributed() ? next!(p) : put!(progch, true))
#progress_bar && (parallel_type != EnsembleDistributed() ? next!(p) : put!(progch, true))

scn_i = last(scenario_pairs[iter_i[2]])
parameters_i = parameters_pregenerated[iter_i[1]]
Expand Down Expand Up @@ -266,6 +267,7 @@ function mc(
safetycopy = false
)

#=
if progress_bar && (parallel_type == EnsembleDistributed())
@sync begin
@async while take!(progch)
Expand All @@ -285,6 +287,7 @@ function mc(
end
end
else
=#
solution = solve(prob, alg, parallel_type;
trajectories = lp*lc,
reltol = reltol,
Expand All @@ -294,7 +297,7 @@ function mc(
save_everystep = false,
kwargs...
)
end
#end

ret = Vector{Pair{Symbol,MCResult}}(undef, lc)

Expand Down

0 comments on commit 7fd98b3

Please sign in to comment.