Simulation and Queueing Theory: Topic 8
Simulation and Queueing Theory: Topic 8
Topic 8
Contents
8.1 An Introduction to Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
8.2 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
8.3 Steps in Simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
8.3.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
8.3.2 Model Building . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
8.3.3 Input Modelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
8.3.4 Verification and Validation . . . . . . . . . . . . . . . . . . . . . . . . . . 8
8.3.5 Output Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
8.4 Queueing Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
8.4.1 Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
8.4.2 Equations for a Single Server . . . . . . . . . . . . . . . . . . . . . . . . 16
8.4.3 A Two-Server Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
8.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
8.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2 TOPIC 8. SIMULATION AND QUEUEING THEORY
Hypothesis about how and why certain phenomena occur can be tested for
feasibility.
There are further limitations to those listed by Pegden, Shannon, and Sadowski (1995).
Simulation is an experimental problem solving technique. As said before, when available
analytical (or ’close’) solutions should be preferred since they are more accurate. To put
this last statement differently, solutions found by simulations often tend to be suboptimal.
The solution may be the best found after running several simulations with different
parameters, but this is in general no guarantee that the solution is indeed the best
available (which can usually only be proven using analytical methods). Simulations
also come with a price tag. Developing a good simulation is a complex task usually
performed by highly skilled people. In addition, substantial computing power may be
required to run a large simulation process. None of this comes for free. In fact, even
finding the right people to develop the simulation can be difficult, since those people
need next to solid statistical and programming skills also deep insight into the problem
or environment for which the simulation is to be developed. Finally, due to the lack of
analytical methods it is often difficult to detect or recognise errors within the design or
implementation of simulations.
The following are a couple of potential applications of simulation related to computer
science, information technology, and electrical engineering (in the broadest sense):
The list above suggests the following guidelines when to use simulations and models:
real systems may not (yet) exist, may be expensive, time consuming to create, or
hazardous;
experimentation with the real system may be expensive, dangerous, or likely to
cause serious disruption;
there may be the need to study past or future behaviour of the system, for example
in slow motion;
analytical modelling of the system may be impossible;
even if analytical modelling is possible there may not be a simple or practical
solution available;
validation of the model and the results is possible;
models can be tuned at any desired accuracy;
only incomplete information about the real system is available.
Formulate problem
Check for existing models. If such models (whether analytical or simulation
models) are available then solve the model and analyse the solution.
If there are no models relevant to the problem then one should first look for
an analytical model. An alternative might also be to enumerate all possible
alternatives and use evaluation procedures to select the optimal alternative. Only
when these options fail should one proceed to developing a simulation model, use
the model and analyse the data gained from the simulation.
8.2 Models
A model is any simplified representation of an object or a system. Models are used for
analysing, understanding, or explaining an object or a system. S.E. Elnaghraby (The
Role of Modeling in I.E. design, J. Industrial Engineering 1968) defines the role and
purpose of models as follows: Models are
an aid of thought;
an aid to communication;
a purpose of training and instruction;
a tool of prediction;
an aid to experimentation.
Models can be classified according to their nature, which can be physical, symbolic
(mathematical, numerical), or procedural (simulations). Physical models often have high
costs. Symbolic models, though often cheap, are difficult to communicate to people with
less mathematical training. Procedural models offer a good balance between costs and
use since they are easy to communicate.
Models can be further classified according to various characteristics. The following are
only some characteristics often mentioned in the literature:
Most mathematical models contain certain parameters that describe how the model
works or what the input or output of the model are. We distinguish between exogeneous
and endogeneous parameters (or variables). Exogeneous parameters represent
external parameters and may be seen as input parameters. An example are parameters
in the input probability distribution. Endogeneous parameters of a model are those that
are predicted by the model, i.e., the status or output variables.
– Problem formulation
– Setting objectives and overall project plan
Model building
– Model conceptualisations
– Data collection (for input)
– Model translation
– Verification of the (computer) model
– Validation (accurate description of the real world)
Running the model
– Experimental design
– Production runs and analysis
Documentation and reporting
The last steps are also often summarised as strategic planning, and include
experimentation, interpretation of the results and the final implementation of the findings.
The important parts of the simulation steps are contained in Figure 8.1:
Figure 8.1:
Some of these steps will be discussed in detail below.
The problem formulation given to the engineer is often vague. In many cases this
is just the statement that there seems to be a problem somewhere.
Related to the previous point, the problem may not yet be correctly identified, let
alone that there is a clear and concise problem formulation.
The system for which a simulation is to be designed may not be well understood.
This may be either due to the complexity of the system, or due to the engineer not
being acquainted with the system.
As a result most simulations start with an orientation study which aims to get a
firm understanding of the system in question. Also, objectives and alternatives are
continuously generated through the study and may be subject to change according to
the insights already gained.
The model should model and show the operations of the system in question.
The model should provide a solution to a real world problem.
The model should be for the benefit of those who asked for the design of the
model.
At the model building stage we can reiterate some of the common problems: Good
models are expensive and time consuming. This applies both to the human factor, i.e.,
to the people involved, as well to computing power. Models are almost always imprecise
since models are almost never a complete picture of the real world. Models may appear
to be accurate where in fact they aren’t. The converse is also true, where models may
be accurate where they don’t appear to be. Another common problem is that with the
design of a (mathematical) model we will associate numbers to certain data. This may
suggest a greater degree of validity to the model or its outcome than is actually justified.
Input data has to be collected for the various input processes.
Possible input distributions have to be selected to represent those input processes.
The choice is between theoretical distributions or empirical distributions.
Goodness-to-fit hypothesis testing is used to determine whether collected input
data matches a given theoretical distribution.
If the model is used to predict effects of new procedures then there may not be any
data to collect. In this case theoretical distributions have to be chosen to model
various input processes.
Parameters of the distributions have to be estimated using either point estimators
or interval estimators.
Let us state again the main use of the most important probability distributions:
Binomial distribution. This distribution models the number of successes in
successive trials, where the trials are independent from each other and there is a
common success probability .
Poisson distribution. This distribution is used to model arrival processes in fixed
time intervals where arrivals are independent. Thus this distribution can be used
to model arrivals of customers at a counter, or arrivals of printer jobs at the printer
queue.
Exponential distribution. The exponential distribution models time between
independent events. A typical use of this distribution is the time between arrivals
at a counter. If arrivals are modeled by the Poisson distribution then inter-arrivals
are modeled by the exponential distribution.
Normal distribution. The normal distribution is the most common distribution. It
often models errors or processing time due to its symmetric character.
Weibull distribution. Finally, the Weibull distribution is often used to model time-
to-failure of systems or system components.
Once the choice is made for a particular distribution then the parameters have to
be estimated. The following is a list of parameters for some of the more common
distributions and the common point estimators for their parameters. For more complete
tables see for example Banks, p. 370.
Validation aims to establish confidence into the model, i.e., confidence that the model is
indeed a true picture of the real world. A model that is not validated is only of academic
interest and of hardly any use in decision making or analysing a real-world situation.
Since validation is part of the art no prescribed mechanism exists for it. However, basic
guidelines are the following:
/ Results (say outcomes of the model) must be reasonable. This is often established
with test data where the correct outcome is known beforehand.
/ Testing of assumptions.
/ Testing of input-output transformations, i.e., does a certain variation of the input
parameters result in reasonable changes of the output results.
Validation is usually achieved through common sense and logic, by taking advantage of
knowledge and insight available, by empirical testing, by paying attention to details, by
debugging of the program, by input-output analysis and comparison with real-life data,
and by checking predictions. From this list it becomes clear that next to data and results
we also validate concepts, methodology, and inferences.
Calibration of the model may be seen as part of the validation process. Every model
is only a partial representation of the real world. Calibration is the fine tuning of the
validated model. It describes how accurate or inaccurate the model is. Calibration is
the term used for the fine tuning of parameters of a system (like input distributions,
parameters of the distributions, etc.). To be able to calibrate the major part of the model
has be be validated.
A test often used in validating models is the Turing test. Real reports are mixed with fake
reports based on model predictions. If experienced people cannot tell apart the reports
then this suggests that the model in question is an accurate picture of the real world.
Verification is the formal process whereby it is checked that the implementation of
the model is an accurate representation of the conceptual model. Typical verification
techniques include the following:
Again there are several aspects of the verification process. We verify the structure of
the program, the algorithm, but also the robustness of the code.
The analysis has to be done carefully, since it is easy to assign numbers too much
validity and forget that they come from a model.
However, the one company helicopter that can be serviced is definitely a finite
population.
In many queueing systems there is a limit to the length of the queue:
This is not to be confused with customer behavior, where customers will not queue if
there are already ten customers waiting in line to be served. Thus, the system capacity
is a real constraint of the system, and an important parameter in a simulation.
The arrival process is characterised by the time intervals between customer arrivals.
Such arrivals may be scheduled, or occur at random times, in which case they are
characterised by a probability distribution. For example, if arrival of customers is
3
modelled by a Poisson process with mean (arrivals per time unit), then inter-arrival
3
time is modeled by an exponential distribution with mean -1 (time units). The expected
4 3
number of arrivals in time intervals is thus . The Poisson process is often used to
model arrival of customers.
Next to scheduled and random arrivals there is also the possibility that there is always
one customer in the queue. This happens for example if the customer represents raw
material, and the production process guarantees that such material is always present.
Queue behaviour refers to the actions customers take while arriving or waiting in the
queue. Customers may
5 balk (leave, if the queue is too long),
5 renege (leave, if the queue proceeds too slowly), or
5 jockey (move between lines according to what the customer thinks is the
shortest/fastest line).
Discipline refers to the logical order in which customers are served. Often used models
are
5 FIFO (first-in-first-out), LIFO (last-in-first-out);
5 SIRO (service in random order);
5 SPT (shortest processing time first);
5 PR (service according to priority).
Example
Problem:
As a first example we look at a simple queue model which has an infinite population,
one queue, and one server.
Solution:
Suppose inter-arrival times are determined by rolling a die. If the numbers 6, 1, 4, 3, 6,
5 are rolled this means that the customers arrive at times
0,6,7,11,14,20,25
as in the following table:
7 8
Customer Interarrival time Arrival time on clock
9
: ; ;
< 7 =
> > 7?7
@ < 7>
; ; :9
= @ :?@
A < :?A
Suppose also that the service time for each customer is
2, 3, 1, 1, 1, 1, 2
time units respectively, then we can extend our table to include service begin and time
to get served to get the following table representing the time spent by customers in the
system:
:
Customer Arrival time Service begin Service time Service ends
:
1 0 0
< B
2 6 6
7 7C9
3 7 9
7 7D:
4 11 11
7 7D@
5 14 14
7 :E7
6
7
20
25
20
25
: :F=
Note that, for example, customer 3 has to wait for 2 time units before being served since
the server is still busy serving customer 2. After serving customer 3 (at time 10) the
server is idle for 1 time unit until customer 4 arrives, which is then served immediately.
Interarrival time
Service time
h Customer 1 arrives at time 0 and has 3 time units service time, leaving the system
at time unit 3. In total the customer spent 3 time units in the system, and the server
was not idle.
h Customer 2 arrives 6 time units after customer 1, thus arrives at time unit 6. Since
the server is idle the customer will be served immediately, leaving the system at
time unit 10 since the service time was 4 time units. The server was idle for 3 time
units (from time unit 3 until 6, after finishing serving customer 2 at time unit 3 and
waiting for the next customer to arrive at time unit 6).
h The rest of the table is generated similarly.
Time
Time
since Arrival Service Start Waiting End Idle
Customer spent in
last time time service (queue) service time
system
arrival
1 0 0 3 0 0 3 3 0
2 6 6 4 6 0 10 4 3
3 1 7 3 10 3 13 6 0
4 3 10 2 13 3 15 5 0
5 2 12 3 15 3 18 6 0
6 8 20 4 20 0 24 4 2
7 3 223 4 24 1 28 5 0
8 2 25 3 28 3 31 6 0
9 5 30 4 31 1 35 5 0
10 6 36 4 36 0 40 4 1
Time
Time
since Arrival Service Start Waiting End Idle
Customer spent in
last time time service (queue) service time
system
arrival
11 5 41 3 41 0 44 3 1
12 2 43 4 44 1 48 5 0
13 5 48 3 48 0 51 3 0
14 8 56 3 56 0 59 3 5
15 4 60 2 60 0 62 2 1
16 8 68 4 68 0 72 4 6
17 3 71 3 72 1 75 4 0
18 7 78 2 78 0 80 2 3
19 5 83 5 83 0 88 5 3
20 1 84 3 88 4 91 7 0
66 20 86 25
Let us summarise some of the data:
idle time
Probability (server idle) =
total run time
j ?k svm u lEpwkFx
o
4. The average service time is 3.3 time units.
84
average interarrival time =
XEwF19
6. The average waiting time for customers that have to wait is 2.22 time units.
7. The average time spent by a customer in the system is 4.3 time units.
Alternatively, the average time spent in the system is the average waiting time plus
the average server time, which is 1 + 3.3 = 4.3 .
time is taken as following the negative exponential distribution, with mean service rate
.
This is sometimes summarised as a M/M/1/ system.
(the two "M"s are the mean values above, "1" is 1 server and " " is because there is no
limit on queue size.)
In the following equations, the "system" refers to both waiting in the queue and being
served.
Average number in system,
F
Average number in queue,
tF\
Average queueing,
¢ ¡ tF
Average time in system,
£ ¥ ¤ ¡ F ¡
In addition:
Example
Problem:
Application forms arrive at a clerk’s desk for processing on average every 4 minutes.
Arrivals are assumed to follow Poisson distribution. The service rate is, on average, 20
per hour. Calculate the various queue characteristics.
Solution:
Arrivals: One form arrives every 4 minutes, so there are 15 in an hour. This means that
´ = 15.
Service: µ = 20
º F³ ¹± ± 15 = 3 forms
20 - 15
¸ º °¢³± ³t¼³t±¹ » ±\½ 15 = 2.25 forms
2
20(20 - 15)
¾¿ º À³ Á ³t¼³F± ¹ ±½ = 15 = 0.15 hours = 9 minutes
20(20 - 15)
à ³F¹ Á ± 1 = 0.2 hours = 12 minutes
20 - 15
ªJ¯°QÆ?Ç
Inter - arrival time Prob. Cum. prob. Random digits
1 0.25 0.25
Æ?ÈP°QÈ?Ç
2 0.40 0.65
È?ÈP°QÉ?Ç
3
4
0.20
0.15
0.85
1.00
É?ÈP°Êª?ª
Server A:
Ù Both server work about the same amount of time (A 40 time units, B 40 time units).
Ù Server A is 63% of the time busy, server B also 63%.
Ù Only 5 customers had to wait, and the total waiting time is very low with 7 time
units. The average waiting time for those who had to wait was just
7 ÛÜrÝ
5 Ú
time units.
Ù The system looks well-balanced. One server would not be able to do the job, and,
unless the costs for waiting are very high, a third server is not justified.
8.5 Conclusion
The design of a simulation is usually a large project and thus the rules of project
management apply. Project management suggests a number of simple models that
describe the process of running a project.
The simplest model is the waterfall model, which suggests a linear execution of various
stages of the project, which could here be
Ù problem analysis;
Ù model conceptualisation;
Ù validation;
Ù input modeling;
Ù model building;
Ù verification;
Ù simulation runs;
Ù output analysis;
Ù documentation.
However, due to its linear nature the waterfall model is usually too simple to be employed
for real projects. In fact, the waterfall model suggests that each stage has to be
completed before the next stage can start, and the model does not allow to go back
an correct any errors that were made.
More complex models have been suggested, most notably the so-called spiral model.
The common characteristics of these models are that they allow for stages to be revisited
and that they allow stages to be started before the preceding stage is completed. A
typical example why this is needed is calibration. Calibration happens after the first
simulation runs when the output of those runs is compared with real life data. Observed
discrepancies are then used to do a fine tuning of the input parameters and the validation
process is entered again.
Thus the list of stages above gives only the direction where a project is currently heading
to, but it is allowed to return to earlier stages to modify the design, to correct errors, or
to calibrate parameters.
8.6 Summary
ß Simulation enables the study of, and experimentation with, the interactions of
complex systems. Often the knowledge gained cannot be obtained by studying
the real-life system.
ß The design of simulations can be a highly complex task and, in fact, may be seen
as art.
ß Important stages in the design of a simulation are Overall Design (including the
problem formulation), Model Building (conceptualisations, input modeling, model
translation, verification and validation), Output Analysis, and Documentation.
ß The problem formulation is the hardest part in the design of a simulation since
the problem may not be correctly identified and the system may not be well
understood.
ß Finding the right model is the real part of the art.
ß Input modeling is concerned with collecting data to determine input distributions
and parameters for those distributions. Sampling, hypothesis testing, and
estimation is often used in input modeling.
ß Verification is about relating the conceptual model to the operational model (are
we building the model right?), validation is about the relationship between the real
system and the conceptual model (are we building the right model?).
ß Output analysis is the statistical evaluation of the data generated by the model so
that the model can be used in decision making.
ß Queues are often the simplest components of a simulation. A queueing model
consists in the simplest case of a population, the queue, and a server.
ß To define a queueing model one needs to specify queue behaviour, which are the
actions by the customers waiting in the queue. Customers could balk, renege, or
jockey.
ß Queue discipline refers to the logical order in which customers are served.
Common models are FIFO (first in first out), LIFO (last in first out), SIRO (service
in random order), SPT (shortest processing time first), or PR (service according to
priority).
ß More complex queueing models may have several queues, several servers, and
complex queue behaviour and discipline.
Glossary
calibration
Calibration is the term used for the fine tuning of parameters of a system (like input
distributions, parameters of the distributions, etc.).
endogeneous parameter
Endogeneous parameters of a model are those that are predicted by the model,
i.e., the status or output variables.
exogeneous parameter
Exogeneous parameters represent external parameters and may be seen as input
parameters. An example are parameters in the input probability distribution.
model
A model is any simplified representation of an object or a system.
queue behaviour
Queue behaviour refers to the actions customers take while arriving or waiting in
the queue.
queue discipline
Discipline refers to the logical order in which customers are served.
queueing theory
Queueing theory refers to the mathematical models used to simulate these
queues.
Turing test
Real reports are mixed with fake reports based on model predictions. If
experienced people cannot tell apart the reports then this suggests that the model
in question is an accurate picture of the real world.
validation
Validation refers to the agreement between a model and the real world.
verification
Verification refers to whether a model behaves as intended.
c