Skip to content

Commit

Permalink
Add more information about running simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
chraibi committed Mar 15, 2024
1 parent 11d30d6 commit 83fc383
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def read_data(output_file: str) -> pd.DataFrame:
simulation_time,
data,
Path(OUTPUT_FILE),
msg,
)
msg.code(f"Finished simulation. Evac time {evac_time:.2f} s")
st.empty()
Expand Down
9 changes: 7 additions & 2 deletions simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def run_simulation(
simulation: jps.Simulation,
motivation_model: mm.MotivationModel,
_simulation_time: float,
ped_ids: List[int]
ped_ids: List[int],
msg: Any
) -> None:
"""Run simulation logic.
Expand Down Expand Up @@ -159,6 +160,7 @@ def run_simulation(
and simulation.elapsed_time() < _simulation_time
):
simulation.iterate()
msg.code(f"Agents in the simulation: {simulation.agent_count()}")
if simulation.iteration_count() % 100 == 0:
agents = simulation.agents()
number_agents_in_simulation = simulation.agent_count()
Expand Down Expand Up @@ -197,6 +199,7 @@ def main(
_simulation_time: float,
_data: Dict[str, Any],
_trajectory_path: pathlib.Path,
msg
) -> float:
"""Main simulation loop.
Expand Down Expand Up @@ -244,7 +247,7 @@ def main(
ped_ids = distribute_and_add_agents(simulation, agent_parameters, positions)
motivation_model = init_motivation_model(_data, ped_ids)
logging.info(f"Running simulation for {len(ped_ids)} agents:")
run_simulation(simulation, motivation_model, _simulation_time, ped_ids)
run_simulation(simulation, motivation_model, _simulation_time, ped_ids, msg)
logging.info(
f"Simulation completed after {simulation.iteration_count()} iterations"
)
Expand All @@ -265,6 +268,7 @@ def main(
time_step = parse_time_step(data)
number_agents = parse_number_agents(data)
simulation_time = parse_simulation_time(data)
dummy = ""
if fps and time_step:
main(
number_agents,
Expand All @@ -273,4 +277,5 @@ def main(
simulation_time,
data,
pathlib.Path(sys.argv[2]),
dummy,
)

0 comments on commit 83fc383

Please sign in to comment.