diff --git a/src/Animation.jl b/src/Animation.jl index a041ad4..4740327 100644 --- a/src/Animation.jl +++ b/src/Animation.jl @@ -6,7 +6,7 @@ using GLMakie using ColorSchemes: cyclic_mrybm_35_75_c68_n256_s25 using LaTeXStrings: @L_str using JLD2: JLD2 -using ProgressMeter: @showprogress +using ProgressMeter: ProgressMeter using ..ReCo: ReCo @@ -123,6 +123,7 @@ function animate_with_sim_consts( show_interaction_circle::Bool, show_skin_circle::Bool, show_frame_diff::Bool, + show_progress::Bool, ) GLMakie.activate!() set_theme!(theme_black()) @@ -184,7 +185,11 @@ function animate_with_sim_consts( bundle_paths = ReCo.sorted_bundle_paths(dir) - @showprogress 1 for (n_bundle, bundle_path) in enumerate(bundle_paths) + progress = ProgressMeter.Progress( + length(bundle_paths); dt=1, enabled=show_progress, desc="Animation: " + ) + + for (n_bundle, bundle_path) in enumerate(bundle_paths) bundle::ReCo.Bundle = JLD2.load_object(bundle_path) args = (; @@ -212,6 +217,8 @@ function animate_with_sim_consts( ) animate_bundle!(args, sim_consts) + + ProgressMeter.next!(progress) end end @@ -225,6 +232,7 @@ function animate( show_interaction_circle::Bool=false, show_skin_circle::Bool=false, show_frame_diff::Bool=false, + show_progress::Bool=true, ) println("Generating animation...") @@ -238,6 +246,7 @@ function animate( show_interaction_circle, show_skin_circle, show_frame_diff, + show_progress, ) println("Animation done.") diff --git a/src/RL/RL.jl b/src/RL/RL.jl index c0b52fc..8c806d8 100644 --- a/src/RL/RL.jl +++ b/src/RL/RL.jl @@ -10,7 +10,7 @@ using Intervals using StaticArrays: SVector using LoopVectorization: @turbo using Random: Random -using ProgressMeter: @showprogress +using ProgressMeter: ProgressMeter using ..ReCo: ReCo @@ -62,6 +62,7 @@ function run_rl(; ϵ_stable::Float64=0.0001, skin_to_interaction_r_ratio::Float64=ReCo.DEFAULT_SKIN_TO_INTERACTION_R_RATIO, packing_ratio::Float64=0.22, + show_progress::Bool=true, ) where {E<:Env} @assert 0.0 <= goal_gyration_tensor_eigvals_ratio <= 1.0 @assert n_episodes > 0 @@ -110,7 +111,9 @@ function run_rl(; hook(PRE_EXPERIMENT_STAGE, agent, env) agent(PRE_EXPERIMENT_STAGE, env) - @showprogress 0.6 for episode in 1:n_episodes + progress = ProgressMeter.Progress(n_episodes; dt=1, enabled=show_progress, desc="RL: ") + + for episode in 1:n_episodes dir = ReCo.init_sim_with_sim_consts(sim_consts; parent_dir=parent_dir) # Reset @@ -136,7 +139,9 @@ function run_rl(; # TODO: Replace with live plot @show hook.rewards - @show agent.policy.explorer.step + # @show agent.policy.explorer.step + + ProgressMeter.next!(progress) end # Post experiment diff --git a/src/ReCo.jl b/src/ReCo.jl index 78f67c4..e76b119 100644 --- a/src/ReCo.jl +++ b/src/ReCo.jl @@ -5,7 +5,7 @@ export init_sim, run_sim, run_rl, animate, LocalCOMEnv using StaticArrays: SVector using JLD2: JLD2 using Distributions: Uniform, Normal -using ProgressMeter: @showprogress +using ProgressMeter: ProgressMeter using CellListMap: CellListMap using Random: Random diff --git a/src/run.jl b/src/run.jl index 541fa1a..9c8cd0d 100644 --- a/src/run.jl +++ b/src/run.jl @@ -13,6 +13,7 @@ function run_sim( seed::Int64=42, n_bundle_snapshots::Int64=100, env_helper::Union{RL.EnvHelper,Nothing}=nothing, + show_progress::Bool=true, ) @assert length(dir) > 0 @assert duration > 0 @@ -102,6 +103,7 @@ function run_sim( n_bundle_snapshots=n_bundle_snapshots, bundle=Bundle(sim_consts.n_particles, n_bundle_snapshots), box=gen_cell_list_box(sim_consts.half_box_len, sim_consts.skin_r), + show_progress=show_progress, ) simulate!( diff --git a/src/simulation.jl b/src/simulation.jl index 4a9d170..8242a03 100644 --- a/src/simulation.jl +++ b/src/simulation.jl @@ -132,7 +132,13 @@ function simulate!( start_time = Dates.now() println("Started simulation at $start_time.") - @showprogress 0.6 for (integration_step, t) in enumerate(T0:(args.δt):T) + time_range = T0:(args.δt):T + + progress = ProgressMeter.Progress( + length(time_range); dt=1, enabled=args.show_progress, desc="Simulation: " + ) + + for (integration_step, t) in enumerate(time_range) if (integration_step % n_steps_before_snapshot == 0) && save_data wait(task) @@ -178,6 +184,8 @@ function simulate!( end first_integration_step = false + + ProgressMeter.next!(progress) end wait(task)