Discrete Event Simulation
Discrete Event Simulation
2011.10.26
Kenneth
What is a simulation?
3
Simulation Types
4
Static vs. Dynamic
• Dynamic
• State variables change over time (System
Dynamics, Discrete Event)
• Static
• Snapshot at a single point in time
(optimization models, etc.)
5
Deterministic vs. Stochastic
• Deterministic model
• The behavior is entire predictable. The
system is perfectly understood, then it is
possible to predict precisely what will happen.
• Stochastic model
• The behavior cannot be entirely predicted.
6
Discrete vs. Continuous
• Discrete model
• The state variables change only at a
countable number of points in time. These
points in time are the ones at which the event
occurs/change in state.
• Continuous
• The state variables change in a continuous
way, and not abruptly from one state to
another (infinite number of states). 7
Discrete Event Simulation
Dynamic Stochastic Discrete
8
How to Implement a Discrete
Event Simulation?
Ground
Customer (aircraft)
Entities utilizing the system/resources
Server (runway)
Resource that is serially reused; serves one customer at a time
Queue 10
Buffer holding aircraft waiting to land
An Example: Airport System
Single Server Queue
Ground
Performance metrics
• Average waiting time: average time that an aircraft
must wait when arriving at an airport before they are
allowed to land.
• Maximum number of aircraft on the ground: helps to
determine the required space of the parking area. 11
Simulation Development
• Events
• Stochastic model and system attributes
• System States
• Relationship among events
• Time handling
• Output statistics
12
An Example: Airport System
Single Server Queue
D Sf Ss A
Ground
Events: an instantaneous occurrence
that changes the state of a system
Arrival (A) Finish Service (Sf)
Start Service (Ss) Departure (D) 13
Stochastic Model and
System Attributes
• Customers
• Arrival process: schedule of aircraft arrivals
• Real trace
• Probability model: distribution of inter-arrival time
• i.i.d. (Independent and identically distributed )
• Uniform, normal, exponential …
• Servers
• How much service time is needed for each
customer?
• Probability model: i.i.d. and exponential distribution
• How many servers? 14
• Single
Stochastic Model and
System Attributes
• Queue
• Service discipline - who gets service next?
• First-in-first-out (FIFO), Last-in-first-out (LIFO), Priority,
Weighted-fairness (WFQ), random …
• Preemption?
• Queue capacity?
• k or infinite
• Ground
• Park time
• Probability model: i.i.d. and exponential
distribution 15
Stochastic Model and
System Attributes
• Uniform
• Given max and min
• 0 ≦ random() < 1
• = min + random() × (max - min)
• Exponential
• Given rate λ
• @p.30 of lec1.ppt
• Normal
• Asking Google
16
How to verify the correctness of
distribution generator?
17
How to verify the correctness of
distribution generator via Excel?
• Generating pdf
• Applying “Histogram” of “Data Analysis”
• “Data Analysis” is in “Analysis Toolpack” (分析工具箱)
18
How to verify the correctness of
distribution generator via Excel?
19
Simulation Development
• Events
• Stochastic model and system attributes
• System States
• Relationship among events
• Time handling
• Output statistics
20
System States
• System state
• A collection of variables in any time that
describe the system
• Event
• An instantaneous occurrence that changes the
state of a system State 1
Event Y Event X
Event X
Event Y
State 3 State 2
21
An Example: Airport System
Single Server Queue
D Sf Ss A
Ground
System States (Q:3 G:2 B:y)
Q: # of aircrafts waiting for landing
G: # of aircrafts on the ground
22
B: y/n; y if the runway is busy
An Example: Airport System
Single Server Queue
D Sf Ss A
Ground
Q:3 G:1
Q:4 G:2 A D B:y
B:y Q:3 G:2
Q:2 G:3
B:y B:y
IF Q>0 Q:3 G:3 Sf Ss 23
B:n
Simulation Development
• Events
• Stochastic model and system attributes
• System States
• Relationship among events
• Time handling
• Output statistics
24
Relationships among Events
27
Simulation Development
• Events
• Stochastic model and system attributes
• System States
• Relationship among events
• Time handling
• Output statistics
28
Time Handling
Simulation time
30
00:02:19
00:17:49
t = 00:48:37
Simulation Development
• Events
• Stochastic model and system attributes
• System States
• Relationship among events
• Time handling
• Output statistics
31
Output statistics
Q 0 1 0
G 0 1 0 1
B N Y N Y
00:02:19 00:17:49 00:48:37 00:59:06 00:48:37 01:22:11
Departure Event D
Finish Service Event Sf @ 00:59:06
@ 00:17:49 Finish Service Event Sf
Arrival Event A @ 01:22:11
Arrival Event A Arrival Event A
@ 00:48:37
@ 00:02:19 @ 01:12:28
Simulation time
32
Simulation Flow Chart
33