Skip to content

Commit

Permalink
check the stop condition before simulation starts
Browse files Browse the repository at this point in the history
  • Loading branch information
artgoldberg committed Dec 17, 2020
1 parent 12e40e2 commit 6f189d8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions de_sim/simulator.py
Expand Up @@ -638,6 +638,10 @@ def _simulate(self):
self.num_handlers_called = 0
self.log_with_time(f"Simulation to {self.sim_config.max_time} starting")

# check the stop condition
if self.sim_config.stop_condition is not None and self.sim_config.stop_condition(self.time):
raise SimulatorError(f"Stop condition true at beginning of simulation at time {self.time}")

try:
self.progress.start(self.sim_config.max_time)
self.init_metadata_collection(self.sim_config)
Expand Down

0 comments on commit 6f189d8

Please sign in to comment.