Skip to content

Commit

Permalink
rm progress_bar from mc
Browse files Browse the repository at this point in the history
  • Loading branch information
ivborissov committed Sep 18, 2023
1 parent 5069673 commit ec5f1fa
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/monte_carlo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,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_cons(parameters_variation_nt, i); safetycopy=true)
return prob_i
Expand Down Expand Up @@ -92,7 +92,7 @@ function mc(
reduction = reduction_func,
safetycopy = false
)

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

#end

return MCResult(solution.u, has_saveat(scenario), scenario)
end
Expand Down Expand Up @@ -225,12 +227,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 @@ -262,7 +264,7 @@ function mc(
reduction = reduction_func,
safetycopy = false
)

#=
if progress_bar && (parallel_type == EnsembleDistributed())
@sync begin
@async while take!(progch)
Expand All @@ -282,6 +284,8 @@ function mc(
end
end
else
=#

solution = solve(prob, alg, parallel_type;
trajectories = lp*lc,
reltol = reltol,
Expand All @@ -291,7 +295,8 @@ function mc(
save_everystep = false,
kwargs...
)
end

#end

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

Expand Down

0 comments on commit ec5f1fa

Please sign in to comment.