Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Simulation Examples: Simulation of Queuing Systems

SIMULATION EXAMPLES
Simulation of Queuing Systems

This lecture presents several examples of simulation that can be performed by devising
a simulation table either manually or with a spreadsheet. The simulation table provides a
systematic method for tracking system state over time.
Methodology of discrete-system simulation
1. Determine the characteristics of each of the inputs to the simulation.
These are often modeled as probability distributions, either continuous or
discrete.
2. Construct a simulation table.
Each simulation table is different, for each is developed for the problem at hand.
For each repetition or trial there are a set of inputs and one response.
3. For each repetition i, generate a value for each of the p inputs, and evaluate the
function, calculating a value of the response yi.
The input values may be computed by sampling values from the distributions
chosen in step 1.
A response typically depends on the inputs and one or more previous responses.

Table: Simulation Table

There are a series of problems in the chapter involving queuing (single-server and two-
server), inventory, reliability, and network analysis.
The inventory example has a closed-form (mathematical) solution to compare to the simulation
solution.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
1
Simulation Examples: Simulation of Queuing Systems

What is a queuing problem?


A queue occurs when there are more customers than employees to serve them. This
means that customers have to wait for their turn. Whether the waiting itself is an issue or
not can only be determined by the customers.
In 1985, an American writer and expert on business management named David
Maister published a seminal paper titled the Psychology of Waiting Lines. Here he
outlines a simple formula to measure customer satisfaction.
S=P–E
• S = satisfaction
• P = perception of the service level
• E = expectation of the service level
Satisfied customers
If the customer's perception of a service level is equal to or higher than their expectation
of that service level, they are satisfied.
Dissatisfied customers
If the customer's perception of a service level is lower than their expectation of that
service level, they are dissatisfied.

Defining the queuing problem


As the perceived service level are strongly correlated to the waiting experience, my
definition of the queuing problem is:
A queuing problem occurs when the number of dissatisfied customers is higher than the
number of satisfied customers due to the perceived waiting experience.
Therefore, organizations can overcome the queuing problem by improving the waiting
experience.

How to improve the waiting experience


The fundamental solution to the queue problem is to improve the waiting experience.
Here are three examples of how to do it.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
2
Simulation Examples: Simulation of Queuing Systems

Keep the customer entertained: Relevant distractions can improve the customer's
waiting experience. By placing entertainment media in the waiting area such as a TV,
music or games, you can transform passive waiting into an active waiting.
Ensure that the customer is informed: Make it easy for the customers to know where
to go, where to wait, and how long the expected waiting times are. Use monitors and
digital screens to provide this information.
Take the opportunity to enlighten the customer: When customers are waiting, there
is an excellent opportunity for you to advertise your products or services on monitors
and digital screens. By enlightening the customer on your offering, he or she is likely to
be more receptive to cross-sell and up-sell.

Elements/parameters of Queuing Systems


Figure 1 shows the elements of a single queue queuing system:

1. Population of Customers (Calling Population)


It can be considered either limited (closed systems) or unlimited (open systems).
Unlimited population represents a theoretical model of systems with a large number
of possible customers (a bank on a busy street, a motorway petrol station). Example
of a limited population may be a number of processes to be run (served) by a
computer or a certain number of machines to be repaired by a service man. It is
necessary to take the term "customer" very generally. Customers may be people,
machines of various nature, computer processes, telephone calls, etc.
2. Nature of Arrival
It defines the way customers enter the system. Mostly the arrivals are random with
random intervals between two adjacent arrivals. Typically, the arrival is described by
a random distribution of intervals also called Arrival Pattern.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
3
Simulation Examples: Simulation of Queuing Systems

3. Queue
It represents a certain number of customers waiting for service (of course the queue
may be empty). Typically, the customer being served is considered not to be in the
queue. Sometimes the customers form a queue literally (people waiting in a line for a
bank teller). Sometimes the queue is an abstraction (planes waiting for a runway to
land). There are two important properties of a queue: Maximum Size and Queuing
Discipline.

3.1 Maximum Queue Size (also called System capacity)


It is the maximum number of customers that may wait in the queue (plus the one(s)
being served). Queue is always limited, but some theoretical models assume an
unlimited queue length. If the queue length is limited, some customers are forced to
renounce without being served.

3.2 Queuing Discipline


It represents the way the queue is organized (rules of inserting and removing
customers to/from the queue). There are these ways:
1) FIFO (First in First Out) also called FCFS (First Come First Serve) - orderly queue.
2) LIFO (Last in First Out) also called LCFS (Last Come First Serve) - stack.
3) SIRO (Serve in Random Order).
4) Priority Queue, that may be viewed as a number of queues for various priorities.
5) Many other more complex queuing methods that typically change the customer’s
position in the queue according to the time spent already in the queue, expected
service duration, and/or priority. These methods are typical for computer multi-
access systems.
Most quantitative parameters (like average queue length, average time spent in the
system) do not depend on the queuing discipline. That’s why most models either do
not take the queuing discipline into account at all or assume the normal FIFO queue.
In fact, the only parameter that depends on the queuing discipline is the variance (or
standard deviation) of the waiting time. There is this important rule (that may be
used for example to verify results of a simulation experiment):

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
4
Simulation Examples: Simulation of Queuing Systems

The two extreme values of the waiting time variance are for the FIFO queue
(minimum) and the LIFO queue (maximum).
Theoretical models (without priorities) assume only one queue. This is not
considered as a limiting factor because practical systems with more queues (bank
with several tellers with separate queues) may be viewed as a system with one
queue, because the customers always select the shortest queue. Of course, it is
assumed that the customers leave after being served. Systems with more queues (and
more servers) where the customers may be served more times are called Queuing
Networks.

4. Service Mechanism
It represents some activity that takes time and that the customers are waiting for.
Again, take it very generally. It may be a real service carried on persons or machines,
but it may be a CPU time slice, connection created for a telephone call, being shot
down for an enemy plane, etc. Typically, a service takes random time. Theoretical
models are based on random distribution of service duration also called Service
Pattern. Another important parameter is the number of servers. Systems with one
server only are called Single Channel Systems, systems with more servers are
called Multi Channel Systems.

5. Output represents the way customers leave the system. Output is mostly ignored by
theoretical models, but sometimes the customers leaving the server enter the queue
again ("round robin" time-sharing systems).

What is the objective of queuing system?


The primary objective of the queuing system is to meet the demand for service at
minimum cost.

Types of queuing systems


1. Single Channel Systems
2. Multi-Channel Systems.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
5
Simulation Examples: Simulation of Queuing Systems

How to run a simulation?


1. Manually- using simulation table
2. Through computer- using a simulator or a language

Queueing systems require the concepts of system state, events, and simulation
clock
1. The state of the system is the number of units in the system and the status of the
server, busy or idle.
2. An event is a set of circumstances that causes an instantaneous change in the state
of the system.

In a single-channel queueing system there are only two possible events that affect
the state of the system. They are as follows

i. the entry of a unit into the system (arrival event) and


ii. the completion of service on a unit (the departure event).

The queueing system includes the server, the unit being serviced (if there is one), and
the units in the queue (if any).

3. The simulation clock is used to track simulated time.

Figure 2: Simple queuing system

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
6
Simulation Examples: Simulation of Queuing Systems

Some popular examples of queuing systems:

Why simulation clock is used?

The simulation clock is used to track simulated time. It also calculates arrival time,
departure time and awaiting time.

What is interarrival time?

It is the time between two successive arrival in a queueing system. That means the time
between when one customer arrives at a queue and when the next customer arrives.

What’s the Difference Between Arrival Rates and Inter Arrival Times?

• The arrival rate is the number of arrivals per unit of time.


• The inter arrival time is the time between each arrival into the system and the
next.

The arrival rate is calculated from the following equation;

arrival rate = 1/inter arrival time

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
7
Simulation Examples: Simulation of Queuing Systems

The neat trick with this equation is that if you invert the arrival rate your answer is the
inter arrival time which can then be used in your simulation.

Inter arrival time = 1/arrival rate

For example;

If 12 customers enter a store per hour, the time between each arrival is;

inter arrival time = 1/arrival rate

= 1/12

= 0.083(hours)

= 0.083 x 60 minutes

= 5 (minutes)

Therefore, from the arrival rate of 12 per hour, the time between each arrival is 5 minutes.

What happens if a unit has just completed in a queuing system?


If a unit has just competed service, the simulation proceeds in the manner shown below
in the flow diagram

Figure 3: Service just completed flow diagram

What happens when the arrival event is occurred? Or What happens when a unit
enters the system?

The arrival event occurs when a unit enters the system. The flow diagram
for the arrival event is shown in Figure 4. The unit may find the server either
idle or busy; therefore, either the unit begins service immediately, or it enters the
queue for the server. The unit follows the course of action shown in Figure 5.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
8
Simulation Examples: Simulation of Queuing Systems

Figure 4: Unit-entering-system flow diagram.


If the server is busy, the unit enters the queue. If the server is idle and the
queue is empty, the unit begins service. It is not possible for the server to be
idle and the queue to be nonempty.

Figure 5: Potential unit actions upon arrival.


What will be the server’s state after the completion of a service in queuing system?
After the completion of a service in queuing system the server may become idle or remain
busy with the next unit. The relationship of these two outcomes to the status of the queue
is shown in Figure 5. If the queue is not empty, another unit will enter the server and it
will be busy. If the queue is empty, the server will be idle after a service is completed.
These two possibilities are shown as the shaded portions of Figure 6. It is impossible for
the server to become busy if the queue is empty when a service is completed. Similarly, it
is impossible for the server to be idle after a service is completed when the queue is not
empty.

Figure 6: Server outcomes after service completion.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
9
Simulation Examples: Simulation of Queuing Systems

What is required for determining what happens next in the queuing systems? Or
How uncertainty in real life is imitated?

Simulations of queueing systems generally require the maintenance of an event list for
determining what happens next. The event list tracks the future times at which the
different types of events occur. Simulation clock times for arrivals and departures are
computed in a simulation table customized for each problem.

In simulation, events usually occur at random times, the randomness imitating


uncertainty in real life.

Why random numbers are needed in the queuing systems and how can it generate?

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
10
Simulation Examples: Simulation of Queuing Systems

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
11
Simulation Examples: Simulation of Queuing Systems

Simulation Example ((Single-Channel Queue)


1. A Grocery Store for 6 Customers
A small corner shop has only one checkout counter. Customers arrive at this counter at
random from one to eight minutes apart. Each possible value of inter-arrival time has the
same probability of occurrence. The service times vary from 1 to 6 minutes with the
probabilities given below. Analyze the system by simulating the arrival of 6 customers
and answer the following questions:
Service time Probability
1 0.10
2 0.20
3 0.30
4 0.25
5 0.10
6 0.05
1. The average waiting time for a customer
2. The probability that a customer has to wait in a queue
3. The fraction of the idle time of a server
4. The average service time
5. The average time between arrivals
6. The average waiting time for those who are waiting
7. The average waiting time a customer spends in the system
Use the following sequence of random numbers
For arrivals 913 727 15 948 309 922
For service
84 10 74 53 17 79
time

Assume that the first customer arrives at time “zero”


1) Arrival time and random digits assignment and the service time and random
digits assignment
Cumulative Random digits
Inter-arrival time probability
probability assignment
1 0.125 0.125 0 - 125
2 0.125 0.250 126 - 250
3 0.125 0.375 251 - 375
4 0.125 0.500 376 - 500

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
12
Simulation Examples: Simulation of Queuing Systems

5 0.125 0.625 501 - 625


6 0.125 0.750 626 - 750
7 0.125 0.875 751 - 875
8 0.125 1.00 876 - 1000

The service time and random digits assignment


Cumulative Random digits
Service time Probability
probability assignment
1 0.10 0.10 0 - 10
2 0.20 0.30 11 - 30
3 0.30 0.60 31 - 60
4 0.25 0.85 61 - 85
5 0.10 0.95 86 - 95
6 0.05 1.00 96 - 100

2) Determining the time between arrivals


customer Random Number Time between arrivals (interarrival time)
1 - -
2 913 8
3 727 6
4 15 1
5 948 8
6 309 3

Determining the service time


customer Random Number Service time
1 84 4
2 10 1
3 74 4
4 53 3
5 17 2
6 79 4

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
13
Simulation Examples: Simulation of Queuing Systems

Data sheet
Time
Inter Service Service Idle
Customer Arrival Service Waiting spent
arrival time time time of
list time time time in
time begin end server
system
1 - 0 4 0 0 4 4 0
2 8 8 1 8 0 9 1 4
3 6 14 4 14 0 18 4 5
4 1 15 3 18 3 21 6 0
5 8 23 2 23 0 25 2 2
6 3 26 4 26 0 30 4 1

2. A Grocery Store for 20 Customers


A small corner shop has only one checkout counter. Customers arrive at this counter at
random from one to eight minutes apart. Each possible value of inter-arrival time has the
same probability of occurrence. The service times vary from 1 to 6 minutes with the
probabilities given below. Analyze the system by simulating the arrival of 20 customers.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
14
Simulation Examples: Simulation of Queuing Systems

▪ A column of random digit is developed to generate random numbers (Random


Number Table will be given)
▪ It is necessary to list only 19 random numbers to generate times between arrivals.
Why only 19 numbers? The first arrival is assumed to occur at time 0, so only 19
more arrivals need to be generated to end up with 20 customers.
▪ In Table Distribution of Time Arrival, the first random-digit assignment is 001–
125. There are 1000 three-digit values possible (001 through 000). The probability
of a time-between-arrivals of 1 minute is 0.125, and 125 of the 1000 random-digit
values are assigned to such an occurrence. Times between arrivals for 19
customers are generated by listing 19 three-digit values from Random Number
Table and comparing them to the random-digit assignment of Table Distribution of
Time Arrival.

Table: Time-Between-Arrival Distribution

Table: Service Time Generated

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
15
Simulation Examples: Simulation of Queuing Systems

Table: Simulation Table for Queuing Problem

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
16
Simulation Examples: Simulation of Queuing Systems

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
17
Simulation Examples: Simulation of Queuing Systems

3. Coffee Shop Facility

Mr. Srinivasan, owner of Citizens restaurant is thinking of introducing separate coffeeshop


facility in his restaurant. The manager plans for one service counter for the coffee shop
customers. A market study has projected the inter-arrival times at the restaurant as given
in the table. The counter can service the customers at the following rate:

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
18
Simulation Examples: Simulation of Queuing Systems

Mr. Srinivasan will implement the plan if the average waiting time of customers in the
system is less than 5 minutes. Before implementing the plan, Mr. Srinivasan would like to
know the following:
i. Mean waiting time of customers, before service.
ii. Average service time.
iii. Average idle time of service.
iv. The time spent by the customer in the system.

Simulate the operation of the facility for customer arriving sample of 20 cars when the
restaurant starts at 7.00 pm every day and find whether Mr. Srinivasan will go for the
plan.
Use the following sequence of random numbers
SL.--→ 1 2 3 4 5 6 7 8 9 10 11 12 13 14
For 87 37 92 52 41 05 56 70 70 07 86 74 31 71
arrivals
For 36 16 81 08 51 34 88 88 15 53 01 54 03 54
service
time

SL.--→ 15 16 17 18 19 20
For arrivals 57 85 39 41 18 38
For service time 56 05 01 45 11 76
Solution
Arrival time and random digits assignment and the service time and random
digits assignment
Cumulative Random digits
Inter-arrival time probability
probability assignment
2 0.15 0.15 0 - 15
3 0.25 0.40 16 - 40
4 0.20 0.60 41 - 60
5 0.25 0.85 61 - 85
6 0.15 1.00 86 - 100

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
19
Simulation Examples: Simulation of Queuing Systems

The service time and random digits assignment


Cumulative Random digits
Service time Probability
probability assignment
2 0.10 0.10 0 - 10
3 0.25 0.35 11 - 35
4 0.30 0.65 36 - 65
5 0.20 0.85 66 - 85
6 0.15 1.00 86 - 100
Now we get,

i. Mean waiting time of customers, before service: 20/20= 1 minute


ii. Average service time= total service time/ total customers= 72/20=3.6 minutes
iii. Average idle time of service= total idle time/total customers= 17/20= 0.85
minutes
iv. The time spent by the customer in the system= average service time + average
waiting time= 3.6+1= 4.6 minutes

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
20
Simulation Examples: Simulation of Queuing Systems

4. Dentist Schedule

Dr. Watson, a dentist schedules all his patients for 30-minute appointments. Some of the
patients take more or less than 30 min depending on the type of dental work to be done.
The following table shows the summary of the various categories of work, their
probabilities and time actually needed to complete the work.

Assuming the dentist clinic starts at 8.00 am, the arrival pattern and the service category
are shown in below table.

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
21
Simulation Examples: Simulation of Queuing Systems

Arrival Pattern of the Patients

Data sheet

Patient Arrival Service Service Service Waiting Idle time


start duration ends time (for
(minutes) (minutes) doctor)
1 8:00 8:00 60 9:00 0 0
2 8:30 9:00 15 9:15 30 0
3 9:00 9:15 45 10:00 15 0
4 9:30 10:00 45 10:45 30 0
5 10:00 10:45 45 11:30 45 0
6 10:30 11:30 15 11:45 60 0
7 11:00 11:45 45 12:30 45 0
8 11:30 12:30 45 01:15 60 0
Total 285

The average waiting time of patients = Total waiting time/ total patients

= 285/8

= 35.625 minutes

Md. Mohibullah, Lecturer, Department of CSE, Comilla University


Email: mohib.cse.bd@gmail.com
22

You might also like