02 - SYSC4005 - Simulation Examples
02 - SYSC4005 - Simulation Examples
SYSC 4005/5001W
Discrete Simulation/Modeling
Winter 2024
1
Introduction
2
Simulation Steps
3
Simulation of Queueing Systems (1/4)
• A queueing system is described by its calling population, the nature of
the arrivals, the service mechanism, the system capacity, and the
queueing discipline.
• The members of the calling population may be, for example, customers,
telephone calls, or jobs in a repair shop; here, we refer to them as units.
4
Simulation of Queueing Systems (2/4)
• Assumptions: unlimited potential calling population and a constant
arrival rate.
• no matter how many units have already arrived or are still present in
the system, the interarrival time until the next arrival follows the same
statistical distribution.
• Arrivals for service occur one at a time in a random fashion; once they
join the waiting line, they are eventually served.
• Service times are of some random length according to a probability
distribution which does not change over time.
• The system capacity has no limit, any number of units can wait in line.
5
Simulation of Queueing Systems (3/4)
6
Simulation of Queueing Systems (4/4)
7
Simulation of Queueing Systems
Departure Event
8
Simulation of Queueing Systems
Arrival Event
9
Simulation of Queueing Systems
10
Simulated Clock
11
Random Numbers
12
Random Numbers
• Random numbers can be taken from random digits table, or can be
generated in simulation packages and in spreadsheets (such as Excel).
• E.g., Excel has a macro function called RAND() that returns a
"random" number between 0 and 1.
• When numbers are generated by using a procedure, they are often
referred to as Pseudo-Random Numbers (PRNs).
• Because the procedure is fully
known, it is always possible to
predict the sequence of
numbers that will be generated
prior to the simulation.
13
Single Channel Queue – Interarrival Times
• In a single-channel queueing
simulation, interarrival times and
service times are generated from
the distributions of these random
variables.
• For simplicity, assume that the
times between arrivals were
generated by rolling a dice (die)
five times and recording the up These five interarrival times are used to
face. This table contains a set of compute the arrival times of six customers at
five inter-arrival times generated the queueing system
in this manner.
14
Single Channel Queue – Service Times
15
Single Channel Queue – Simulation Table
16
Chronological Ordering of Events
17
Number of Customers in the System
18
Example
• A small grocery store has one checkout counter.
• Customers arrive at the checkout counter at random times from 1 to 8
minutes apart, interarrival times are integer-valued with each of the 8
values having equal probability; this is a discrete uniform distribution
• The service times vary from 1 to 6 minutes (also integer-valued), with the
probabilities 0.1, 0.2, 0.3, 0.25, 0.10, 0.05, respectively.
• Our objective is to analyze the system by simulating the arrival and
service of 100 customers and to compute a variety of typical measures of
performance for queueing models.
• 100 customers is too small for good analysis.
19
Example
Interarrival Times • A set of uniformly distributed between 0
and 1 RNs is needed to generate the
arrivals at the checkout counter.
Successive RNs are independent.
• 99 RNs is needed. Three-place RNs will
suffice. (Table A.1)
• There are 1000 three-digit values possible
(001 through 000).
• The third column is the cumulative
probability for the distribution.
20
Example
• A set of uniformly distributed between 0
Service Time and 1 RNs is needed to generate the
arrivals at the checkout counter.
Successive RNs are independent.
• 99 RNs is needed. Two-place RNs will
suffice. (Table A.1)
• There are 100 three-digit values
possible (01 through 00).
• The third column is the cumulative
probability for the distribution.
Service Time Distribution • The probability of a service time of 1
Average Service Time = ∑6𝑖𝑖=1 𝑠𝑠𝑖𝑖 𝑝𝑝(𝑠𝑠𝑖𝑖 ) = 4.5 min is 0.10 10 of the 100 random
digit values are assigned to such an
minutes
occurrence.
21
Interarrival Time Generation
22
Service Time Generation
23
The Simulation Table
• Columns are added to
answer questions posed.
• All rows are based on the
random numbers for
interarrival and service
times and the completion
time of the previous
customer
• The rightmost columns have
been added to collect
statistical measures of
performance (each
customer’s time in system
and the server’s idle time).
24
Example Results
25
Example Results
total service time (minutes) 317
• Average service time (minute) =
total number of customers = 100
=
3.17 minutes
This can be compared with the expected service time by finding the
mean of the service-time distribution
𝐸𝐸 𝑆𝑆 = ∑∞
𝑠𝑠=0 𝑠𝑠𝑠𝑠 𝑠𝑠 = 1 0.10 + 2 0.20 + 3 0.30 + 4 0.25 + 5 0.10 +
6 0.05 = 3.2 minutes
26
Example Results
• Average time between arrivals (minute) =
• This can be compared with the expected time between arrivals by finding
the mean of the discreet uniform distribution whose endpoints are 𝑎𝑎 =
1 and 𝑏𝑏 = 8.
𝑎𝑎+𝑏𝑏 1+8
𝐸𝐸 𝐴𝐴 = 𝑠𝑠
= 2
= 4.5 minutes
• Slightly higher than that of the simulation. The longer the simulation, the
closer the average will be to 𝐸𝐸 𝐴𝐴 .
27
Example Results
28
Waiting Time Distribution
29
Simulating a Queue with Two Servers
The Able-Baker Call Center Problem
• A computer technical support
center is staffed by two people,
Able and Baker, who take calls
and try to answer questions and
solve computer problems. The
time between calls ranges from
1 to 4 minutes, with distribution
as shown in the Table.
• Able is more experienced and
can provide service faster than
Baker. The distributions of their
service times are shown in the
tables.
30
Simulating a Queue with Two Servers
The Able-Baker Call Center Problem
The workbook provides a detailed explanation of the simulation steps, including the
underlying logic (formulas) for computing each step.
31
Simulating a Queue with Two Servers
The Able-Baker Call Center Problem
32
Simulating a Queue with Two Servers
The Able-Baker Call Center Problem
33
Simulating a Queue with Two Servers
The Able-Baker Call Center Problem
34
Inventory Simulation An order quantity, Q1, is placed
to bring the inventory level
up to 𝑀𝑀.
• The inventory system shown is called
an (𝑀𝑀, 𝑁𝑁) system:
• an inventory review every 𝑁𝑁 time
periods, maximum inventory level
𝑀𝑀
• at each 𝑁𝑁 time units, the inventory
level is checked and an order is
made to bring the inventory up to
the level 𝑀𝑀.
• For simplicity, the lead time is shown
as zero (in reality, it is modeled as a Shortage.
random variable.)
35
Inventory Simulation
• Demands are not usually known with certainty, so the order quantities are
modeled by a probability distribution.
• In the example graph, demand is shown as being uniform over the
time period.
• In the second cycle, the amount in inventory drops below zero, indicating
a shortage. These units are backordered; when the order arrives, the
demand for the backordered items is satisfied first.
• To avoid shortages, a buffer, or safety, stock would need to be carried.
• In some inventory systems, a portion of sales may be lost rather than
backordered when inventory runs out.
36
Inventory Simulation
37
Inventory Simulation
• The total cost (or total profit) of an inventory system is the measure of
performance, can be affected by the policy alternatives
• the decision maker can control 𝑀𝑀 and 𝑁𝑁.
• Inventory systems have a number of parameters, some controllable and
some not.
• The controllable variables are the decision or policy variables. For each
item in inventory, these include:
1. The maximum inventory level, 𝑀𝑀
2. The review period, 𝑁𝑁
3. The order quantity (for replenishment), 𝑄𝑄
4. Lead time for replenishment, 𝐿𝐿
38
Inventory Simulation
• In a model of an (𝑀𝑀, 𝑁𝑁) inventory system, the events that may occur are
1. the demand for items in the inventory,
2. the review of the inventory position and resulting decision to place a
replenishment order, and
3. the arrival of replenishment stock.
• When the lead time is assumed to be zero, events 1 & 2 occur at the
same time.
39
Simulating the News Dealer’s Problem
• In this example, a news dealer must decide how many newspapers to
buy. In this and similar problems, only a single time period of specified
length is relevant, and only a single procurement is made.
• Inventory remaining at the end of the single time period is sold for
scrap, discarded or recycled.
• The dealer buys papers for 33 cents each and sells them for 50 cents
each. Newspapers not sold at the end of the day are sold as scrap for 5
cents each. Newspapers can be purchased in bundles of 10. Thus, the
newsstand can buy 50 or 60 or 70 papers, and so on. The order quantity,
𝑄𝑄, is the only policy decision.
• Unlike some inventory problems, the order quantity 𝑄𝑄 is fixed since
ending inventory is always zero due to scrapping leftover papers.
40
Simulating the News Dealer’s Problem
41
Simulating the News Dealer’s Problem
42
Simulating the News Dealer’s Problem
Simulation Table for Purchase
of 70 Newspapers
43
Simulating the News Dealer’s Problem
44
Simulating the News Dealer’s Problem
Results Analysis
• The average total (20-day) profit was $135.49 (averaged over the 400
trials).
• The minimum 20-day profit was $86.60 and the maximum was $198.00
• The figure shows that only 38 of the 400 trials resulted in a total 20-day
profit of more than $160.
• The single trial had a profit of $114.70, which is on the low side of the
distribution in the histogram figure. This shows that
• the result for one 20-day trial may not be representative of long-term
performance, and
• it is necessary to simulate many trials as well as conduct a careful
statistical analysis before drawing conclusions.
45
Questions?
46