9 - Traffic Simulation Model
9 - Traffic Simulation Model
225J
1.225J (ESD 205) Transportation Flow Systems
Lecture 9
Simulation Models
Lecture 9 Outline
About this lecture:
• It is based on R16. Only material covered in class must be read
• Download a spreadsheet model from the 1.225F01 website
Introduction to simulation models and a simple example
Random numbers
Simulation models for M/M/1 queueing systems
Random observations
An event-driven simulation model for an M/M/1 queueing system
A spreadsheet implementation of an event-driven simulation model
for M/M/1
A discrete-time simulation model for an M/M/1 queueing system
Lecture summary
Queueing Models:
• How to determine the steady-state variables of a queueing system
with general interarrival and service time distributions ?
Coin-
Coin-Flipping Game: A Simulated Play
Number of
heads & tails
Cumulative number of
tails Number of tails =
number of heads + 3
⇒ Stop simulated play
Cumulative number of
heads Outcome: $8 - $11 = $ -3
1 2 3 4 5 6 7 8 9 10 11 Number of
Random number: 8, 1, 3, 7, 2, 7, 1, 6, 5, 5, 7 coin-flips
Head or Tail: T, H, H, T, H, T, H, T, T, T, T
Sample average of number of coin-flips per play: (11 + 5 + L + 7) / 14 = 7 (see R16) ; True mean is 9
Random Numbers
A random number is a random observation from the uniform
distribution on interval (0, 1) (U(0,1))
Theories related to random number generation methods are well
established. There are examples in R16 if you are interested in details
of such methods.
Most computer systems have functions that allow for generating
(artificial) random numbers
In Excel, RAND() returns a random number that we denote r
A(t)
N(t)
C(t)
t T Time
Arrival and departure times are discrete events
Two representations of time
• Discretize time in small time-intervals ⇒ discrete-time simulation
• Continuous-time ⇒ event-driven simulation
1.225, 11/28/02 Lecture 9, Page 9
An Event-
Event-Driven Simulation Model for M/M/1
An: arrival time of customer n
Dn: departure time (service completion time) of customer n
Hn: interarrival (arrival headway) time of customer n
Sn: service time of customer n
A1 = 0 and An = An-1 + Hn for n = 2, 3, …
D1 = S1 and Dn = Sn + max {An , Dn-1} for n = 2, 3, …
Hn and Sn are generated from two exponential random variables
− ln (1 − rA ) − ln (1 − rD )
Hn = Sn =
λ µ
H n = − LN ( RAND()) / λ S n = − LN ( RAND()) / µ
Histogram
rou = 0.6, # of runs = 50, true mean = 5.0
14
12
10
Frequency
8
Frequency
6
4
2
0
0
0.8
1.6
2.4
3.2
4
4.8
5.6
6.4
7.2
8
8.8
W (sec)
Histogram
rou = 0.96, # of runs = 50, true mean = 50
7
6
5
Frequency
4
Frequency
3
2
1
0
e
0
8
16
24
32
40
48
56
64
or
M
W (sec)
Discrete-
Discrete-Time Simulation Model for M/M/1
M/M/1 model with:
• arrival rate λ = 3 customers per hour
• service completion rate µ = 5 customers per hour
• fixed-time interval ∆t = 6 min
Probability of one arrival during ∆t:
∆t
PA = Pr (t ≤ ∆t ) = ∫ λe −λw dw = 1 − e −λ∆t = 1 − e −3⋅6 / 60 = 0.259
0
10
Lecture 9 Summary
Introduction to simulation models
A simulation model for simple example (a coin-flipping game)
Random numbers
Simulation models for M/M/1 queueing systems
Random observations
An event-driven simulation model for an M/M/1 queueing system
A spreadsheet implementation of an event-driven simulation model
for M/M/1
A discrete-time simulation model for an M/M/1 queueing system
11