Discrete Event Simulation in Python
Dr Diogo Costa
Adjunct Professor, University of Saskatchewan, Canada & CEO of ImpactBLUE-Scientific
Understand dynamic system
Define objective(s) of discrete-event model
Identify processes:
Identify appropriate SimPy resources (resource
, container
, store
)
Define architecture of model:
Understand the dynamic system
Objectives of the model
What are the aspects you want to optimize?
State-variables to monitor these objectives
Shared Resources
simpy.Resources(env, capacity=4)
Examples
Containers
simpy.Container(env, capacity,
init=initial_capacity)
Resources behaves like a tank or basket
Add and remove quantity:
.put()
and .get()
Examples
Store
Resource like a store with multiple items
Capacity is unlimited (default)
Capacity slots for storing arbitrary objects
Add and remove items:
.put()
and .get()
Examples
SimPy uses bitwise operators to concatenate two events
Types of operators in Python
Bitwise operators
a & b
, a >> b
, a ^ b
In SimPy
Relevant bitwise operators for SimPy
__and__()
or &
__or__()
or |
Discrete Event Simulation in Python