Introduction To Queuing and Simulation
Introduction To Queuing and Simulation
and Simulation
Chapter 6
Business Process Modeling, Simulation and
Design
1
Overview (I)
• What is queuing/ queuing theory?
– Why is it an important tool?
– Examples of different queuing systems
• Components of a queuing system
• The exponential distribution & queuing
• Stochastic processes
– Some definitions
– The Poisson process
• Terminology and notation
• Little’s formula
• Birth and Death Processes
2
Overview (II)
• Important queuing models with FIFO discipline
– The M/M/1 model
– The M/M/c model
– The M/M/c/K model (limited queuing capacity)
– The M/M/c//N model (limited calling population)
• Priority-discipline queuing models
• Application of Queuing Theory to system
design and decision making
3
Overview (III)
4
What is Queuing Theory?
5
Why is Queuing Analysis Important?
• Capacity problems are very common in industry and one
of the main drivers of process redesign
– Need to balance the cost of increased capacity against the gains of
increased productivity and service
• Queuing and waiting time analysis is particularly
important in service systems
– Large costs of waiting and of lost sales due to waiting
Total
cost
Cost
Cost of
service
Cost of waiting
Process capacity
7
Examples of Real World Queuing Systems?
• Commercial Queuing Systems
– Commercial organizations serving external customers
– Ex. Dentist, bank, ATM, gas stations, plumber, garage …
• Transportation service systems
– Vehicles are customers or servers
– Ex. Vehicles waiting at toll stations and traffic lights, trucks or ships
waiting to be loaded, taxi cabs, fire engines, elevators, buses …
• Business-internal service systems
– Customers receiving service are internal to the organization providing
the service
– Ex. Inspection stations, conveyor belts, computer support …
• Social service systems
– Ex. Judicial process, the ER at a hospital, waiting lists for organ
transplants or student dorm rooms …
8
Components of a Basic Queuing Process
Served
Calling Jobs Service Jobs
Queue Mechanism
Population
leave the
system
Arrival Queue
Process Discipline
Service
Queue
Process
Configuration
9
Components of a Basic Queuing Process (II)
The calling population
– The population from which customers/jobs originate
– The size can be finite or infinite (the latter is most
common)
– Can be homogeneous (only one type of customers/ jobs)
or heterogeneous (several different kinds of
customers/jobs)
The Arrival Process
– Determines how, when and where customer/jobs arrive to
the system
– Important characteristic is the customers’/jobs’ inter-
arrival times
– To correctly specify the arrival process requires data
collection of interarrival times and statistical analysis.
10
Components of a Basic Queuing Process (III)
The queue configuration
– Specifies the number of queues
• Single or multiple lines to a number of service
stations
– Their location
– Their effect on customer behavior
• Balking and reneging
– Their maximum size (# of jobs the queue can hold)
• Distinction between infinite and finite capacity
11
Example – Two Queue Configurations
12
Multiple v.s. Single Customer Queue
Configuration
Multiple Line Advantages Single Line Advantages
13
Components of a Basic Queuing Process (IV)
The Service Mechanism
– Can involve one or several service facilities with one or several
parallel service channels (servers) - Specification is required
– The service provided by a server is characterized by its service time
• Specification is required and typically involves data gathering and
statistical analysis.
• Most analytical queuing models are based on the assumption of
exponentially distributed service times, with some generalizations.
The queue discipline
– Specifies the order by which jobs in the queue are being served.
– Most commonly used principle is FIFO.
– Other rules are, for example, LIFO, SPT, EDD…
– Can entail prioritization based on customer type.
14
Mitigating Effects of Long Queues
1. Concealing the queue from arriving customers
– Ex. Restaurants divert people to the bar or use pagers, amusement parks
require people to buy tickets outside the park, banks broadcast news on
TV at various stations along the queue, casinos snake night club queues
through slot machine areas.
2. Use the customer as a resource
– Ex. Patient filling out medical history form while waiting for physician
3. Making the customer’s wait comfortable and distracting their
attention
– Ex. Complementary drinks at restaurants, computer games, internet
stations, food courts, shops, etc. at airports
4. Explain reason for the wait
5. Provide pessimistic estimates of the remaining wait time
– Wait seems shorter if a time estimate is given.
6. Be fair and open about the queuing disciplines used 15
A Commonly Seen Queuing Model (I)
C S = Server
The Queue C S
Customers (C)
CCC…C •
•
•
Customer =C C S
16
A Commonly Seen Queuing Model (II)
• Service times as well as interarrival times are assumed
independent and identically distributed
– If not otherwise specified
• Commonly used notation principle: A/B/C
– A = The interarrival time distribution
– B = The service time distribution
– C = The number of parallel servers
• Commonly used distributions
– M = Markovian (exponential) - Memoryless
– D = Deterministic distribution
– G = General distribution
• Example: M/M/c
– Queuing system with exponentially distributed service and inter-arrival
times and c servers
17
The Exponential Distribution and Queuing
fT(t)
Probability density
t
Mean=
Time between arrivals
E[T]=1/
19
Properties of the Exp-distribution (I)
Implications
– Many realizations of T (i.e.,values of t) will be small; between
zero and the mean
– Not suitable for describing the service time of standardized
operations when all times should be centered around the mean
• Ex. Machine processing time in manufacturing
– Often reasonable in service situations when different customers
require different types of service
– Often a reasonable description of the time between customer
arrivals
20
Properties of the Exp-distribution (II)
Implications
– It does not matter when the last customer arrived, (or how long
service time the last job required) the distribution of the time until
the next one arrives (or the distribution of the next service time)
is always the same.
– Usually a fair assumption for interarrival times
– For service times, this can be more questionable. However, it is
definitely reasonable if different customers/jobs require different
service
21
Properties of the Exp-distribution (III)
Property 3: The minimum of independent exponentially
distributed random variables is exponentially distributed
Assume that {T1, T2, …, Tn} represent n independent and
exponentially distributed stochastic variables with
parameters {1, 2, …, n}.
n
Let U=min {T1, T2, …, Tn} U exp( i )
i 1
Implications
– Arrivals with exponentially distributed interarrival times from n
different input sources with arrival intensities {1, 2, …, n} can be
treated as a homogeneous process with exponentially distributed
interarrival times of intensity = 1+ 2+…+ n.
– Service facilities with n occupied servers in parallel and service
intensities {1, 2, …, n}can be treated as one server with service
intensity = 1+2+…+n
22
Properties of the Exp-distribution (IV)
(t ) n e nt
P( X( t ) n ) for n 0, 1, ...
n!
23
Stochastic Processes in Continuous Time
25
Properties of the Poisson Process
26
Illustration – Disaggregating a
Poisson Process
X1 (t ) Po(p1t ) Po( 1t )
p1
pN
X N (t ) Po(p N t ) Po( N t )
27
Terminology and Notation
The state of the system = the number of customers in the system
Queue length = (The state of the system) – (number of customers
being served)
Capacity Demand
Available Capacity c *
29
Queuing Theory Focus on Steady State
• Steady State condition
– Enough time has passed for the system state to be independent of the
initial state as well as the elapsed time
– The probability distribution of the state of the system remains the same
over time (is stationary).
• Transient condition
– Prevalent when a queuing system has recently begun operations
– The state of the system is greatly affected by the initial state and by the
time elapsed since operations started
– The probability distribution of the state of the system changes with time
30
Transient condition Steady State condition
25
N(t)
Number of jobs in the system,
20
15 E[N(t)]
N(t)
10
0
0 5 10 15 20 25 30 35 40 45 50
time, t
31
Notation For Steady State Analysis
32
Little’s Formula Revisited
L W Lq Wq
L W Lq Wq
33
Birth-and-Death Processes
Assumptions
1. Given N(t)=n,
The time until the next birth (TB) is exponentially distributed with
parameter n (Customers arrive according to a Po-process)
The remaining service time (TD) is exponentially distributed with
parameter n
2. TB & TD are mutually independent stochastic variables and
state transitions occur through exactly one Birth (n n+1)
or one Death (n n–1)
34
A Birth-and-Death Process Rate Diagram
0 1 n-1 n
0 1 2 n-1 n n+1
1 2 n n+1
35
Steady State Analysis of B-D Processes (I)
36
Steady State Analysis of B-D Processes (II)
P0 1 Ci Pn C n P0
i 0
L i Pi Lq (i c) Pi
i 0 i c
38
The M/M/1 - model
0 1 2 n-1 n n+1
2 (c-2) (c-1) c c
1
c1 ( / ) n ( / ) c 1
P0
n ! c ! 1 ( /( c )
n 0
Steady State
Condition:
( / ) n
P0 for n 1,2, , c
n! =(/c)<1
Pn
n
( / ) P for n c 1, c 2,
c!c n c 0
41
The M/M/c Model (II)
( / ) c
Lq ( n c) Pn ... P
2 0
n c c!(1 )
W=Wq+(1/)
42
Example – ER at County Hospital
Situation
– Patients arrive according to a Poisson process with intensity
( the time between arrivals is exp() distributed.
– The service time (the doctor’s examination and treatment time of
a patient) follows an exponential distribution with mean 1/
(=exp() distributed)
The ER can be modeled as an M/M/c system where c=the
number of doctors
Data gathering
= 2 patients per hour
= 3 patients per hour
Questions
– Should the capacity be increased from 1 to 2 doctors?
– How are the characteristics of the system (, Wq, W, Lq and L)
affected by an increase in service capacity?
43
Summary of Results – County Hospital
• Interpretation
– To be in the queue = to be in the waiting room
– To be in the system = to be in the ER (waiting or under treatment)
45
The M/M/c/K – Model (II)
for n 0,1,2, , K 1
n
0 for n K
Observation
The M/M/c/K model always has a steady state
solution since the queue can never “explode”
46
The M/M/c/K – Model (III)
0 1 2 c-1 c K-1 K
2 3 (c-1) c c c
1 n 1 n
P0 Pn P0
1 K 1 1 K 1
( K 1) K 1
L Lq L (1 P0 )
1 1 K 1
W L/
Where n Pn
n 0
Wq L q /
48
The M/M/c//N – Model (I)
• An M/M/c model with limited calling population, i.e., N
clients
• A common application: Machine maintenance
– c service technicians is responsible for keeping N service stations
(machines) running, that is, to repair them as soon as they break
– Customer/job arrivals = machine breakdowns
– Note, the maximum number of clients in the system = N
• Assume that (N-n) machines are operating and the time until
breakdown for each machine i, Ti, is exponentially distributed
(Tiexp()). If U = the time until the next breakdown
U = Min{T1, T2, …, TN-n} Uexp((N-n))).
49
The M/M/c//N – Model (II)
• The State Diagram (c service technicians and N machines)
= Arrival intensity per operating machine
= The service intensity for a service technician
N (N-1) (N-(c-1))
0 1 2 c-1 c N-1 N
2 3 (c-1) c c
50
Priority-Discipline Queuing Models
• For situations where different customers have different priorities
– For example, ER operations, VIP customers at nightclubs…
• Assuming a situation with N priority classes (where class 1 has
the highest priority) there are two fundamental priority
principles to consider.
1. Non-Preemptive priorities
A customer being served cannot be ejected back into the queue to
leave place for a customer with higher priority
2. Preemptive priorities
A customer of lower priority that is being served will be thrown
back into the queue to leave room for a higher priority customer
• Assuming that all customers experience independent exp()
service times and arrive according to Poisson processes both
models can be analyzed as special case M/M/c models
51
Queuing Modeling and System Design (I)
• Examples:
– The number of doctors in a hospital,
– The number of exits and cashiers in a supermarket,
– The choice of machine type at a new investment decision,
– The localization of toilets in a new building, etc…
52
Queuing Modeling and System Design (II)
• Two fundamental questions when designing (queuing)
systems
– Which service level should we aim for?
– How much capacity should we acquire?
• The cost of increased capacity must be balanced against the
cost reduction due to shorter waiting time
Specify a waiting cost or a shortage cost accruing when customers
have to wait for service or…
… Specify an acceptable service level and minimize the capacity
under this condition
• The shortage or waiting cost rate is situation dependent and
often difficult to quantify
– Should reflect the monetary impact a delay has on the
organization where the queuing system resides
53
Different Shortage Cost Situations
54
Analyzing Design-Cost Tradeoffs
• Given a specified shortage or waiting cost function the analysis
is straightforward
• Define
– WC = Expected Waiting Cost (shortage cost) per time unit
– SC = Expected Service Cost (capacity cost) per time unit
– TC = Expected Total system cost per time unit
• The objective is to minimize the total expected system cost
TC
Cost
Min TC = WC + SC
SC
WC
Process capacity
55
Analyzing Linear Waiting Costs
• Expected Waiting Costs as a function of the number of
customers in the system
– Cw = Waiting cost per customer and time unit
– CwN = Waiting cost per time unit when N customers in the system
WC C w nPn C w L
n 0
WC C w Lq
56
Analyzing Service Costs
The expected service costs per time unit, SC, depend on the
number of servers and their speed
• Definitions
– c = Number of servers
= Average server intensity (average time to serve one customer)
– CS() = Expected cost per server and time unit as a function of
SC = c*CS()
57
A Decision Model for System Design
Determining and c
• Both the number of servers and their speed can be varied
– Usually only a few alternatives are available
• Definitions
– A = The set of available - options
Min TC c Cs () WC
A,c 0,1,...
• Optimization
– Enumerate all interesting combinations of and c, compute TC and
choose the cheapest alternative
60
Simulation – Why use it?
61
Simulation v.s. Symbolic & Analytical Tools
Strengths
+ Provides a quantitative measure
+ Flexible – can handle any kind of complex system or statistical
interdependencies
+ Capable of finding inefficiencies otherwise not detected until the
system is in operation
Weaknesses
– Can take a long time to build
Usually requires a substantial amount of data gathering
– Easy to misrepresent reality and draw faulty conclusions
– Generally not suitable for optimizing system parameters
• Graphical interfaces
Achieves the descriptive benefits of
symbolic tools like flow charts
• Optimization Engines
Enables efficient automated search
for best parameter values
63
Building a Simulation Model
• General Principles
– The system is broken down into suitable components or entities
– The entities are modeled separately and are then connected to a
model describing the overall system
A bottom-up approach!
• The basic principles apply to all types of simulation models
– Static or Dynamic
– Deterministic or Stochastic
– Discrete or continuous
• In BPD and OM situations computer based Stochastic
Discrete Event Simulation (e.g. in Extend) is the natural
choice
– Focuses on events affecting the state of the system and skips all
intervals in between
64
Steps in a BPD Simulation Project
1. Problem formulation Phase 1
Problem Definition
2. Set objectives and overall project plan
4. Data Collection
Phase 2
3. Model conceptualization
Model Building
5. Model Translation
No Phase 3
6. Verified
Yes Experimentation
No No
7. Validated
Yes
8. Experimental Design
Phase 4
Implementation
9. Model runs and analysis
• Verification (efficiency)
– Is the model correctly built/programmed?
– Is it doing what it is intended to do?
• Validation (effectiveness)
– Is the right model built?
– Does the model adequately describe the reality you want to
model?
– Does the involved decision makers trust the model?
66
Model Verification Methods
Conceptual Model
Calibration and 1. Assumptions on system components
Validation 2. Structural assumptions which define the
interactions between system components
3. Input parameters and data assumptions
Model
verification
Operational Model
(Computerized representation)
68
Example – Simulation of a M/M/1 Queue
• Assume a small branch office of a local bank with only
one teller.
• Empirical data gathering indicates that inter-arrival and
service times are exponentially distributed.
– The average arrival rate = = 5 customers per hour
– The average service rate = = 6 customers per hour
• Using our knowledge of queuing theory we obtain
= the server utilization = 5/6 0.83
– Lq = the average number of people waiting in line
– Wq = the average time spent waiting in line