Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using...
Transcript of Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using...
![Page 1: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/1.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Introduction to Discrete-Event Simulation
Using SimPy
Chun-Chieh Huang
DSP and Algorithm Design Department
Metanoia Communications Inc.
October 17, 2011
![Page 2: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/2.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Outline
1 What is Simulation and Why do we need it?
2 What is Discrete-Event Simulation?
3 Example to Illustrate World Views
4 Introduction to SimPy
5 SimPy Example
![Page 3: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/3.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
![Page 4: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/4.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
When to use simulation
hard to do real experiment,e.g. battle field, or banking system
![Page 5: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/5.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
When to use simulation
hard to do real experiment,e.g. battle field, or banking systemcheaper to do simulation,e.g. RTL simulation for IC design,or highway/freeway route planning
![Page 6: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/6.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
When to use simulation
hard to do real experiment,e.g. battle field, or banking systemcheaper to do simulation,e.g. RTL simulation for IC design,or highway/freeway route planninganalyzing bottleneck for current workflow
![Page 7: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/7.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
When to use simulation
hard to do real experiment,e.g. battle field, or banking systemcheaper to do simulation,e.g. RTL simulation for IC design,or highway/freeway route planninganalyzing bottleneck for current workflow
When not to use simulation
more expensive to do simulation,e.g. simple harmonic motion
![Page 8: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/8.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Simulation and Why do we need it?
Simulation
a computer program that creates a virtual environmentin order to study physical problems
When to use simulation
hard to do real experiment,e.g. battle field, or banking systemcheaper to do simulation,e.g. RTL simulation for IC design,or highway/freeway route planninganalyzing bottleneck for current workflow
When not to use simulation
more expensive to do simulation,e.g. simple harmonic motionproblems that can be analyzed by pencil and paper
![Page 9: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/9.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Categories of Simulation
Continuous or discrete
State variable is continuous, e.g. weather systemsState variable is discrete, e.g. number of customers
![Page 10: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/10.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Categories of Simulation
Continuous or discrete
State variable is continuous, e.g. weather systemsState variable is discrete, e.g. number of customers
Static or dynamicStatic: represents a system at a particular point of time
called Monte-Carlo Simulation [2]
Dynamic: represents systems as they change over time
e.g. banking system from 9:00 AM to 5:00 PM
![Page 11: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/11.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Categories of Simulation
Continuous or discrete
State variable is continuous, e.g. weather systemsState variable is discrete, e.g. number of customers
Static or dynamicStatic: represents a system at a particular point of time
called Monte-Carlo Simulation [2]
Dynamic: represents systems as they change over time
e.g. banking system from 9:00 AM to 5:00 PM
Deterministic or stochastic
Deterministic: contains no random variableStochastic: has one or more random variables
![Page 12: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/12.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
What is Discrete-Event Simulation?
Simulation of weather system is continuous.
Simulation of queue in a post office is discrete.
Number of customers in any time is discrete.Simulation for this kind of systems is calleddiscrete-event simulation.
Mostly, but not limited to, queueing systems
factory work flowfreeway traffic simulationnetwork traffic simulation
![Page 13: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/13.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
![Page 14: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/14.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
Event-oriented
on each event, generate next event andput into event queuesimulation time advances to next eventfaster than activity-oriented
![Page 15: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/15.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
Event-oriented
on each event, generate next event andput into event queuesimulation time advances to next eventfaster than activity-oriented
Process-oriented
abstract one object into a processeasier to maintain in the end
![Page 16: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/16.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Example to Illustrate World Views
Simulating a post office with only one clerk
Customers come in at random timeand wait if the clerk is already serving
Clerk serves each customer for a random period of time
![Page 17: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/17.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
Event-oriented
on each event, generate next event andput into event queuesimulation time advances to next eventfaster than activity-oriented
Process-oriented
abstract one object into a processeasier to maintain in the end
![Page 18: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/18.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Simulation starts!
Gen 1st arr at 2.6
Check events: 1st arr at 2.6
![Page 19: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/19.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6
![Page 20: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/20.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6
![Page 21: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/21.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6
![Page 22: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/22.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6
![Page 23: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/23.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6
![Page 24: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/24.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 1st arr at 2.6...
![Page 25: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/25.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
First arrival!
![Page 26: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/26.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Calculate next arrival at 3.5
Calculate service time, end at 4.0
![Page 27: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/27.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 28: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/28.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 29: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/29.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 30: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/30.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 31: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/31.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 32: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/32.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 33: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/33.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 34: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/34.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5
![Page 35: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/35.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: 2nd arrival at 3.5...
![Page 36: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/36.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Second arrival!
![Page 37: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/37.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Calculate next arrival at ...
![Page 38: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/38.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: service end at 4.0
![Page 39: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/39.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: service end at 4.0
![Page 40: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/40.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Activity-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Check events: service end at 4.0...
![Page 41: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/41.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
Event-oriented
on each event, generate next event andput into event queuesimulation time advances to next eventfaster than activity-oriented
Process-oriented
abstract one object into a processeasier to maintain in the end
![Page 42: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/42.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
62.6: 1st arr
Simulation starts!
![Page 43: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/43.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
62.6: 1st arr
First arrival!
![Page 44: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/44.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
Calculate next arrival at 3.5
Calculate service time, end at 4.0
3.5: 2nd arr 4.0: 1st arr end
![Page 45: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/45.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
63.5: 2nd arr 4.0: 1st arr end
Second arrival!
![Page 46: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/46.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
64.0: 1st arr end 5.0: 3rd arr
![Page 47: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/47.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Event-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
64.0: 1st arr end 5.0: 3rd arr
End service of 1st arrival.
![Page 48: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/48.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Discrete-Event Simulation World Views
Activity-oriented
fixed increment of timetime-consuming
Event-oriented
on each event, generate next event andput into event queuesimulation time advances to next eventfaster than activity-oriented
Process-orientedabstract one object into a process
Arrival process for customers, or A
Clerk process, or S
Event manager, or E
easier to maintain in the end
![Page 49: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/49.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A: Gen 1st arr at 2.6
S:
E: Add one event of 2.6
Simulation starts!
![Page 50: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/50.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
First arrival!
A: Add customer to queue
S:
E: Process event, wake A up
![Page 51: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/51.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A: Calc next arr at 3.5
S:
E: Add event of 2.6&3.5
![Page 52: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/52.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A:
S: Serv, calc serv T at 4.0
E: Proc event of 2.6, add Ev 4.0
![Page 53: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/53.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A: Add customer to queue
S:
E: Proc event of 3.5, wake A up
Second arrival!
![Page 54: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/54.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A: Calc next arr at 5.0
S:
E:
Calc next arrival at 5.0
![Page 55: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/55.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A:
S: 1st arr end serv.
E: Proc event of 4.0, wake S up
![Page 56: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/56.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Process-Oriented Discrete-Event Simulation
0 1 2 3 4 5 6 7 8 90
1
2
3
4
5
6
A:
S: Serv 2nd arr.
E: Add end serv event for 2nd arr.
![Page 57: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/57.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Implementing Discrete-Event Simulation
Use your own C/C++ implementation
takes time to write simulation engine and algorithm codehard to debug, especially for event managernot very convincing
![Page 58: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/58.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Implementing Discrete-Event Simulation
Use your own C/C++ implementation
takes time to write simulation engine and algorithm codehard to debug, especially for event managernot very convincing
Use generalized simulation library, or language
SIMULA programming languageC++SIM or JavaSIM [1]SimEvents in Simulink/MATLABSimPy [5]
![Page 59: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/59.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Implementing Discrete-Event Simulation
Use your own C/C++ implementation
takes time to write simulation engine and algorithm codehard to debug, especially for event managernot very convincing
Use generalized simulation library, or language
SIMULA programming languageC++SIM or JavaSIM [1]SimEvents in Simulink/MATLABSimPy [5]
Use special purpose simulation packages
ns-3 for network simulation [4]
![Page 60: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/60.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Introduction to SimPy
Uses Python for modeling
Python is a scripting language like MATLAB, but faster!Python is very easy to write and very beautiful!
![Page 61: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/61.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Introduction to SimPy
Uses Python for modeling
Python is a scripting language like MATLAB, but faster!Python is very easy to write and very beautiful!
Process-oriented Discrete Event Simulation Language
easier to write modelprovides event manager implementation
![Page 62: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/62.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Introduction to SimPy
Uses Python for modeling
Python is a scripting language like MATLAB, but faster!Python is very easy to write and very beautiful!
Process-oriented Discrete Event Simulation Language
easier to write modelprovides event manager implementation
Uses coroutine to suspend/resume process
will be refered to as thread in this presentationguarantees order of executioncannot run on parallel machine
![Page 63: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/63.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terminology: Classes
Process
simulates an entity which evolves in time, e.g.a customer who needs to be served by a clerkrefered to as thread in [3]
![Page 64: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/64.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terminology: Classes
Process
simulates an entity which evolves in time, e.g.a customer who needs to be served by a clerkrefered to as thread in [3]
Resource
simulates something to be queued, e.g. the waiting list
![Page 65: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/65.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
![Page 66: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/66.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
![Page 67: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/67.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
![Page 68: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/68.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
yield request requests for a given resource
![Page 69: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/69.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
yield request requests for a given resource
yield release used to indicate that current thread no longerneed the given resource
![Page 70: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/70.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
yield request requests for a given resource
yield release used to indicate that current thread no longerneed the given resource
yield passivate put current thread into suspension andwait until awakened by some other thread
![Page 71: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/71.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
yield request requests for a given resource
yield release used to indicate that current thread no longerneed the given resource
yield passivate put current thread into suspension andwait until awakened by some other thread
reactivate() awakes a previously-passivated thread
![Page 72: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/72.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Terimnology: Functions
activate() used to mark a thread as runnable when it is firstcreated
simulate() starts the simulation
yield hold put current thread into suspension for a certainamount of time
yield request requests for a given resource
yield release used to indicate that current thread no longerneed the given resource
yield passivate put current thread into suspension andwait until awakened by some other thread
reactivate() awakes a previously-passivated thread
cancel() cancels all the events associated with apreviously-passivated thread
![Page 73: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/73.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
SimPy Example
Scenario
A post office with only one clerk.Customers arrival is poisson process,i.e. inter-arrival time is exponential distribution.Service time is also poisson process.
Process
ArrivalClerk
Queue is managed by ourselves.
![Page 74: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/74.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Arrival Process
c l a s s A r r i v a l C l a s s ( P roc e s s ) :A r r i v a l R a t e = 1/1.0 # r e c i p r o c a l o f mean a r r i v a l t ime
de f __init__ ( s e l f ) :P r oc e s s . __init__ ( s e l f )
de f Run( s e l f ) :wh i l e 1 :
I n t e r A r r i v a l T im e = G. Rnd . e x p o v a r i a t e ( A r r i v a l C l a s s . A r r i v a l R a t ey i e l d hold , s e l f , I n t e rA r r i v a l T im eC = Customer ( )C l e r k C l a s s . Queue . append (C) # a customer a r r i v e sG. NumCustomers += 1
i f C l e r k C l a s s . I d l e != [ ] : # I s t h e r e any c l e r k i d l e ?r e a c t i v a t e ( C l e r k C l a s s . I d l e [ 0 ] ) # Yes , wake him/ her up
![Page 75: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/75.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Clerk Process
c l a s s C l e r kC l a s s ( P roc e s s ) :S e r v i c eRa t e = 1/1.2 # r e c i p r o c a l o f mean s e r v i c e t imeMaxQueueLength = 0Queue = [ ]I d l e = [ ]Busy = [ ]NumDone = 0de f __init__ ( s e l f ) :
P r oc e s s . __init__ ( s e l f )C l e r kC l a s s . I d l e . append ( s e l f ) # I n i t i a l l y i d l e
de f Run( s e l f ) :wh i l e 1 :
y i e l d p a s s i v a t e , s e l f # wa i t u n t i l awaken by customersC l e r k C l a s s . I d l e . remove ( s e l f )C l e r k C l a s s . Busy . append ( s e l f ) # going to be busywh i l e C l e r kC l a s s . Queue != [ ] :
C = C l e r kC l a s s . Queue . pop ( ) # c a l l nex t customer i n l i n ei f l e n ( C l e r k C l a s s . Queue ) > C l e r k C l a s s . MaxQueueLength :
C l e r kC l a s s . MaxQueueLength = l e n ( C l e r kC l a s s . Queue )# St a r t s e r v i c e the customerServ i ceT ime = G. Rnd . e x p o v a r i a t e ( C l e r k C l a s s . S e r v i c eRa t e )y i e l d hold , s e l f , Serv i ceT imeC . en dSe r v i c e ( )G . TotalWait ingTime += C . Wait ingTimeC l e r k C l a s s . NumDone += 1d e l C
C l e r k C l a s s . Busy . remove ( s e l f )C l e r k C l a s s . I d l e . append ( s e l f )
![Page 76: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/76.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Live Demo
![Page 77: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/77.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Important Simulation Parameters
Purpose List below parameters to prove that your work isrepeatable.
RNG Random number generator method
Linear Congruential Method
oldest and best well known
Mersenne Twister
designed with simulation purpose in mindused to implement random library in pythonafter version 2.5
RNG Random number generator seed
![Page 78: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/78.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Concluding Remarks
Simulation is a powerful tool to study physical problemswith cheaper cost.
SimPy provides process-oriendted DES frameworkto write simlation easily and reasonably fast.
![Page 79: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/79.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
References
[1] JavaSIM and C++SIM. http://javasim.codehaus.org/.
[2] Jerry Banks, John S. Carson, Barry L. Nelson, andDavid M. Nicol. Discrete-Event System Simulation (5thEdition). Prentice Hall, 2009.
[3] N Matloff. A discrete-event simulation course based on thesimpy language. Davis, 2006.
[4] ns -3 Network Simulator. http://www.nsnam.org/.
[5] SimPy Simulation Package. http://simpy.sourceforge.net/.
![Page 80: Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy Chun-Chieh Huang DSP and Algorithm Design Department Metanoia Communications](https://reader035.fdocuments.net/reader035/viewer/2022062403/5fdb226ccf74181a0925dd70/html5/thumbnails/80.jpg)
Introductionto Discrete-
EventSimulation
Using SimPy
Chun-ChiehHuang
What isSimulationand Why dowe need it?
What isDiscrete-EventSimulation?
Example toIllustrateWorld Views
Introductionto SimPy
SimPyExample
References
Q & A