queuing theory

89
Queueing Theory-1 Queueing Theory Chapter 17

Upload: esther-grace-vinitha

Post on 30-Apr-2017

245 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Queuing Theory

Queueing Theory-1

Queueing Theory

Chapter 17

Page 2: Queuing Theory

Queueing Theory-2

Basic Queueing Process

Arrivals •  Arrival time

distribution •  Calling population

(infinite or finite)

Queue •  Capacity

(infinite or finite) •  Queueing

discipline

Service •  Number of servers

(one or more) •  Service time

distribution

J

“Queueing System”

Page 3: Queuing Theory

Queueing Theory-3

Examples and Applications

•  Call centers (“help” desks, ordering goods) •  Manufacturing •  Banks •  Telecommunication networks •  Internet service •  Transportation •  Hospitals •  Restaurants •  Other examples….

Page 4: Queuing Theory

Queueing Theory-4

Labeling Convention (Kendall-Lee)

/ / / / / Interarrival

time distribution

Number of servers

Queueing discipline

System capacity

Calling population

size

Service time

distribution

M Markovian (exponential interarrival times, Poisson number of arrivals)

D Deterministic Ek Erlang with shape

parameter k G General

FCFS first come, first served

LCFS last come, first served

SIRO service in random order

GD general discipline

Priority queues Round robin

Finite Capacity K Infinite Capacity +∞

Finite Population N Infinite Population +∞

Page 5: Queuing Theory

Queueing Theory-5

Labeling Convention (Kendall-Lee)

Examples: M/M/1 M/M/1/FCFS/∞/∞ M/M/s M/M/s/FCFS/∞/∞ M/G/1 M/M/s//10 M/M/s/FCFS/K=10/∞

M/M/1///100 M/M/1/FCFS/∞/N=100

Ek/G/2//10 Erlang(k)/General/s=2/FCFS/K=10/∞

Page 6: Queuing Theory

Queueing Theory-6

Terminology and Notation •  State of the system

Number of customers in the queueing system (includes customers in service)

•  Queue length Number of customers waiting for service = State of the system - number of customers being served

•  N(t) = State of the system at time t, t ≥ 0 •  Pn(t) = Probability that exactly n customers are in the queueing

system at time t •  L = Expected number of customers in the system •  Lq = Expected number of customers in the queue

Page 7: Queuing Theory

Queueing Theory-7

Terminology and Notation •  λn = Mean arrival rate (expected # arrivals per unit time)

of new customers when n customers are in the system

•  s = Number of servers (parallel service channels) •  µn = Mean service rate for overall system

(expected # customers completing service per unit time) when n customers are in the system

Note: µn represents the combined rate at which all busy servers (those serving customers) achieve service completion.

Page 8: Queuing Theory

Queueing Theory-8

Terminology and Notation •  State is number of customers in the system, may be infinite •  Transitions can happen at any time, so instead of transition

probabilities, as with Markov chains, we have transition rates •  Queueing analysis is based on a special case of continuous time

Markov chains called birth-death processes

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

Page 9: Queuing Theory

Queueing Theory-9

Example •  Arrival rate depends on the number n of customers in the system

λ0: 6 customers/hour λ1: 5 customers/hour λ2: 4 customers/hour

•  Service rate is the same for all n µ1: 2 customers/hour µ2: 2 customers/hour µ3: 2 customers/hour

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

Page 10: Queuing Theory

Queueing Theory-10

Terminology and Notation When arrival and service rates are constant for all n, λ = mean arrival rate

(expected # arrivals per unit time) µ = mean service rate for a busy server 1/λ = expected interarrival time 1/µ = expected service time ρ = λ/sµ

= utilization factor for the service facility = expected fraction of time the system’s service capacity (sµ)

is being utilized by arriving customers (λ)

Page 11: Queuing Theory

Queueing Theory-11

Example •  A customer arrives every 10 minutes, on average

- What is the arrival rate per minute? λ = 1 customer / 10 minutes = 0.10 customers/minute or 6 customers/hour - Interarrival time between customers is 1/λ

•  The service time takes 30 minutes on average - What is the service rate per minute? µ = 1 customer / 30 minutes = 0.0333 customers/minute or 2 customers/hour - Service time is 1/µ

Customer arrives

Customer arrives

Customer arrives

Customer arrives

Page 12: Queuing Theory

Queueing Theory-12

Terminology and Notation Steady State

When the system is in steady state, then Pn = probability that exactly n customers are in the queueing system L = expected number of customers in queueing system

=

Lq = expected queue length (excludes customers being served) =

!"

=0nnnP

!"

=

#sn

nPsn )(

0 1 2

λ0 λ1 λ2

µ2 µ3

… µ1

Page 13: Queuing Theory

Queueing Theory-13

Example: Utilization

•  Suppose λ = 6 customers/hour and µ = 2 customers/hour •  Utilization is ρ= λ/(sµ) •  If one server, s=1, ρ= λ/µ = 6/2 = 3,

utilization > 1, so steady state will never be reached, queue length will increase to infinity in the long run

•  If three servers, s=3, ρ= λ/(3µ) = 1

utilization = 1, queue is unstable and may never reach steady state

•  If four servers, s=4, ρ= λ/(4µ) = 3/4 utilization < 1, the queue will reach steady state and L is finite

Page 14: Queuing Theory

Queueing Theory-14

Terminology and Notation Steady State

When the system is in steady state, then ω = waiting time in system (includes service time)

for each individual customer W = E[ω] = expected time in system ωq = waiting time in queue (excludes service time)

for each individual customer Wq = E[ωq] = expected time in queue

Page 15: Queuing Theory

Queueing Theory-15

Little’s Formula

•  Assume λn=λ and µn=µ (arrival and service rates constant for all n)

•  In a steady-state queue,

Expected number in system =

(Arrival rate) x (Expected time in system)

Expected time in system =

(Expected time in queue) +

(Expected time in service) !

L = "WLq = "Wq

Demonstrates the relationships between L, W, Lq, and Wq Intuitive Explanation: 1. * C C C C Server

I have just arrived, and because the system is in steady state, I expect to wait W until I leave

2. C C C C Server * As I leave, the number of customers in the system is the number that arrived while I was in the system. Because the system is in steady state, I expect this number to be L. But, if I expect to wait W, and the average arrival rate is λ, then I expect to see λW arrivals while I am in the system, so L= λW !

me

me

!

W =Wq +1µ

Page 16: Queuing Theory

Queueing Theory-16

Little’s Formula (continued) •  This relationship also holds true for λ (expected arrival rate)

when λn are not equal. !

Recall, Pn is the steady state probability of having n customers in the system

!

L = " WLq = " Wq

where " = "nPnn= 0

#

$0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

Page 17: Queuing Theory

Queueing Theory-17

Heading toward M/M/s

•  The most widely studied queueing models are of the form M/M/s (s=1,2,…)

•  What kind of arrival and service distributions does this model assume?

•  Reviewing the exponential distribution…. •  A picture of the probability density function for :)l(exponentia~ !T

α

e!

!21

!

1

fT(t)

t

!

Area = P T <12"

#

$ %

&

' ( = 0.393

!

Area = P 12"

< T <1"

#

$ %

&

' ( = 0.239

!

Area = P T >1"

#

$ %

&

' ( = 0.368

Page 18: Queuing Theory

Queueing Theory-18

Exponential Distribution Reviewed

If T ~ exponential(α), then

!"#

<$%=

%&

000)( t

tetft

T

!

FT (t) = P(T " t) = #e$#uduu= 0

t

% =1$ e$#t

P(T > t)=1$ 1$ e$#t( ) = e$#t

E[T] =

Var(T) =

!1

21!

α

e!

!21

!

1

fT(t)

t

1

!

1

FT(t)

t

1-e-1

Page 19: Queuing Theory

Queueing Theory-19

Property 1 Strictly Decreasing

The pdf of exponential, fT(t), is a strictly decreasing function

•  A picture of the pdf: )()0( ttTtPtTP !+"">!""

α

e!

!21

!

1

fT(t)

t

!

Area = P T <12"

#

$ %

&

' ( = 0.393

!

Area = P 12"

< T <1"

#

$ %

&

' ( = 0.239

!

Area = P T >1"

#

$ %

&

' ( = 0.368

Page 20: Queuing Theory

Queueing Theory-20

Property 2 Memoryless

The exponential distribution has lack of memory i.e. P(T > t+s | T > s) = P(T > t) for all s, t ≥ 0 Example: P(T > 15 min | T > 5 min) = P(T > 10 min) For interarrival times, this means the time of the next arriving customer is independent of the time of the last arrival i.e. arrival process has no memory This assumption is reasonable if

1. there are many potential customers 2. each customer acts independently of the others 3. each customer selects the time of arrival randomly

Ex: phone calls, emergency visits in hospital, cars (sort of)

The probability distribution has no memory of what has already occurred For service times, most of the service times are short, but occasional long service times

Page 21: Queuing Theory

Queueing Theory-21

Property 2 Memoryless

•  Prove the memoryless property for the exponential distribution

Only exponential and geometric distributions are memoryless

•  Is this assumption reasonable? –  For interarrival times

–  For service times

!

P T > t + s |T > s( ) =P T > t + s and T > s( )

P T > s( )=P T > t + s( )P T > s( )

=e"# t+s( )

e"# s( ) =e"# t( )e"# s( )

e"# s( ) = e"# t( ) = P T > t( )

0 s t+s

t

Page 22: Queuing Theory

Queueing Theory-22

Property 3 Minimum of Exponentials

The minimum of several independent exponential random variables has an exponential distribution If T1, T2, …, Tn are independent r.v.s, Ti ~ expon(αi) and U = min(T1, T2, …, Tn), U ~expon( ) Example: If there are s servers, each with exponential service times with mean µ, then U = time until next service completion ~

!

exponential(sµ)1 2

s

µ µ

µ

X X X X X

!

" = " ii=1

n

#

Page 23: Queuing Theory

Queueing Theory-23

Property 4 Poisson and Exponential

Suppose the time T between events is exponential (α), let N(t) be the number of events occurring by time t. Then N(t) ~ Poisson(αt) Note: E[N(t)] = αt, thus the expected number of events per unit time is α

0 t

!

P N t( ) = n( ) ="t( )n e#"t

n!, n = 0,1,2,…

P N t( ) = 0( ) ="t( )0e#"t

0!= e#"t

P N t( ) =1( ) ="t( )1e#"t

1!="te#"t

P N t( ) = 2( ) ="t( )2e#"t

2

Page 24: Queuing Theory

Queueing Theory-24

Property 5 Proportionality

For all positive values of t, and for small Δt, P(T ≤ t+Δt | T > t) ≈ αΔt i.e. the probability of an event in interval Δt is proportional (with factor α) to the length of that interval

t t+Δt

αΔt

Page 25: Queuing Theory

Queueing Theory-25

Property 6 Aggregation and Disaggregation

The process is unaffected by aggregation and disaggregation

Aggregation

N1 ~ Poisson(λ1)

N2 ~ Poisson(λ2)

Nk ~ Poisson(λk) λ = λ1+λ2+…+λk

N ~ Poisson(λ)

N1 ~ Poisson(λp1)

N2 ~ Poisson(λp2)

Nk ~ Poisson(λpk)

N ~ Poisson(λ)

Disaggregation

p1

p2

pk … …

Note: p1+p2+…+pk=1 Ex: different types of customers are arriving into 1 queue Call center – customers from different cities, different questions Car repairs – different types of cars, different types of problems

Disaggregate to other queues or servers pi = probability of type i (fraction of type i)

Ex: Manufacturing – good, defective-scrap, rework

Page 26: Queuing Theory

Queueing Theory-26

Back to Queueing •  Remember that N(t), t ≥ 0, describes the state of the system:

The number of customers in the queueing system at time t

•  We wish to analyze the distribution of N(t) in steady state

•  Find the steady state probability Pn of having n customers in the system with rates λ0, λ1, λ2… and µ1, µ2, µ3…

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

Page 27: Queuing Theory

Queueing Theory-27

Birth-and-Death Processes •  If the queueing system is M/M/…/…/…/…, N(t) is a birth-and-death

process •  A birth-and-death process either increases by 1 (birth), or

decreases by 1 (death) •  General assumptions of birth-and-death processes:

1. Given N(t) = n, the probability distribution of the time remaining until the next birth is exponential with parameter λn

2. Given N(t) = n, the probability distribution of the time remaining until the next death is exponential with parameter µn

3. Only one birth or death can occur at a time

Page 28: Queuing Theory

Queueing Theory-28

Rate Diagrams

•  Rate diagrams indicate the states in a birth-and-death process and the arrows indicate the mean rates at which transitions occur

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

… n-2 n-1 n

λn-2 λn-1 λn

µn-1 µn µn+1

n+1

λn+1

µn+2

… λn-3

µn-2

Page 29: Queuing Theory

Queueing Theory-29

Steady-State Balance Equations

•  Assume the system achieves steady state (it will when utilization is strictly less than 1) •  Rate In = Rate Out

Pn = probability of n customers in system

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

… n

λn-1

µn

λn

µn+1

Page 30: Queuing Theory

Queueing Theory-30

Steady-State Balance Equations

Pn = probability of n customers in system

0 1 2

λ0 λ1 λ2

µ1 µ2 µ3

… n

λn-1

µn

λn

µn+1

!

State 0 : µ1P1 = "0P0 # P1 ="0

µ1

P0

State 1: "0P0 + µ2P2 = "1 + µ1( )P1 # P2 ="1"0

µ2µ1

P0

State n : "n -1Pn$1 + µn+1Pn+1 = "n + µn( )Pn # Pn+1 ="n"n$1!"0

µn+1µn!µ1

P0

Need Pn =1n=0

!

"

Define C0 =1

Cn =!n#1!!0

µn!µ1

Pn =CnP0

CnP0 = P0n=0

!

" Cn =1n=0

!

"

P0 =1

Cnn=0

!

"

Page 31: Queuing Theory

Recall Useful Facts

Queueing Theory-31

!

Geometric series

infinite sum: if x <1, xnn= 0

"

# =1

1$ x

finite sum : for any x %1, xnn= 0

N

# =1$ xN +1

1$ x

Page 32: Queuing Theory

Problem 17.5-5

•  A service station has one gasoline pump •  Cars wanting gasoline arrive according to a Poisson

process at a mean rate of 15 per hour •  However, if the pump already is being used, these

potential customers may balk (drive on to another service station). In particular, if there are n cars already at the service station, the probability that an arriving potential customer will balk is n/3 for n = 1, 2, 3

•  The time required to service a car has an exponential distribution with a mean of 4 minutes

Queueing Theory-32

Page 33: Queuing Theory

Problem 17.5-5

a)  Construct the rate diagram for this queuing system b)  Develop the balance equations c)  Solve these equations to find the steady-state

probability distribution of the number of cars at the station. Verify that this solution is the same as that given by the general solution for the birth-and-death process

d)  Find the expected waiting time (including service) for those cars that stay

Queueing Theory-33

Page 34: Queuing Theory

Queueing Theory-34

M/M/1 Queueing System •  Simplest queueing system based on birth-and-death •  We define

λ = mean arrival rate µ = mean service rate ρ = λ / µ = utilization ratio

•  We require λ < µ , that is ρ < 1 in order to have a steady state –  Why?

If p≥1, won’t converge, and the queue will explode (up to +∞)

Rate Diagram

0 1 2 3 4 …

λ λ λ λ λ

µ µ µ µ µ

Pn n=0

!

"

Page 35: Queuing Theory

Queueing Theory-35

M/M/1 Queueing System Steady-State Probabilities

Calculate Pn, n = 0, 1, 2, … Rate In = Rate Out

!

State 0 : µP1 = "P0 # P1 ="µP0

State 1: "P0 + µP2 = " + µ( )P1 # P2 =1µ

" + µ( ) "µP0 $

µµ"P0

%

& '

(

) * =

"2

µ2 P0

State n : Pn =""!"µµ!µ

P0 ="µ

%

& ' (

) *

n

P0 = +nP0

Need Pnn= 0

,

- =1

%

& ' (

) *

n

P0 = P0"µ

%

& ' (

) *

n

=n= 0

,

-n= 0

,

- P0 +n =n= 0

,

- P01

1$ +%

& '

(

) * =1

!

Geometric Series

"n =n= 0

#

$ 11% "

if " <1

!

For M/M/1 with " <1P0 =1# "Pn = "n 1# "( ) for n = 0,1,2,…

Page 36: Queuing Theory

Queueing Theory-36

M/M/1 Queueing System L, Lq, W, Wq

Calculate L, Lq, W, Wq

!

L = expected number in system = nPnn= 0

"

# = n$n 1% $( )n= 0

"

# = $ 1% $( ) n$n%1

n= 0

"

#

L = $ 1% $( ) d$n

d$n= 0

"

# = $ 1% $( ) dd$

$n

n= 0

"

# = $ 1% $( )d 1

1% $&

' (

)

* +

d$=$ 1% $( )1% $( )2 =

$1% $

=, /µ

1% , /µ=

,µ % ,

Lq = expected number in queue = n %1( )Pnn=1

"

# = n %1( )$n

n=1

"

# 1% $( ) = n$n

n=1

"

# 1% $( ) % $n

n=1

"

# 1% $( )

Lq = L % 1% P0( ) = L % $ =$

1% $% $ =

$2

1% $=

,2

µ µ % ,( )

W =L,

=,

µ % ,( ),=

1µ % ,( )

Wq =Lq,

=,2

µ µ % ,( ),=

,µ µ % ,( )

!

d"n

d"= n"n#1

!

d 1" #( )"1

d#= "1 1" #( )"2 "1( )

d 1" #( )"1

d#=

11" #( )2

Page 37: Queuing Theory

Queueing Theory-37

M/M/1 Queueing System Distribution of Time in System

!

" = waiting time in system

W = E "[ ] =1

µ # $

P " > t( ) = e#µ 1#%( ) t for t & 0" q = waiting time in queue

Wq = E " q[ ] =$

µ µ # $( )P " q > t( ) = %P " q > t( ) = %e#µ 1#%( )t for t & 0

Page 38: Queuing Theory

Queueing Theory-38

M/M/1 Example: ER •  Emergency cases arrive independently at random •  Assume arrivals follow a Poisson input process (exponential

interarrival times) and that the time spent with the ER doctor is exponentially distributed

•  Average arrival rate = 1 patient every ½ hour λ= 2 patients / hour

•  Average service time = 20 minutes to treat each patient

µ= 1 patient / 20 minutes = 3 patients / hour •  Utilization

ρ = λ/µ=2/3

•  Does this M/M/1 queue reach steady state? Yes! ρ<1

Page 39: Queuing Theory

Queueing Theory-39

M/M/1 Example: ER Questions

In steady state, what is the… 1. probability that the doctor is idle?

P0=1-ρ=1-2/3 = 1/3

2. probability that there are n patients? Pn=ρn(1-ρ) = 1/3(2/3)n

3. expected number of patients in the ER? L = λ/(µ-λ) = 2/(3-2) = 2 patients

4. expected number of patients waiting for the doctor?

L = λ2/µ(µ-λ) = 4/3 patients

Page 40: Queuing Theory

Queueing Theory-40

M/M/1 Example: ER Questions In steady state, what is the…

5. expected time in the ER?

W= 1/(µ-λ) = 1 hour

6. expected waiting time? Wq= λ/µ(µ-λ) = 2/3 hour

Note: W = Wq + 1/µ that is 1 = 2/3 + 1/3 7. probability that there are at least two patients waiting to see the

doctor?

P(≥3 patients in system) = 1 – P0 – P1 – P2 = 1 – 1/3 – 2/9 – 4/27 = 0.296 = 0.44

8. probability that a patient waits more than 30 minutes?

P(ωq>1/2 hr) = ρe-µ(1-ρ)t = (2/3)e-3(1/3)1/2 = (2/3)e-1/2 = 0.404

Page 41: Queuing Theory

Queueing Theory-41

Car Wash Example •  Consider the following 3 car washes •  Suppose cars arrive according to a Poisson input process and

service follows an exponential distribution •  Fill in the following table What conclusions can you draw from your results? As ρ à 1, L, Lq, W, Wq à ∞ and P0 à 0

λ µ ρ L Lq W Wq P0

Car Wash A 0.1 car/min

0.5 car/min

0.1/0.5 = 0.2

(0.1)/(0.5-0.1) = 0.25

(0.1)2/(0.5)(0.4) = 0.05

0.25/0.1 = 2.5 min

0.5/0.1 = 0.5 min

0.4/0.5 = 0.8

Car Wash B 0.1 car/min

0.11 car/min

0.1/1.1 = 0.909

(0.1)/(0.11-0.1) = 10

(0.1)2/(0.11)(0.1) = 9.09

10/0.1 = 100 min

9.09/0.1 = 90.9 min

0.01/11 = 0.09

Car Wash C 0.1 car/min

0.1 car/min

0.1/0.1 = 1

0.1/(0.1-0.1) = +∞

Not steady state +∞ +∞ +∞ 0/0.1 = 0

Page 42: Queuing Theory

!"

#!"

$!"

%!"

&!"

'!"

(!"

)!"

*!"

+!"

#!!"

!,!!" !,#!" !,$!" !,%!" !,&!" !,'!" !,(!" !,)!" !,*!" !,+!" #,!!"

Queueing Theory-42

Car Wash Example •  M/M/1 with λ=0.1 car/min •  ρ=λ/µ •  L=λ/(µ-λ) = ρ/(1-ρ)

L

ρ Rule of thumb: never exceed ρ = 0.8, 80% utilization

Car wash A Car wash B

Page 43: Queuing Theory

Queueing Theory-43

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

λ λ λ

µ 2µ 3µ

s-1 s

λ λ λ

(s-1)µ sµ sµ

s+1

λ

… 3 4

λ λ

4µ 5µ

Page 44: Queuing Theory

Queueing Theory-44

M/M/s Queueing System Steady-State Probabilities

!!!!

"

!!!!

#

$

++=%%&

'(()

*µ+

=%%&

'(()

*µ+

=µµµ+++

=

,

,

,,

... 2,s 1,s!

s ..., 2, 1,!

......

11

021

nss

nn

C

sn

n

n

nn

nnn

)(

1

/11

!)/(

1

0!)/(

0

µ!"µ!

"

=

µ! +=

# ss

s

nn

snP

and Pn = CnP0

where

Use Birth Death Processes Rate In = Rate Out Coefficients are easy to remember if you think of rate diagram Say s = 3

0 1 2

λ λ λ

µ 2µ 3µ

3 4

λ λ

3µ 3µ

!

C0 =1

C1 ="µ

C2 ="µ"2µ

="µ

#

$ % &

' (

212!

C3 ="µ

#

$ % &

' (

313!

!

C4 ="µ

#

$ % &

' (

41313!

C5 ="µ

#

$ % &

' (

513#

$ % &

' ( 2 13!

Cn ="µ

#

$ % &

' (

n1s#

$ % &

' ( n)s 1s!

Page 45: Queuing Theory

Queueing Theory-45

M/M/s Queueing System L, Lq, W, Wq

21

10

20

)()!1(

)1(!)/(

!"µµ"

!=

#"

#µ!=

"

+

ssP

sPL

s

s

s

q

!"

#$%

&''(

)**+

,

--

-

-+=>

----

µ./µ.

0µ.µ

µ

/11

)1(!)/(1)(

)/1(0

se

sPetP

stst

How to find L? W? Wq? Use Lq to find Wq (Lq = λWq):

Wq = Lq/λ Use Wq to find W:

W = Wq + 1/µ Use L=λW to find L in terms of Lq:

L = λW = λ(Wq + 1/µ) = λ(Lq/λ + 1/µ) = Lq + λ/µ

tss

nnq ePtP )1(

1

01)( !µ" ##

#

=

$%

&'(

)#=> *

If s – 1 – λ /µ = 0 then this term is (µt)

Page 46: Queuing Theory

Queueing Theory-46

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)

Page 47: Queuing Theory

Queueing Theory-47

M/M/s Example: ER Questions

In steady state, what is the… 1.  probability that both doctors are idle?

probability that exactly one doctor is idle?

2.  probability that there are n patients?

3.  expected number of patients in the ER?

!

P0 =1

#

$ % &

' (

0

0!+

#

$ % &

' (

1

1!+

#

$ % &

' (

2

2!1

1) *

=1

1+23

+49 + 2

12 3

=12

!

P1 =" µ( )1

1!P0 =

2312

=13

!

Pn =

#

$ % &

' (

n

n!P0 =

23#

$ % &

' ( n 1n!

12

if 0 ) n < 2

#

$ % &

' (

n

s!sn*sP0 =

23#

$ % &

' ( n 1

2!12#

$ % &

' ( n*2 1

2=

13#

$ % &

' ( n

if n + 2

,

-

.

.

.

/

.

.

.

!

L = "W = " Lq " +1 µ( ) = Lq + " µ =1 12 + 2 3 = 3 4

Page 48: Queuing Theory

Queueing Theory-48

M/M/s Example: ER Questions

In steady state, what is the… 4.  expected number of patients waiting for a doctor?

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?

!

Lq =P0 " µ( )s#s! 1$ #( )s

=1 2( ) 2 /3( )2 1 3( )2! 2 /3( )2

=112

!

P "q > t( ) = 1# P0 # P1( )e#2µ 1#$( ) t = 1# 12#13

%

& '

(

) * e#2(3) 2 3( )t =

16e#4 t

P "q > 30min( ) = P "q >12hour

%

& '

(

) * + 0.022

Page 49: Queuing Theory

Queueing Theory-49

Performance Measurements

s = 1 s = 2

ρ 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

P(at least two patients waiting in queue)

0.296 0.0185

P(a patient waits more than 30 minutes)

0.404 0.022

Page 50: Queuing Theory

Queueing Theory-50

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

Page 51: Queuing Theory

Queueing Theory-51

P(ω>t) =

P(ωq>t) =

Page 52: Queuing Theory

Queueing Theory-52

P(ω>t) =

P(ωq>t) =

Page 53: Queuing Theory

Queueing Theory-53

P(ω>t) =

P(ωq>t) =

Page 54: Queuing Theory

Queueing Theory-54

Single Queue vs. Multiple Queues •  Would you ever want to keep separate queues for separate

servers?

Single queue

Multiple queues

vs.

Page 55: Queuing Theory

Queueing Theory-55

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 ρ

0.75 0.083 0.375 0.042 0.5 λ/2µ =1/3

1.0 0.334 0.5 0.167 0.4449

λ`/µ =(λ/µ)/3

=1/3

Page 56: Queuing Theory

Queueing Theory-56

Bank Example Continued

•  Suppose we now have 3 tellers •  Again, compare the two models

M/M/3 Three M/M/1 queues λ=2, µ=3 λ’ = λ/3 = 2/3, µ=3 ρ=λ/(sµ) = 2/9 M/M/1: ρ=λ’/3 = 2/9 ρ is the same L= 0.676 L=0.286 3L = 0.858 Lq = 0.009 Lq=0.063 3Lq = 0.189 W = 0.338 W = 0.429 Wq = 0.005 Wq = 0.095 P0 = 0.5122 P0 = 0.7778 (P0)3 = 0.47

Page 57: Queuing Theory

Queueing Theory-57

M/M/s//K Queueing Model (Finite Queue Variation of M/M/s)

•  Now suppose the system has a maximum capacity, K •  We will still consider s servers •  Assuming s ≤ K, the maximum queue capacity is K – s •  Some applications for this model:

Trunk lines for phone – call center Warehouse with limited storage Parking garage

•  Draw the rate diagram for this problem:

0 1

λ λ

µ 2µ

… s-1 s s+1

λ λ λ

sµ sµ sµ

K

0 λ

(s-1)µ

λ

Page 58: Queuing Theory

Queueing Theory-58

M/M/s//K Queueing Model (Finite Queue Variation of M/M/s)

Balance equations: Rate In = Rate Out State 0: µP1 = λP0

State 1: λP0 + 2µP2 = (λ+µ)P1

State 2: λP1 + 3µP3 = (λ+2µ)P2

State 3: λP2 + 3µP4 = (λ+3µ)P3

State K-1: λPK-2 + 3µPK = (λ+3µ)PK-1

State K: λPK-1 = 3µPK

0 1 2 3=s 4

λ λ λ

2µ 3µ 3µ

λ

µ

K

0 λ

… λ

!

C0 =1

C1 ="µ

C2 ="2

2µ2

C3 ="3

3!µ3 (s = 3)

C4 =1

3!#3$

% &

'

( ) "µ

$

% & '

( )

4

!

Cn =1

3!#3 n*s( )

$

% &

'

( ) "µ

$

% & '

( )

n

for s + n + K

CK +1 = 0

P0 =1

Cnn=0

K

!

Pn =CnP0

Page 59: Queuing Theory

Queueing Theory-59

M/M/s//K Queueing Model (Finite Queue Variation of M/M/s)

Solving the balance equations, we get the following steady state probabilities:

Kn

nP

ss

nP

n

P nsn

n

n

n

n

>

+=µ

!

!

="

0

K ..., 1,s s, for!

s ..., 2, 1, for!

0

0

Verify that these equations match those given in the text for the single server case (M/M/1//K)

!

P0 =1

1+ (" /µ )n

n!n=1

s

# + (" /µ )s

s!"sµ( )

n$s

n= s+1

K

#

Page 60: Queuing Theory

Queueing Theory-60

M/M/s//K Queueing Model (Finite Queue Variation of M/M/s)

!!"

#$$%

&'++=

µ(=))')'')')'

)µ(=

**'

=

'

=

''

1

0

1

0

20

1

/ where)],1()(1[)1(!)/(

s

nnq

s

nn

sKsKs

q

PsLnPL

ssKsPL

WL != qq WL != )1(0

Kn

nn PP !"="=" #$

=

To find W and Wq:

Although L ≠ λW and Lq ≠ λWq because λn is not equal for all n,

and where

Also, because there is a finite number of states, the steady state equations do hold, even if ρ>1

Page 61: Queuing Theory

Queueing Theory-61

M/M/s///N Queueing Model (Finite Calling Population Variation of M/M/s)

•  Now suppose the calling population is finite, N •  We will still consider s servers •  Assuming s ≤ N, the maximum number in the queue capacity is

N – s, so K ≥ N does not affect anything If N is the entire population, then the maximum number in system is N. Assume N ≤ K and s ≤ N

•  Application for this model: Machine replacement

•  Draw the rate diagram for this problem:

0 1

Nλ (N-1)λ

µ 2µ

… s s+1

(N-s)λ (N-(s+1))λ

sµ sµ

N

0 (N-(s-1))λ

λ

Page 62: Queuing Theory

Queueing Theory-62

M/M/s///N Queueing Model (Finite Calling Population Variation of M/M/s)

Queueing Theory-62

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

0 1 2 3 4

(N-1)λ (N-2)λ (N-3)λ

2µ 3µ 3µ

µ

N

0 λ

… (N-4)λ

!

C0 =1

C1 = N "µ

#

$ % &

' (

C2 =N N )1( )2

#

$ % &

' (

2

C3 =N N )1( ) N ) 2( )

3!"µ

#

$ % &

' (

3

Page 63: Queuing Theory

Queueing Theory-63

M/M/s///N Results

! !"

= =" #

$%

&'(µ)

"+#

$%

&'(µ)

"

=1

0

0

!)!(!

!)!(!

1s

n

N

sn

n

sn

n

ssnNN

nnNN

P

!!!

"

!!!

#

$

>

%%&&'

())*

+

µ

,

-

=&&'

())*

+

µ

,

-

=-

Nn for0

Nn for!)!(

!

,...,1,0 for!)!(

!

0

0

sPssnN

N

snPnnN

N

Pn

sn

n

n

!=

"=N

snnq PsnL )( !!

"

#$$%

&'++= ((

'

=

'

=

1

0

1

01

s

nnq

s

nn PsLnPL

Page 64: Queuing Theory

Queueing Theory-64

Queueing Models with Nonexponential Distributions

•  M/G/1 Model –  Poisson input process, general service time distribution with mean 1/µ

and variance σ2 –  Assume ρ = λ/µ < 1 –  Results

!"= 10P

µ+=

!=

/1

/

q

qq

WW

LW

q

q

LL

L

+=

!

+=

"

""#$)1(2

222

Notice for M/M/1

!

P0 =1" #

Lq =

$2

µ2 + #2

2 1" #( )=

2#2

2 1" #( )=

#2

1" #

L = # + Lq = # +#2

1" #=

#1" #

Mean service time = 1/µ Variance of service time, σ2 = 1/µ2

Page 65: Queuing Theory

Queueing Theory-65

Queueing Models with Nonexponential Distributions

•  M/Ek/1 Model –  Erlang: Sum of exponentials

–  Think it would be useful? Yes, because service time may be made up of several tasks – each of which has an iid, independent identical exponential distribution, and T = T1 + T2 + T3 + … + TK

If Ti ~ expon(µ) and independent, then T~Erlang(k,µ) –  Can readily apply the formulae on previous slide where –  Also, Erlang k is between exponential and deterministic, and is a

2-parameter family so can get a better fit to more situations As k goes to infinity M/Ek/1 approaches M/D/1

22 1

µ=!k

!

fT (t) =µk( )k

k "1( )!t k"1e"kµt for t # 0

When k=1, get exponential

Erlang k as k --> ∞, approach deterministic

Mean

Standard Deviation

Variance !

!

!

!

!

1kµ

!

1kµ2

!

1µ2

!

" 0

!

" 0

Page 66: Queuing Theory

Queueing Theory-66

Application of Queueing Theory

•  We can use the results for the queueing models when making decisions on design and/or operations

•  Some decisions that we can address –  Number of servers –  Efficiency of the servers –  Number of queues –  Amount of waiting space in the queue –  Queueing disciplines

Page 67: Queuing Theory

Queueing Theory-67

Number of Servers •  Suppose we want to find the number of servers that minimizes the

expected total cost, E[TC] –  Expected Total Cost = Expected Service Cost + Expected Waiting Cost

(E[TC]= E[SC] + E[WC]) •  How do these costs change as the number of servers change?

Number of servers

Exp

ecte

d co

st

E[TC] E[SC] – increases with number of servers

E[WC] – decreases with number of servers

Minimum E[TC] is not necessarily where E[SC] and E[WC] intersect

Page 68: Queuing Theory

Queueing Theory-68

Repair Person Example

•  SimInc has 10 machines that break down frequently and 8 operators •  The time between breakdowns ~ Exponential, mean 20 days •  The time to repair a machine ~ Exponential, mean 2 days •  Currently SimInc employs 1 repair person and is considering hiring

a second •  Costs:

–  Each repair person costs $280/day –  Lost profit due to less than 8 operating machines:

$400/day for each machine that is down •  Objective: Minimize total cost •  Should SimInc hire the additional repair person?

Page 69: Queuing Theory

Queueing Theory-69

Repair Person Example Problem Parameters

•  What type of problem is this? –  M/M/1 –  M/M/s –  M/M/s/K –  M/G/1 –  M/M/s finite calling population

(close, but not exactly – have to draw the rate diagram finite number of machines (10), but maximum of 8 operating at a time)

–  M/Ek/1 –  M/D/1

•  What are the values of λ and µ? Time between breakdowns ~expon. mean = 20 days λ = 1 customer / 20 days for each machine operating Compare 1 and 2 servers time to repair ~expon. mean = 2 days µ = 1 customer / 2 days

Page 70: Queuing Theory

Queueing Theory-70

Repair Person Example Rate Diagrams

•  Draw the rate diagram for the single-server and two-server case

Single server 0 1 2 3 4 …

•  Expected service cost (per day) = E[SC] = 1 server: 280 $/day 2 servers: 2(280) $/day = 560 $/day

•  Expected waiting cost (per day) = E[WC] =

10 9 8

Two servers 0 1 2 3 4 … 10 9 8

8λ 8λ 8λ 7λ 6λ 3λ 2λ λ

µ µ µ µ µ µ µ µ

!

400 1" P3 + 2P4 +!+ 8P10( ) = 400 n # 2( )Pnn= 3

10

$ = g n( )Pn$ where g n( ) =0 if n = 0,1,2

400 n # 2( ) if n = 3,4,…10% & '

µ 2µ 2µ 2µ 2µ 2µ 2µ 2µ

Page 71: Queuing Theory

Queueing Theory-71

Repair Person Example Steady-State Probabilities

•  Write the coefficients for the balance equations for each case Single server 2 servers

•  How to find E[WC] for s=1? s=2? !

C0 =1

C1 = 8 "µ

#

$ % &

' (

C2 = 82 "µ

#

$ % &

' (

2

C3 = 83 "µ

#

$ % &

' (

3

C4 = 83 ) 7 "µ

#

$ % &

' (

4

C5 = 83 ) 7 ) 6 "µ

#

$ % &

' (

5

= 82 ) 8!5!

#

$ % &

' (

5

!

C6 = 82 " 8!4!

$

% & '

( )

6

C7 = 82 " 8!3!

$

% & '

( )

7

C8 = 82 " 8!2!

$

% & '

( )

8

C9 = 82 " 8!1!

$

% & '

( )

9

C10 = 82 " 8!0!

$

% & '

( )

10

!

C0 =1

C1 = 8 "µ

#

$ % &

' (

C2 =82

2"µ

#

$ % &

' (

2

C3 =83

22"µ

#

$ % &

' (

3

C4 =83 ) 723

#

$ % &

' (

4

C5 =82

24)8!5!

#

$ % &

' (

5

!

!

E WC[ ] = 400 n " 2( )Pnn= 3

10

# = g n( )Pnn= 0

10

# where g n( ) =0 if n = 0,1,2

400 n " 2( ) if n = 3,4,…10$ % &

Page 72: Queuing Theory

Queueing Theory-72

Repair Person Example E[WC] Calculations

N=n g(n) s=1 s=2

Pn g(n) Pn Pn g(n) Pn 0 0 0.271 0 0.433 0 1 0 0.217 0 0.346 0 2 0 0.173 0 0.139 0 3 400 0.139 56 0.055 24 4 800 0.097 78 0.019 16 5 1200 0.058 70 0.006 8 6 1600 0.029 46 0.001 0 7 2000 0.012 24 0.0003 0 8 2400 0.003 7 0.00004 0

9 2800 0.0007 0 0.000004 0

10 3200 0.00007 0 0.0000002 0 E[WC] $281/day $48/day

Page 73: Queuing Theory

Queueing Theory-73

Repair Person Example Results

•  We get the following results

s E[SC]: E[WC]: E[TC]: 1 $280/day $281/day $561/day 2 $560/day $48/day $608/day ≥ 3 ≥ $840/day ≥ $0/day ≥ $840/day

•  What should SimInc do? Stay with 1 server Could consider other possibilities to reduce E[TC]; - instead of another server, decrease service time by considering faster equipment or an apprentice - consider a different maintenance policy to decrease arrival rate

* min!

Page 74: Queuing Theory

Queueing Theory-74

Supercomputer Example

•  Emerald University has plans to lease a supercomputer •  They have two options

•  Students and faculty jobs are submitted on average of 20 jobs/day, (λ = 20 jobs /day) distributed Poisson

i.e. Time between submissions ~ 1/20 = 0.05 day = 1.2 hours •  Which computer should Emerald University lease?

Supercomputer Mean number of jobs per day Cost per day

MBI 30 jobs/day $5,000/day

CRAB 25 jobs/day $3,750/day

µMBI = 30 jobs/ day

µCRAB = 25 jobs/ day

Page 75: Queuing Theory

Queueing Theory-75

Supercomputer Example Waiting Cost Function

•  Assume the waiting cost is not linear: h(ω) = 500 ω + 400 ω 2 (ω = waiting time in days)

•  What distribution do the waiting times follow? •  What is the expected waiting cost, E[WC]?

Note: if h(ω) is a linear function, h(ω)=cω, then E[h(ω)] = cE[ω] = cW $/job

and then E[WC] = cWλ = cL $/job job/day $/day

!

for M/M/1 fw (") = µ 1# $( )e#µ 1#$( )"

!

E h "( )[ ] = 500" + 400" 2( )µ 1# $( )e#µ 1#$( )"d"0

%

&

=58 $/job for MBI 132 $/job for CRAB' ( )

E[WC] = E[h(")]* =1160 $/day for MBI 2640 $/day for CRAB' ( )

$/day $/job jobs/day

Page 76: Queuing Theory

Queueing Theory-76

Supercomputer Example Results

•  Next incorporate the leasing cost to determine the expected total cost, E[TC]

•  Which computer should the university lease?

MBI !

E TC[ ] = E SC[ ] + E WC[ ]

E TC[ ] =5000 $/day + 1160 $/day = 6160 $/day for MBI *3750 $/day + 2640 $/day = 6390 $/day for CRAB" # $

Page 77: Queuing Theory

Jackson Networks

Chapter 17.9 Queueing Networks

Page 78: Queuing Theory

Equivalence property

•  Assume that a service facility with s servers and an

infinite queue has a Poisson input with parameter λ and

the same exponential service-time distribution with

parameter µ for each server (the M/M/s model), where

sµ>λ. Then the steady-state output of this service facility

is also a Poisson process with parameter λ.

78

Page 79: Queuing Theory

Infinite queues in series

•  Suppose that customers must all receive service at a series of m service facilities in a fixed sequence. Assume that each facility has an infinite queue, so that the series of facilities form a system of infinite queues in series.

•  The joint probability of n1 customers at facility 1, n2 customers at facility 2, … , then, is the product of the individual probabilities obtained in this simple way.

79

P (N1,N2,...,Nm ) = (n1,n2,...,nm ){ }= Pn1Pn2 ! ! !Pnm

Page 80: Queuing Theory

What is Jackson network ?

•  A Jackson network is a system of m service facilities where facility i (i = 1, 2, … , m ) has 1.  An infinite queue 2.  Customers arriving from outside the system according to a

Poisson input process with parameter ai

3.  si servers with an exponential service-time distribution with parameter µi .

•  A customer leaving facility i is routed next to facility j (j = 1, 2, … , m) with probability pij or departs the system with probability qi where

qi =1! pij

j=1

m

"80

Page 81: Queuing Theory

Jackson network diagram

81

Page 82: Queuing Theory

Key property of Jackson network

•  Any such network has the following key property

–  Under steady-state conditions, each facility j (j = 1, 2, … , m) in a

Jackson network behaves as if it were an independent M/M/sj

queueing system with arrival rate

82

! j = aj + !i piji=1

m

! ,

where sjµ j > ! j.

Page 83: Queuing Theory

Jackson network example

•  To illustrate these calculations, consider a Jackson network with three service facilities that have the parameters shown in the table below.

83

Facility j sj µj aj pij

i = 1 i = 2 i = 3 j = 1 1 10 1 0 0.1 0.4 j = 2 2 10 4 0.6 0 0.4 j = 3 1 10 3 0.3 0.3 0

Page 84: Queuing Theory

Jackson network example diagram

84

Page 85: Queuing Theory

Jackson network example (cont’d)

•  Plugging into the formula for λj for j = 1, 2, 3, we obtain

•  The simultaneous solution for this system is

85

!1 =1 + 0.1!2 + 0.4!3!2 = 4+ 0.6!1 + 0.4!3!3 = 3+ 0.3!1 + 0.3!2

!1 = 5, !2 =10, !3 = 712

Page 86: Queuing Theory

Jackson network Excel template

86

Page 87: Queuing Theory

Jackson network example (cont’d)

•  Given this simultaneous solution for λj, to obtain the distribution of the number of customers Ni = ni at facility i, note that

87

!i ="isiµi

=

12

for i =1

12

for i = 2

34

for i = 3

!

"

###

$

###

Pn2=

13

for n2 = 0

13

for n2 =1

13

12!

"#$

%&n2'1

for n2 ( 2

)

*

++++

,

++++

for facility 2,

Pn1=

12

12!

"#$

%&n1

for facility 1,

Pn3=

14

34!

"#$

%&n3

for facility 3.

Page 88: Queuing Theory

Jackson network example (cont’d)

•  The joint probability of (n1, n2, n3) then is given simply by the product form solution

•  The expected number of customers Li at facility i

•  The expected total number of customers in the system

88

P (N1,N2,N3) = (n1,n2,n3){ }= Pn1Pn2Pn3

L1 =1, L2 =43, L3 = 3

L = L1 + L2 + L3 = 513

Page 89: Queuing Theory

Jackson network example (cont’d)

•  To obtain W, the expected total waiting time in the

system (including service times) for a customer, you

cannot simply add the expected waiting times at the

respective facilities, because a customer does not

necessarily visit each facility exactly once.

•  However, Little’s formula can still be used for the entire

network,

89

W =L

a1 + a2 + a3=23