Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Conditional end simulation
Is there's a way of stopping the
SpaDESsimulation based on a condition, such as when some variable reaches a certain value?
Simply change the end time of the simulation mid-run: when your condition is met, change the end time to the current time.
Within your module:
if (condition) end(sim) <- time(sim)
With care, you can also manipulate the event queue. For example, if you remove all the events in the queue, then it will the time will proceed until the end time (i.e., end(sim) )
# remove all events in the event queue if (condition) events(sim) <- events(sim)