Chapter 2 - Simulation by Hand
Chapter 2 - Simulation by Hand
pt er
C h a h m
… o r i t
A l g
n c e l )
d v a n u a
e A ( m a
T i m n d
y H a
o n b
u l ati
Si m
Time Advance Algorithm
Example (Single Server Queue)
A small grocery store has only one checkout counter.
Customers arrive at this checkout counter at random from 1 to 8
minutes apart.
Each possible value of interarrival time has the same probability
of occurrence.
The service time vary from 1 to 6 minutes with the probability
shown below. (…given)
1 0.10
2 0.20
3 0.30
4 0.25
5 0.10
6 0.05
The problem is to analyze the system by simulating the arrival and service
of 20 customers and determine:
• The random digits were taken from the table in the previous slide but Dr Fentahu D. (Prof.) personally disagree with the
author the way he read the table (I believe that we have to follow a certain specific order in reading the table, otherwise
we may be biased such as not choosing small numbers, avoiding large number etc..
Generate service times (ST)
– Determine the range of random digits for each possible
service time
Service Service
Customer Random Digits Time Customer Random Digits Time
(Minutes) (Minutes)
1 84 4 11 32 3
2 10 1 12 94 5
3 74 4 13 79 4
4 53 3 14 05 1
5 17 2 15 79 5
6 79 4 16 84 4
7 91 5 17 52 3
8 67 4 18 55 3
9 89 5 19 30 2
10 38 3 20 50 3
Simulation Table Preparation (the required)
Time Since Arrival Service Time Time Time Time Idle Time
Customer Last Time Time Service Customer Service Customer of Server
Arrival (Clock) (Minutes) Begin Waite in Ends Spends in (Minutes)
(Minutes) (Clock) Queue (Clock) System
(Minutes) (Minutes)
1 -- 0 4 0 0 4 4 0
2 8 1 8 0 9 1 4
3 8 14 4 14 0 18 4 5
4 6 15 3 18 3 21 6 0
5 1 23 2 23 0 25 2 2
6 8 26 4 26 0 30 4 1
7 3 34 5 34 0 39 5 4
8 8 41 4 41 0 45 4 2
9 7 43 5 45 2 50 7 0
10 2 46 3 50 4 53 7 0
11 3 47 3 53 6 56 9 0
12 1 48 5 56 8 61 13 0
13 1 53 4 61 8 65 12 0
14 5 59 1 65 6 66 7 0
15 6 62 5 66 4 71 9 0
16 3 70 4 71 1 75 5 0
17 8 71 3 75 4 78 7 0
18 1 73 3 78 5 81 8 0
19 2 77 2 81 4 83 6 0
20 4 82 3 83 1 86 4 0
5 56 124 18
68
The recursive equation to calculate Time Service Begin
• AT(i) = Arrival time for customer i
• ST(i) = Service time for customer i
Arriving Departing
7 6 5 4
(Blank Parts) (Finished Parts)
Queue Part in Service
(FIFO)
• General intent:
Estimate expected production
Waiting time in queue, queue length
Proportion of time machine is busy
• Time units
Can use different units in different places … must declare
Be careful to check the units when specifying inputs
Declare base time units for internal calculations, outputs
Be reasonable (interpretation, roundoff error)
Model Specifics
Initially (time 0) empty and idle
Base time units: minutes
Input data (assume given for now …), in minutes:
N
WQi N = no. of parts completing queue wait WQi = waiting time
i 1 in queue of ith part Know:
WQ1 = 0 (why?) N > 1 (why?)
N
Max WQi
i 1,...,N
… cont’d
TSi
i 1 max TSi TSi = time in system of part i
P , i 1,...,P
… cont’d
20
0 B(t ) dt , B(t ) 1
if the machine is busy at time t
if the machine is idle at time t
20 0
Simulation by Hand (the required part)
4
3
Q(t) graph 2
1
0
0 5 10 15 20
2
B(t) graph 1
0
0 5 10 15 20
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 0.00, Initialize
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 0.00, Arrival of Part 1
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 1.73, Arrival of Part 2
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 2.90, Departure of Part 1
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 3.08, Arrival of Part 3
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 3.79, Arrival of Part 4
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 4.41, Arrival of Part 5
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 4.66, Departure of Part 2
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 8.05, Departure of Part 3
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 12.57, Departure of Part 4
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 17.03, Departure of Part 5
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 18.69, Arrival of Part 6
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 19.39, Arrival of Part 7
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
t = 20.00, The End
Time (Minutes)
Interarrival times 1.73, 1.35, 0.71, 0.62, 14.28, 0.70, 15.52, 3.15, 1.76, 1.00, ...
Service times 2.90, 1.76, 3.39, 4.52, 4.46, 4.36, 2.07, 3.36, 2.37, 5.38, ...
Summary
Average waiting time in queue: