Simulation 1
Simulation 1
1
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
What is Queuing Theory?
▪ Queues arise when the short-term demand for service exceeds the capacity
• Most often caused by random variation in service times and the times between customer
arrivals.
• If long term demand for service > capacity → the queue will explode!
2
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
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 for service systems
• Large costs of waiting and of lost sales due to waiting
▪ Prototype Example – ER at Hospital
• Patients arrive by ambulance or by their own vehicle
• One doctor is always on duty
• More and more patients seeks help → longer waiting times
Question: Should another MD position be instated?
3
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
A Cost/Capacity Tradeoff Model
Total
cost
Cost
Cost of
service
Cost of waiting
Process capacity
4
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
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…
5
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Components of a Basic Queuing Process
Input Source The Queuing System
Served
Calling Jobs Service Jobs
Queue Mechanism
Population
leave the
system
Arrival Queue
Process Discipline
Service
Queue
Process
Configuration
6
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Components of a Basic Queuing Process
(1)
▪ 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.
7
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Components of a Basic Queuing Process
(2)
▪ The queue configuration
• Specifies the number of queues
o Single or multiple lines to a number of service stations
• Their location
• Their effect on customer behavior
o Balking and reneging
• Their maximum size (# of jobs the queue can hold)
o Distinction between infinite and finite capacity
8
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Example – Two Queue Configurations
Multiple Queues Single Queue
Servers Servers
9
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Multiple vs. Single Customer Queue
Configuration
▪ Multiple Line Advantages
• The service provided can be differentiated
o Ex. Supermarket express lanes
• Labor specialization possible
• Customer has more flexibility
• Balking behavior may be deterred
o Several medium-length lines are less intimidating than one very long line
10
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Multiple vs. Single Customer Queue
Configuration (cont.)
▪ Single Line Advantages
• Guarantees fairness
o FIFO applied to all arrivals
• No customer anxiety regarding choice of queue
• Avoids “cutting in” problems
• The most efficient set up for minimizing time in the queue
• Jockeying (line switching) is avoided
11
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Mitigating Effects of Long Queues
▪ Concealing the queue from arriving customers
• Ex. Amusement parks require people to buy tickets outside the park
▪ Use the customer as a resource
• Ex. Patient filling out medical history form while waiting for physician
▪ 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
▪ Explain reason for the wait
▪ Provide estimates of the remaining wait time
• Wait seems shorter if a time estimate is given.
▪ Be fair and open about the queuing disciplines used
12
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Components of a Basic Queuing Process
(3)
▪ The queue discipline
• Specifies the order by which jobs in the
queue are being served.
• The most commonly used principle is FIFO.
• Other rules are, for example, LIFO, SPT, EDD…
• Can entail prioritization based on customer
type.
13
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Components of a Basic Queuing Process
(4)
▪ 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
o Specification is required and typically involves data gathering
and statistical analysis.
o Most analytical queuing models are based on the assumption
of exponentially distributed service times, with some
generalizations.
14
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
A Commonly Seen Queuing Model
The Queuing System
The Service Facility
C S = Server
C S
The Queue
•
Customers (C)
CCC…C •
•
C S
Customer =C
15
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
A Commonly Seen Queuing System
▪ Service times as well as interarrival times are assumed independent and identically distributed
• If not otherwise specified
▪ Common assumptions:
• c servers with a single queue with FIFO ordering
• A1, A2, …, An are IID random variables (interarrival times)
o l is the arrival rate
• S1, S2, …, Sn are IID random variables (service times)
o m is the service rate
• A’s and S’s are independent
• r = l/cm is the utilization
16
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
A Commonly Seen Queuing System (cont.)
▪ Commonly used notation principle: A/B/c/k (Kendall’s notation)
• A = The interarrival time distribution
• B = The service time distribution
• c = The number of parallel servers
• k = The capacity of queue
▪ Commonly used distributions
• M = Markovian (exponential) - Memoryless
• D = Deterministic distribution
• G = General distribution
▪ Commonly used Queueing system notation:
• M/M/1
• M/M/c
• M/G/c
• GI/G/c
▪ Example: M/M/c
• Queuing system with exponentially distributed service and inter-arrival times and c servers
17
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
A Single-Server Queueing System
Registration
Arriving Reg. Desk Departing
patients patients
Interarrival times, service
times random (need to specify
Patient being probability distributions)
Queue registered
19
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Urgent-Care Clinic
▪ Some questions:
• How many staff of which type during which time periods?
• How big should the waiting room(s) be?
• What would be the effect on patient waits if doctors and nurses tended to decrease or increase the time they spend with
patients?
• What if 10% more patients arrived (arrival rate increased by 10%)?
• Should we serve patients in order of their acuity, or just first-in-first-out (FIFO)?
20
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Why Study Queueing Theory with
Simulation?
▪ Terminology, logic similar to many simulation models
▪ In some cases, can derive exact closed-form formulas for output performance metrics, use to
verify (debug) simulation models:
• Have simulation model of complex system that does not meet queueing-theory assumptions … but it
would if we made some (over-)simplifying extra assumptions like exponential distributions for inter-
arrival and service times
• Modify the simulation model so that it meets these extra assumptions, run it for a very long time …
queueing-theoretic results are typically available only for steady state (a.k.a. long run, infinite horizon)
• Compare simulation output with queueing-theoretic results … if they (approximately) agree, then
confidence in the simulation is improved.
• Restore your simulation model back the way it should be!
21
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing-System Structure and
Terminology
▪ Entities (like customers, patients, jobs) arrive, get served either at a single station or at several stations, may
wait in queue(s), and may leave the system (if they do, it’s an open system, otherwise if they never leave it’s
closed)
▪ Queueing network could consist of several separate queueing stations, each of which is a single- or multiple-
server queue
• If multiple server, usually assume that a single queue “feeds” all the parallel servers, and that the servers are identical in-
service speeds:
▪ Queue disciplines – when an entity can leave the queue and start service, which entity gets to be the next one
to be served?
• First-in, first-out (FIFO), a.k.a. first-come, first-served (FCFS)
• Last-in, first-out (LIFO) – a “stack” of physical or logical objects
• Priority – Shortest Job First (SJF); or Maximum Value First (MVF)
22
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing-System Performance Metrics
▪ (Wq) Time in queue (excluding service time); if in a network, either overall (added up for all
queueing waits) or at individual stations
▪ (W) Time in system, including time in queue plus service time (again over the network or at a
node)
▪ (Lq) Number of entities in queue (a.k.a. queue length), not including any entities in service
(again, over the network or at a node)
▪ (L) Number of entities in system, including in queue plus in service (over network or at a node)
▪ (ρ) Utilization of a server, or of a group of parallel identical servers, the time-average number of
individual servers in the group who are busy
23
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Example Single-server Queueing System
Registration
Reg. Desk Departing
Arriving
patients patients
Queue
Patient being
registered
24
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Patient Arrival/Registration Time Data
Patient Arrival Time IAT ST
1 0 0 2
2 3 3 5
3 4 1 2
4 7 3 3
5 14 7 2
6 16 2 7
7 19 3 3
8 26 7 2
9 35 9 1
10 38 3 7
25
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
M/M/c Queuing Formulae
M / M /1 M /M /c
Lq = lWq
−1
(cr )c c −1
(cr )
n
p( 0) 1− r +
c! (1 − r ) = n!
L = lW
n 0
r2 r (cr ) p( 0)
c
Lq
1− r c! (1 − r )
2
Conservation equations
r l little's law
L Lq +
1− r m
Wq
r (cr )c p(0)
m (1 − r ) c! cm (1 − r )
2
Askin, R. G. and C. R. Standridge,
Modeling and Analysis of
1 1 Manufacturing Systems, John Wiley &
W wq +
m (1 − r ) m Sons, New York, NY, 1993.
28
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Networks
▪ Consist of nodes, each of which is a G/G/c station, connected by arcs representing possible entity travel between nodes
• Can also have entity arrivals from outside the network, and entities can exit from any node to outside the system
▪ When an entity leaves a node, it can go out on any of the arcs emanating from that node, with arc probabilities summing to 1
▪ Assume:
• All arrival processes from outside have
exponential interarrival times (a.k.a.
Poisson processes), and are independent
of each other
• All service times are independent
Called a Jackson network
exponential (so each node is an M/M/c) with these assumptions;
• All queue capacities are infinite much is known about it
• Utilization (a.k.a. traffic intensity) r
locally at each node is < 1
30
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Networks
31
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Networks (cont.)
▪ Use all of this to analyze each node in a Jackson network as a stand-alone M/M/c queue, using
formulae given earlier
• Just have to compute Poisson arrival input/output rates using decomposition, superposition of Poisson
processes
• Let lSignIn be the (Poisson) arrival rate into the Sign In station, assume exponential service times throughout:
32
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Network Example 1
33
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Network Example 2
34
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Network Example 2
35
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
Queueing Theory vs. Simulation
▪ Queueing-theoretic results have the advantage of being exact, i.e., no statistical uncertainty/variation
• Simulation results have statistical uncertainty/variation, which needs to be acknowledged and appropriately addressed
▪ But queueing theory has its own shortcomings:
• Strong assumptions that may be unrealistic, like exponential service times (mode = 0?), making model validity questionable
• Nearly always only for steady-state long-run behavior, so don’t address what happens in the short run
• Not available for all inter-arrival/service distributions, or (more importantly) for complex systems (Jackson network is
simple, restrictive)
▪ Despite output uncertainty, simulation has major advantages:
• No restrictions on input distributions, model form, or complexity … so model validity is facilitated
• Can address short-term time frames … in fact, steady-state is harder for simulation (long runs, initialization bias) than for
queueing theory
• Just have to be mindful of proper statistical design/analysis
36
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA
In Class Assignment
M / M /1 M /M /c
Station
−1
(cr )c c −1
(cr )n
A B C D E p( 0) 1− r +
System Type M/M/1 M/M/___ M/M/___ M/M/___ M/M/___ c! (1 − r ) n = 0 n!
r2 r (cr ) p( 0)
c
r Lq
1− r c! (1 − r )
2
l
r l
Wq L Lq +
1− r m
Lq r (cr )c p(0)
Wq
W m (1 − r ) c! cm (1 − r )
2
L 1 1
W wq +
m (1 − r ) m
37
COLLEGE OF ENGINEERING – INDUSTRIAL ENGINEERING PROGRAM TU.EDU.SA