Skip to content
Advertisement

How to terminate simulation in SimPy 4

Is there a way to terminate the simpy simulation by using a command like env.exit()? I don’t understand how to place an event into env.run(until=event). I want to terminate the simulation when there are no objects left in my certain Simpy Stores. How can I do that?

Advertisement

Answer

Everything is an event in simpy, even the environment itself. Thus, you can terminate the simulation marking as succeed the “root” event.

JavaScript

In order to check if a store is empty, just check if its items len is equal to zero.

If you put all together, you can do something like that to solve your problem:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement