SimPy is a Python framework for a process-oriented discrete-event simulation system. Its event dispatchers are based on Python generator functions.
| Sympy | |
|---|---|
| Type of | framework , process-oriented discrete-event modeling system |
| Author | Klaus G. Müller, Tony Vignaux |
| Developers | Ontje Lünsdorf, Stefan Scherfke |
| Written on | Python |
| operating system | Cross platform |
| First edition | September 17, 2002 |
| Latest version | 3.0.7 ( March 1, 2015 ) |
| License | MIT |
| Site | simpy.readthedocs.org |
They can also be used to create asynchronous networks or to implement multi-agent systems (with both simulated and real interaction).
Processes in SimPy are simply Python generators that are used to model active components, such as customers, vehicles, or agents. SimPy also provides various types of shared resources for modeling points with limited bandwidth (for example, servers, cash desks, tunnels). Starting with version 3.1, SimPy will also provide monitoring capabilities to help gather statistics on resources and processes.
Simulation can be performed in “as fast as possible” mode, in real time (wall clock time) or in the mode of manual execution of events.
Theoretically, in SimPy you can do continuous simulation, but in fact this is not feasible. However, in the case of modeling with a fixed-size step, where processes do not interact with each other or with shared resources, a simple while loop can be used.
SimPy is distributed with tutorials, detailed documentation, and lots of examples.
SimPy was released as an open source project under the MIT license . The first version was released in December 2002.
Example
One of SimPy’s main goals is ease of use. Here is an example of a simple SimPy simulation: [1] a clock process that displays the current model time at each step:
1 >>> import simpy
2 >>>
3 >>> def clock ( env , name , tick ):
4 ... while True :
5 ... print ( name , env . Now )
6 ... yield env . timeout ( tick )
7 ...
8 >>> env = simpy . Environment ()
9 >>> env . process ( clock ( env , 'fast' , 0.5 ))
10 < Process ( clock ) object at 0 x ...>
11 >>> env . process ( clock ( env , 'slow' , 1 ))
12 < Process ( clock ) object at 0 x ...>
13 >>> env . run ( until = 2 )
14 fast 0
15 slow 0
16 fast 0.5
17 slow 1
18 fast 1.0
19 fast 1.5
Links
- ↑ Scherfke, Stefan (July 25, 2014).