07 PENTING QueueingTheoryPart3
07 PENTING QueueingTheoryPart3
(Part 3)
Queueing Theory-1
M/M/s Queueing System
• We define
λ = mean arrival rate
µ = mean service rate
s = number of servers (s > 1)
ρ = λ / sµ = utilization ratio
• We require λ < sµ , that is ρ < 1 in order to have a steady state
Rate Diagram
λ λ λ λ λ λ λ λ λ
… …
0 1 2 3 4 s-1 s s+1
µ 2µ 3µ 4µ 5µ (s-1)µ sµ sµ sµ
Queueing Theory-2
M/M/s Queueing System
Steady-State Probabilities
and Pn = CnP0 0 1 2 3 4 …
µ 2µ 3µ 3µ 3µ
n
$*+'
! (( %% # " &4 1 1
! )µ& C0 = 1
n = 1, 2, ..., s C4 = % (
! n! " $ µ ' 3 3!
C1 =
+ + ...+ ! µ # " &5# 1 &2 1
where Cn = µn ,1µ n ,2...µ 0 = # 2 C5 = % ( % (
n n ,1 1 ! n " " # "& 1 $ µ ' $ 3 ' 3!
!*+' C2 = =% (
µ 2µ $ µ ' 2!
! (( µ %%
! ) n&,s n = s + 1, s + 2, ... # " &3 1 # " & n # 1 & n)s 1
" s! s C3 = % ( Cn = % ( % (
$ µ ' 3! Queueing $ µ ' $ s ' s!
Theory-3
! !
M/M/s Queueing System
L, Lq, W, Wq
How to find L? W? Wq?
Use Lq to find Wq (Lq = λWq):
P0 (! / µ )s #
Lq = Wq = Lq/λ
s! (1 " #)2 Use Wq to find W:
W = Wq + 1/µ
P0 !s +1 Use L=λW to find L in terms
=
(s " 1)! µ s "1(sµ " ! )2 of Lq:
L = λW
s
& P ( . / µ ) , 1 - e - µt ( s -1-. / µ ) )# = λ(Wq + 1/µ)
P(0 > t ) = e - µt $1 + 0 ** ''! = λ(Lq/λ + 1/µ)
% s!(1 - / ) + s - 1 - . / µ (" = Lq + λ/µ
) s #1 & # sµ (1# ! )t
P("q > t ) = '1 # * Pn $e
( n =0 % If s – 1 – λ /µ = 0
then this term is (µt)
Queueing Theory-4
M/M/s Example: A Better ER
• As before, we have
– Average arrival rate = 1 patient every ½ hour
λ = 2 patients per hour
– Average service time = 20 minutes to treat each patient
µ = 3 patients per hour
• Now we have 2 doctors
s=2
• Utilization
ρ = λ/2µ = 2/6 = 1/3 (Before s=1, ρ=2/3)
Queueing Theory-5
M/M/s Example: ER
Questions
In steady state, what is the…
1. probability that both doctors are idle?
P=
( " µ) P0 =
21 1
=
! 1
1! 32 3
2. probability that there are n patients?
, # " &n
! .% ( n
. $ µ ' P = # 2& 1 1 if 0 ) n < 2
. n! 0 %$ 3 (' n! 2
Pn = - n
.# "&
. %$ µ (' # 2 & n 1 # 1 & n*2 1 # 1 & n
. n*s P0 = % ( % ( =% ( if n + 2
/ s!s $ 3 ' 2! $ 2 ' 2 $ 3 '
3. expected number of patients in the ER? Queueing Theory-7
7. probability that there are at least two patients waiting in queue?
Queueing Theory-8
M/M/s Example: ER
Questions
In steady state, what is the…
4. expected number of patients waiting for a doctor?
s 2
P0 ( " µ) # (1 2)(2 /3) (1 3) 1
Lq = s = 2 =
s!(1$ # ) 2!(2 /3) 12
5. expected time in the ER?
W = L/λ = (3/4)/2 = 3/8 hour ≈ 22.5 minutes
!
6. expected waiting time?
Wq = Lq/λ = (1/12)/2 = 1/24 hour ≈ 2.5 minutes
7. probability that there are at least two patients waiting in queue?
P(≥ 4 patients in system) = 1 – P0 – P1 – P2 – P3
= 1 – ½ - 1/3 – 1/9 – 1/27 ≈ 0.0185
8. probability that a patient waits more than 30 minutes?
% 1 1( 1
P (" q > t ) = (1# P0 # P1 )e#2 µ(1# $ ) t = '1# # *e#2(3)( 2 3) t = e#4 t
& 2 3) 6
% ( Queueing Theory-9
1
P (" q > 30min) = P'" q > hour * + 0.022
& 2 )
Performance s=1 s=2
Measurements
ρ 2/3 1/3
L 2 3/4
Lq 4/3 1/12
W 1 hr 3/8 hr
Wq 2/3 hr 1/24 hr
Queueing Theory-10
Travel Agency Example
• Suppose customers arrive at a travel agency according to a
Poisson input process and service times have an exponential
distribution
• We are given
– λ= 0.10/minute, that is, 1 customer every 10 minutes
– µ =0.08/minute, that is, 8 customers every 100 minutes
• If there was only one server, what would happen?
λ/µ > 1
Customers would balk at long lines – never reach steady state
- lose customers
- go out of business?
• How many servers would you recommend?
Calculate P0, Lq and Wq for s=2, s=3, and s=4
Queueing Theory-11
P(ω>t) =
P(ωq>t) =
Queueing Theory-12
P(ω>t) =
P(ωq>t) =
Queueing Theory-13
P(ω>t) =
P(ωq>t) =
Queueing Theory-14
Single Queue vs. Multiple Queues
• Would you ever want to keep separate queues for separate
servers?
Single
queue
vs.
Multiple
queues
Queueing Theory-15
Bank Example
• Suppose we have two tellers at a bank
• Compare the single server and multiple server models
• Assume λ = 2, µ = 3,
L Lq W Wq P0 ρ
λ/2µ
0.75 0.083 0.375 0.042 0.5
=1/3
λ`/µ
=(λ/µ)/3
1.0 0.334 0.5 0.167 0.4449
=1/3
Queueing Theory-16
Bank Example
Continued
• Suppose we now have 3 tellers
• Again, compare the two models
Queueing Theory-17
M/M/s//K Queueing Model
(Finite Queue Variation of M/M/s)
λ λ λ λ λ λ λ 0
0 1 … s-1 s s+1 … K
µ 2µ (s-1)µ sµ sµ sµ sµ
Queueing Theory-18
M/M/s//K Queueing Model
(Finite Queue Variation of M/M/s)
λ λ λ λ λ λ 0
0 1 2 3=s 4 … K
µ 2µ 3µ 3µ 3µ 3µ
C0 = 1 1
Balance equations: Rate In = Rate Out P0 =
" K
C1 =
State 0: µP1 = λP0 µ !C n
State 1: λP0 + 2µP2 = (λ+µ)P1 "2 n=0
C2 = 2
State 2: λP1 + 3µP3 = (λ+2µ)P2 2µ Pn = Cn P0
3
State 3: λP2 + 3µP4 = (λ+3µ)P3 "
C3 = 3
(s = 3)
3!µ
…
4
$ 1 '$ " '
C4 = & )& )
State K-1: λPK-2 + 3µPK = (λ+3µ)PK-1 % 3!#3 (% µ (
State K: λPK-1 = 3µPK !
n
$ 1 '$ " '
Cn = & )& ) for s + n + K
% 3!#3( n*s) (% µ ( Queueing Theory-19
CK +1 = 0
M/M/s//K Queueing Model
(Finite Queue Variation of M/M/s)
Solving the balance equations, we get the following steady state
probabilities:
!n
n
P0
n! µ for n = 1, 2, ..., s
1 !n
P0 = s K Pn = n "s n
P0
n s n$s s s! µ for n = s, s + 1, ..., K
1+ # ( " /n!µ ) + ( " /s!µ ) #( ) "
sµ
n=1 n= s+1 0 n>K
Verify that these equations match those given in the text for the single
server case (M/M/1//K)
Queueing Theory-20
M/M/s//K Queueing Model
(Finite Queue Variation of M/M/s)
P0 (( / µ )s )
Lq = 2
[1 ' )K 's ' (K ' s ))K 's (1 ' ))], where ) = ( / sµ
s! (1 ' ))
s '1
& s '1 #
L = * nPn + Lq + s $$1 ' * Pn !!
n =0 % n =0 "
0 1 … s s+1 … N
µ 2µ sµ sµ sµ sµ
Queueing Theory-22
M/M/s///N Queueing Model
(Finite Calling Population Variation of M/M/s)
Nλ (N-1)λ (N-2)λ (N-3)λ (N-4)λ λ 0
0 1 2 3 4 … N
µ 2µ 3µ 3µ 3µ 3µ
Balance equations: Rate In = Rate Out
State 0: µP1 = λP0 è P1 = (Nλ/µ)P0
State 1: NλP0 + 2µP2 = ((N-1)λ+µ)P1 è P2 = (1/2)(Nλ/µ) ((N-1)λ/µ)P0
…
C0 = 1
# "&
C1 = N % (
$ µ'
2
N ( N )1) # " &
C2 = % (
2 $ µ'
3
N ( N )1)( N ) 2) # " & Queueing Theory-23
C3 = % (
3! $µ'
M/M/s///N Results
1
P0 = s "1 n N n
N! ()% N! ()%
!
n =0
& # +!
(N " n )! n! ' µ $ n =s (N " n )! s! s n "s
& #
'µ$
n
$ N! +,(
! )) && P0 for n = 0,1,..., s
! (N - n )! n! * µ '
! n
Pn = # N ! + , (
) & P for s %n%N
! (N - n )! s! s n -s )* µ &' 0
!
!
" 0 for n>N
s '1
N & s '1 #
Lq = ! (n " s )Pn L = ( nPn + Lq + s $$1 ' ( Pn !!
n =s n =0 % n =0 "
Queueing Theory-24