SimPy logo

SimPy: A Python-based simulation package

SimPy is a process-based discrete-event simulation language based on standard Python and released under the GNU GPL. It provides the modeller with components of a simulation model including processes, for active components like customers, messages, and vehicles, and resources, for passive components that form limited capacity congestion points like servers, checkout counters, and tunnels. It also provides monitor variables to aid in gathering statistics. Random variates are provided by the standard Python random module.

Simpy is based on ideas from Simula and Simscript but uses standard Python.

SimPy is based on efficient implementation of co-routines using Python's generators capability. It requires Python 2.2 or later.

Download

SimPy can be downloaded from the Simpy page on Sourceforge.

Documentation

A brief cheat-sheet of the facilities that SimPy provides in the form of a listing of commands and methods for processes, resources, and monitors.

A more extensive Manual with simple examples.

An introduction to interfacing SimPy models with GUI and plotting applications.

The Bank, a tutorial for SimPy showing the gradual development of a multi-server bank model.

Models

Examples of SimPy models are included in the download package. They include:

MM1.py
M/M/1 random-arrivals, exponential service time queue with GUI input. (MM))
MMC.py
M/M/c (multiple server queue) model. This demonstrates both the multiple capacity Resource class and the use of monitors to tally and accumulate data about the transit times and the numbers in the system. Random arrivals, exponential service-times. (TV)
Market.py
Simulation of a supermarket with measurement of waiting times, etc. (MM)
SimPy_worker_extend.py
Factory making widgets with queues for machines. (MM)
airport.py
A simple model of an airport with a single runway. Times are deterministic and statistics are not (yet) gathered.
bcc.py
BCC (Blocked Customer Cleared) model with a different serivice time distributions (Erlang, Hyper-exponential, Exponential) (TV)
cellphone.py
Simulation of a cellphone cell with blocking (BCC discipline). The program simulates the operation for 10 "hours" and measures the mean and variance of the total time blocked and the number of times blocking occur in each hour. An observational gap occurs between the observation hours to make each hour's measurement independent. (TV)
centralserver.py
Simulates a primitive central-server model with a single CPU and a single disk. A fixed number of users send "jobs" to the system which are processed and sent back to the user who then thinks for a time before sending a job back. This system is useful as it can be solved analytically. (TV)
jacksonnetwork.py
Simulation of a network of 3 queue nodes with random transitions between them. Exponential service times. (TV)
lemmings.py
A very simple queue with random arrivals (M/M/1, actually) (TV)
shortestPath_SimPy.py
A fun example of using SimPy for non-queuing work. It simulates a searcher through a graph, seeking the shortest path. (KGM)

Mailing list

There is a mailing list for users and modellers using SimPy. You can join it at the simpy-user list.