Queuing System in Simulation
Queuing System in Simulation
Chapter 8
Queueing Systems
a l
ep
itn
1
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
1
Queueing Systems
a l
Airport Runways, Gates Airplanes, travelers
ep
Communications network Nodes, links Messages, Packets
itn
2
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
2
Queueing Systems
l
Busy Enter queue Enter queue
a
Server
ep
status Idle Impossible Enter service
itn
3
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
3
Queueing Systems
Departure
event
Begin Another
server idle unit
Remove the waiting
time
NO waiting? YES unit from the queue
l
NO Server YES
a
busy?
ep
Unit enters
Unit enters
itn
queue for 4
service
service
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
4
Characteristics of Queueing Systems
a l
Queue behavior and descipline
ep
Service times and service mechanism
itn
5
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
5
Components Queueing Systems
a l
ep
itn
6
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
6
Arrival Process
a l
6 6 15
ep
itn
7
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
7
Arrival Process
Notation;
Ta Mean inter-arrival time
λ Mean arrival time
a l
1
ep
They are related as; λ =
Ta
itn
8
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
8
Arrival Process
Example - office;
- five days a week
- Eight-hour day
- 800 calls a week
- Model the office using time scale of minutes
1 week = 40 working hours. Therefore inter-arrival time
= (40 * 60) / 800
= 3 minutes
i.e. 0.333 calls per minute
a l
affected by the number of customers
ep
- If the arrival process is homogenous (no rush-hours)
itn
then arrival is linear 9
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
9
Arrival Process
l
A0(t) = 1 – F(t)
a
ep
Therefore, takes maximum value of ‘1’ at t = 0
itn
10
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
10
Poisson Arrival Patterns
a l
f (t ) = λ .e − λt (t >= 0)
ep
itn
11
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
11
Poisson Arrival Patterns
a l
ep
itn
12
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
12
Poisson Arrival Patterns
f (t )
So now, arrival distribution will be; A=
λ
− λt
A0 (t ) = e A=
λ.e −λt
λ
A = e − λt
Here, λ is mean no. of arrivals per unit time and
arrivals in a period of time ‘t’ is again a random
variable.
So now, probability of ‘n’ arrivals occurring in a
period of length ‘t’ is given by (exponential)
(λt ) n e − λt
p ( n) =
n!
a l
ep
itn
13
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
13
Poisson Arrival Patterns
Example;
Arrival Arrival Inter-arrival Arrival Arrival Inter-
Number Time Time Number Time arrival time
1 12.5 12.5 11 136.4 21.4
2 15.1 2.6 12 142.7 6.3
3 44.1 29.0 13 151.2 8.5
4 62.6 18.5 14 162.5 11.3
5 65.3 2.7 15 167.2 4.7
6 67.6 2.3 16 172.9 5.7
7 71.0 3.4 17 179.8 6.9
8 92.5 21.5 18 181.6 1.8
l
9 106.5 14.0 19 185.0 3.4
a
ep
10 115.0 8.5 20 194.9 9.9
itn
14
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
14
Poisson Arrival Patterns
Example;
The inter arrival time is ranging from 1.8 to 29.0.
Look at graph plot at page 149 of text book.
Taking the average of the inter arrival time;
9.74
1
Therefore, estimated arrival rate is = λ =
Ta
= 0.103
Now, let’s group the time period into 10 different
range of size 20
a l
ep
itn
15
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
15
Poisson Arrival Patterns
Example;
Time Period No. of Arrivals Time Period No. of Arrivals
0-20 2 100-120 2
20-40 0 120-140 1
40-60 1 140-160 2
60-80 4 160-180 4
80-100 1 180-200 3
l
2, 3, 4, 5 will be;
a
ep
itn
16
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
16
Poisson Arrival Patterns
Example;
No. of arrivals Actual No. of p(n) Expected
in 20 mins Occurrences number of
occurrences
0 1 0.128 1.3
1 3 0.266 2.7
2 3 0.272 2.7
3 1 0.187 1.9
4 2 0.096 1.0
5 0 0.040 0.4
a l
ep
itn
17
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
17
Poisson Arrival Patterns
Example;
Number of people logging onto a computer per minute is
Poisson Distributed with mean 0.7
What is the probability that 5 or more people will log onto
the computer in the next 10 minutes?
Solution?
Must first convert the mean to the 10 minute period – if mean is 0.7 in
1 minute, it will be (0.7)(10) = 7 in a ten minute period
a l
= 1 – 0.173 (from the table in the text)
ep
= 0.827
itn
18
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
18
The Exponential Distribution
l
arrivals
a
ep
Ex: 20 customers served per hour Æ 1/20 hr (3min) average
service time
itn
19
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
19
The Exponential Distribution
la
ep
It shows that exponential distribution is dependent
on mean value
itn
20
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
20
The Exponential Distribution
1 1
E( X ) = V (X ) =
λ λ2
0 , x < 0
F ( x) = x −λt
∫0
− λx
λe dt = 1 − e , x≥0
a l
ep
itn
21
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
21
The Exponential Distribution
Example – Generation;
Let’s consider we have 5 random numbers ‘y’ in the range
(0,1). The numbers are 0.135, 0.639, 0.424, 0.010,
0.843
Given λ = 3.8
1/ λ = 1/3.8
a l
ep
itn
22
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
22
Coefficient of Variation
a l
ep
itn
23
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
23
Erlang Distribution
a l
ep
Where k is a positive integer
itn
24
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
24
Erlang Distribution
a l
λ λ λ λ λ
ep
k-terms
itn
25
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
25
Erlang Distribution
a l
ep
itn
26
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
26
Erlang Distribution
Example - Generation;
- Generate ‘k’ random samples from an exponential
distribution with mean time of β
- Add all of the terms
a l
ep
itn
27
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
27
Erlang Distribution
Exercise 5.21
Time to serve a customer at a bank is exponentially
distributed with mean 50 sec
1. Probability that two customers in a row will each
require less than 1 minute for their transaction
2. Probability that the two customers together will
require less than 2 minutes for their transactions
For 1) we are looking at the probability that each of two
independent events will be < 1 minute
In this case, the probability overall is the product of the two
probabilities, each of which is exponential
l
λ = rate = 1/mean = 1/50
a
ep
We want P(X < 60) = F(60) = 1 – e-(1/50)(60) = 0.6988
Thus the total probability is (0.6988)2 = 0.4883
itn
28
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
28
Erlang Distribution
a l
ep
itn
29
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
29
Hyper Exponential Distribution
T
1− s
2(1 − s )
a l
−2 sλt −2 (1− s ) λt
A0 (t ) = se + (1 − s )e
ep
itn
30
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
30
Hyper Exponential Distribution
The variance
(1 − 2 s + 2 s ) 2
k=
2 s (1 − s )
when s = ½, k becomes 1 and hence gives exponential
distribution
Steps;
- Generate exponentially distributed rn from uniformly distributed
random number with mean value of 1
- Compare the second uniformly distributed random number to ‘s’
- If less than s, multiply by T/2s
a l
- Else multiply by T/2(1-s)
ep
itn
31
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
31
Service Times
a l
ep
itn
32
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
32
Service Times
a l
ep
itn
33
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
33
Normal Distribution
a l
ep
itn
34
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
34
Normal Distribution
-Property;
67%
93%
99%
µ − 3σ µ − 2σ µ −σ µ +σ µ + 2σ µ + 3σ
µ
a l
ep
itn
35
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
35
Normal Distribution
To generate numbers distributed according to f(z), we use
x = z . σ + µ, z = standard normal variate
If r1 and r2 are two uniform random numbers in the range (0, 1), then to
generate random samples from a standardized normal distribution is
to use ‘Box Mueller Transformation’;
z = (−2. ln r1 ) . cos(2πr2 )
1/ 2
a l
k
ep
i =1
12
itn
36
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
36
Normal Distribution
a l
(independent and identically distributed)
ep
itn
37
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
37
Queueing Notation
Standard notation
A/B/c/N/K
a l
ep
itn
38
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
38
Queueing Notation
This can affect the effective arrival rate, since some arrivals may have
to be discarded
a l
- It could be some relatively small, fixed size
ep
Ex: The computers in a lab that may require service
itn
39
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
39
Queueing Notation
a l
chance of going down in a given day. If a computer
ep
goes down, the repair takes a mean of 2 days
itn
40
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
40
Queueing Notation
a l
ep
itn
41
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
41
Queueing Notation
Example;
1. there are ‘s’ servers in parallel and one FIFO queue feeding all
servers
2. A1, A2, . . . are IID random variables
3. S1, S2, . . . are IID random variables
4. Ai’s and Si’s are independent
Such system is represented by GI/G/s queue
GI – distribution of Ai
G – distribution of Si
M/M/1/∞/∞
Here, the interarrival time and service time are exponentially
distributed, the server is of single-server, the system have
a l
infinite capacity and infinite population of potential arrivals
ep
This kind of server often represented by M/M/1
itn
42
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
42
Queueing Disciplines
a l
time for each entity
ep
itn
43
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
43
Queueing Disciplines
a l
ep
itn
44
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
44
Measure of Performance for Queues
a l
If ‘n’ number of servers;
ep
ρ = λ / (n.µ)
itn
45
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
45
Measure of Performance for Queue
a l
ep
itn
46
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
46
Measure of Performance for Queue
l
system (Mean no. of entities in the system)
a
ep
itn
47
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
47
Measure of Performance for Queue
a l
begin is greater than ‘t’
ep
itn
48
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
48
Mathematical Solutions of Queuing Problems
a l
2k (1 − ρ )
ep
ρ 2 + ρ (1 − ρ )4 s (1 − s )
L= Hyper-Exponential
itn
4 s (1 − s )(1 − ρ ) 49
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
49
Mathematical Solutions of Queuing Problems
a l
ep
itn
50
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
50
Time-Average Number in the System, L
T2 T2
2
T1 T1 T1 T1
1
al
ep
T0 T0
itn
51
0 2 4 6 8 10 12 14 16 20 t
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
51
Time-Average Number in the System, L
a l
ep
itn
52
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
52
Time-Average Number in the System, L
∧
We can calculate L for an interval [0,T] in a fairly
straightforward manner using a sum
∞
∧ 1
L=
T
∑ iT
i=0
i
al
In other words, there is some maximum number in the
ep
system that is never exceeded
itn
53
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
53
Time-Average Number in the System, L
a l
T
Area = ∫ L(t ) dt
ep
0
itn
54
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
54
Time-Average Number in the System, L
l
average number in the queue, and LQ, the long-run
a
ep
time average number in the queue
itn
55
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
55
Time-Average Number in the System, L
a l
ep
itn
56
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
56
Average Time in System Per Customer, w
l
We can think of these values as the observed delay and the
a
long-run average delay per customer
ep
Example: from 216 - Nicol
itn
57
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
57
Average Time in System Per Customer, w
a l
This will lead to increase in the number in the system
ep
(L(t)) without bound as t increases
itn
58
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
58
Average Time in System Per Customer, w
a l
ep
itn
59
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
59
Average Time in System Per Customer, w
a l
arrival rate
ep
As arrivals occur, the arrival rate decreases and the system again
becomes stable
itn
60
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
60
Conservation Law
a l
ep
itn
61
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
61
Server Utilization
a l
However, we can also calculate the server utilization
ep
based on the arrival and service rates
itn
62
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
62
Server Utilization
G/G/1/∞/∞ systems
Consider again the arrival rate λ and the service rate
µ
Consider only the server (without the queue)
With a single server, it can be either busy or idle
If it is busy, there is 1 customer in the "server
system", otherwise there are 0 customers in the
"server system" (excluding the queue)
Thus we can define Ls = ρ = average number of
customers in the "server system"
Using the conservation equation this gives us
Ls = λsws
a l
where λs is the rate of customers coming into the server and
ep
ws is the average time spent in the server
itn
63
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
63
Server Utilization
a l
the longer the lines will be (probably)
ep
Actual line length depends a lot not just on the rates, but also
on the variance
itn
64
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
64
Server Utilization
G/G/c/∞/∞ systems
Applying the same techniques we did for the
single server, recalling that for a stable
system with c servers:
λ < cµ
we end up with the the final result
ρ = λ/cµ
al
ep
itn
65
(C) Pramod Parajuli, 2004
cs
Source: www.csitnepal.com
65