You are on page 1of 27

SIMULATION AND

MODELING SESSION 2
Queuing and Simulation
 In many retail stores and banks, management has tried to reduce the frustration of customers
by somehow increasing the speed of the checkout and cashier lines.

 Although most grocery stores seem to have retained the multiple line/multiple checkout
system, many banks, credit unions, and fast food providers have gone in recent years to a
queuing system where customers wait for the next available cashier.

 The frustrations of "getting in a slow line" are removed because that one slow transaction does
not affect the throughput of the remaining customers.
Queuing and Simulation
 One method to ameliorate the problem has been to use queuing theory

 It has been proved that throughput improves and customer satisfaction increases when queues
are used instead of separate lines.

 Queues are also used extensively in computing---web servers and print servers are now
common
Queuing and Simulation
 Characteristics of a queuing system that impact its performance, for example, queuing
requirements of a restaurant will depend upon factors like:
 How do customers arrive in the restaurant?
 Are customer arrivals more during lunch and dinnertime (a regular restaurant)?
 Or is the customer traffic more uniformly distributed (a cafe)?
 How much time do customers spend in the restaurant?
 Do customers typically leave the restaurant in a fixed amount of time?
 Does the customer service time vary with the type of customer?
 How many tables does the restaurant have for servicing customers?
 The above three points correspond to the most important characteristics of a queuing system.
They are explained below:
Queuing and Simulation
 Arrival Process:
 The probability density distribution that determines the customer arrivals in the system.
 In a messaging system, this refers to the message arrival probability distribution.
 Service Process:
 The probability density distribution that determines the customer service times in the system.
 In a messaging system, this refers to the message transmission time distribution.
 Since message transmission is directly proportional to the length of the message
Queuing and Simulation
 Number of Servers:
 Number of servers available to service the customers.
 In a messaging system, this refers to the number of links between the source and destination
nodes.
Queuing and Simulation
 Simulation in general is to pretend that one deals with a real thing while really working with
an imitation.
 In operations research the imitation is a computer model of the simulated reality.
 A flight simulator on a PC is also a computer model of some aspects of the flight: it shows on
the screen the controls and what the "pilot" (the youngster who operates it) is supposed to see
from the "cockpit" (his armchair).
 Why to use models? To fly a simulator is safer and cheaper than the real airplane.
 For precisely this reason, models are used in industry commerce and military: it is very costly,
dangerous and often impossible to make experiments with real systems.
 Provided that models are adequate descriptions of reality (they are valid), experimenting with
them can save money, suffering and even time.
Queuing and Simulation
 When to use simulations?
 Simulation is a useful tool for any systems that change with time, such as a gas station where
cars come and go, (called dynamic systems) and involve randomness.
 Nobody can guess at exactly which time the next car should arrive at the station, are good
candidates for simulation.
 Modeling complex dynamic systems theoretically need too many simplifications and the
emerging models may not be therefore valid.
 Simulation does not require that many simplifying assumptions, making it the only tool even
in absence of randomness.
Queuing and Simulation
 How to simulate?
 Suppose we are interested in a gas station.
 We may describe the behavior of this system graphically by plotting the number of cars in the
station; the state of the system.
 Every time a car arrives the graph increases by one unit while a departing car causes the graph
to drop one unit.
 This graph (called sample path), could be obtained from observation of a real station, but
could also be artificially constructed.
 Such artificial construction and the analysis of the resulting sample path (or more sample
paths in more complex cases) consist of the simulation.
Queuing System example
 Discrete event simulation.
 In discrete event simulation the model is discrete, and the simulated clock always jumps from
one event time to the most imminent event time.
 At each event time the corresponding action (state change) is performed, and simulated time is
advanced to the next time when some action is to occur
Queuing System example
 The car wash problem
 A garage owner has installed an automatic car wash that services cars one at a time.
 When a car arrives, it goes straight into the car wash if this is idle; otherwise, it must wait in a
queue.
 The car washer starts his day in a tearoom and return there each time he has no work to do.
 As long as cars are waiting, the car wash is in continuous operation serving on a first-come,
first-served basis. All cars that have arrived before the garage closes down are washed.
 Each service takes exactly 10 minutes. The average time between car arrivals has been
estimated at 11 minutes.
 The garage owner is interested in predicting the maximum queue length and average waiting
time if he installs one more car wash and employs one more car washer.
Queuing System example
 Three approaches for discrete event simulation
 There are basically three approaches that can be used for discrete event simulation: the event-
based, the activity-based and the process-based approach.
 The event-based approach
 In the event-based approach the model consists of a collection of events.
 Each event models a state change and is responsible for scheduling other events that depend
on that event.
 Each event has associated an event time and some actions to be executed when the event
occurs. In the car wash problem the arrival of a car is an example of an event.
 Actions associated with this event are the inclusion of the car into the waiting line and the
scheduling of the next car arrival.
 Event-based simulation is the simplest and most common implementation style of discrete
event simulation because it can be implemented in any programming language
Queuing System example
 The activity-based approach
 In the activity-based approach the model consists of a collection of activities.
 Each activity models some time-consuming action performed by an entity. Each activity has
associated a starting condition, some actions to be executed when the activity starts, the
duration of the activity, and some actions to be executed when the activity finishes.
 In the car wash problem the washing of a car is an example of an activity.
 The condition for starting this activity is that one of car washers is idle and the waiting line is
not empty.
 When the activity starts, an idle car washer is removed from the tearoom, and the first waiting
car is removed from the waiting line. The duration of the activity is 10 units of simulated time.
When it ends, the car washer is put back into the tearoom
 Whilst the activity approach is relatively easy to understand, it normally suffers from poor
execution efficiency compared to the event-based approach
Queuing System example
 The process-based approach
 In the process-based approach the model consists of a collection of processes.
 Each process models the life cycle of an entity and is a sequence of logically related activities
ordered in time. In the car wash problem a car is an example of a process.
 Each car performs the following sequence of activities: wait in queue, get washed.
 Since processes resemble objects in the real world, process-based simulation is often easy to
understand.
 Implementation, however, is not easy and execution efficiency may be poor if the
implementation is not done properly.
 The figure below illustrates the relation between the concepts event, activity and process.
Queuing System example
 The process-based approach
How to do the simulation
 Project background
 Describe the problem at hand
 Problem at hand
 Maybe could be long queues at the bank
 Reduction of clients due to long queues
How to do the simulation
 Scope and objectives
 Set the objectives you intend to achieve
 To observe how long the clients take in a queue

 Determine possible improvement strategy


 Find optimal staffing level
How to do the simulation
 Model construction
 Define the entities and the resources
 Entity could be the bank customers

 Resources could be the following:


 Lobby Manager (2) – checks in arriving customers
 Teller (2) – for depositing and cash transfers
 Banker (2)– account opening, Debit and Credit cards and Loans
 Branch Manager (1) – supervise customer satisfaction
How to do the simulation
 Model construction Flowchart
How to do the simulation
 Assignment two deadline 17 May 2021
 Due date:
 In groups of 5:
 Come up with an imaginary problem that you want to simulate and should be unique from the
following list:

 Supermarket
 Dump truck loading
 Student registration at Bursar Office
 Cinema Ticket purchases
 Bus ticket purchases
How to do the simulation
 Assignment two

 State the objectives of the study


 Come up with the entities and the resources in the study
 Come up with the flowchart
 Come up with a conceptual model which is easy to understand and the requirements are given
in the next slide
How to do the simulation
 Model construction requirements
 Requirements for the simulation will be as follows:
 One must maintain the queue
 One must have separate methods for each of the three simulation activities (arrival, service
and departure).
 One must use random numbers that are exponentially distributed for the times between
arrivals of successive customers and for the service time for each customer.
 One must compute and output the average length of time spent in the queue per customer.
How to do the simulation
 Model construction
 The output should show:
 The Customer number like customer 1
 The Arrival Time
 Waiting time
 Service Start time
 Service time
 Departure time
How to do the simulation
 Model construction

 You are required to come up with the Pseudo code for each method

 Use any language of your choice to do the simulation


Pseudo code example
 Set total to zero
 Set grade counter to one
 While grade counter is less than or equal to ten
 Input the next grade
 Add the grade into the total
 Set the class average to the total divided by ten
 Print the class average.
End of Session 2

 Any questions
End of Session 2

You might also like