Simpy – Discrete event simulation for Python

One of the coolest libraries that I’ve come across for Python lately is Simpy.   Simpy is a discrete event simulation for Python.

SimPy is a framework for asynchronous programming and brings more than ten years of scientific know-how in the field of event-discrete simulation.  In simpler terms – if you want to simulate something, Simpy may very be the right tool for the job.

Processes in SimPy are Python generators an can be used to model things like customers, vehicles, servers, checkout counters, etc.

There is a very good tutorial: SimPy in 10 Minutes here.

Simpy is very easy to install, simply (heh) use:

pip install simpy

If you have pytest installed (and you should) you can test that Simpy is functioning correctly thusly:

py.test –pyargs simpy

Simpy uses the the concept of processes to interact with the environment and each other. Processes are Python generators and they create events which are returned appropriately with a yield.

If you are unfamiliar with generators and yield statements the good people at RealPython have you covered.

SimPy is released as open source software under the MIT License.

Leave a comment

Your email address will not be published. Required fields are marked *