Simulation
Dr Valentina Plekhanova
CISM02: Decision Support for Management
Unit 10
Unit 10
Mathematical Models
Reminder
Mathematical Models
Static Models
Analytical Models
Dynamic Models
Numeric Models
Numeric Models
Analytical Models
Simulation Models
Unit 10
Realworld
System
Input Variables
(Observable)
Output Variables
(Observable)
X X . X
Barrier to observation
Non-observable Variables
Unit 10
Model
Computer
Simulation
Unit 10
Unit 10
What is Simulation?
Simulation is emulation of reality using mathematical model.
The Oxford English Dictionary describes simulation as:
"The technique of imitating the behaviour of some situation or system
(economic, mechanical, etc.) by means of an analogous model,
situation, or apparatus, either to gain information more conveniently
or to train personnel."
Unit 10
Simulation: Definition
All simulation models are so-called input-output models.
That is, they yield the output of the system given the input to its
interacting subsystems.
Simulation models are run rather that solved in order to obtain the
desired information or results.
They are incapable of generating a solution on their own in the sense of
analytical models; they can only serve as a tool for the analysis of the
behaviour of a system under conditions specified by the experimenter.
Thus, simulation is not a theory but a methodology of problem solving.
Unit 10
Unit 10
Unit 10
10
Simulation
Simulation: write a simulation model that generates randomly arrivals of
cars and duration of services. It must also sequence properly all
activities to have a one-to-one correspondence with the real system.
Also observation, collection of statistical data, and evaluation must be
programmed (for each car compute the time spent, accumulate these
times, count number of cars, at the end compute and display the
average).
Unit 10
11
Experiment:
Advantages & Disadvantages
These three methods can not be ranked because all of them have
advantages and disadvantages. They can be compared only in the
context of certain particular case taking into account various criteria.
Nevertheless some basic facts are obvious:
Experiment is always the most accurate method, that should be used
whenever it is feasible. Unfortunately very often the experiment is:
Too dangerous (behaviour of a nuclear reactor in critical situations,
landing with a plane with one jet off, etc.)
Too expensive (all cases that cause a damage, long experiments
studying throughput of a data network using leased phone lines, etc.)
Not possible at all if the system being investigated is not available
(evaluation of more possible alternatives in the design stage.)
CISM02 Decision Support for Management
Unit 10
12
Analysis:
Advantages & Disadvantages
Analysis (mostly mathematical) is typically based on strong
assumptions that are rarely true in practical life. Another possible
drawback of analytical methods is too complicated apparatus used
and/or too time consuming computation. An example of this is analysis
of Queuing Networks.
On the other hand using formulae gives mostly fast results and it is
possible to check a large number of alternatives by simply inserting
different values of parameters to the formula(e). Experimental methods
are mostly much more time consuming.
Another problem of analysis is availability of necessary parameters.
Their exact measuring is also not necessarily feasible or it is
impossible in the design stage. Using estimated data or data taken
from other similar systems decreases credibility of results.
CISM02 Decision Support for Management
Unit 10
13
Simulation:
Advantages & Disadvantages (1)
Simulation is also an experimental method. Instead of experimenting
with the real system the experiments are performed with the simulation
model (whose design is thus the key point of simulation studies). Also
simulation has many drawbacks. Here are the most important ones:
Unit 10
14
Simulation:
Advantages & Disadvantages (2)
Limited knowledge of the system being simulated. First of all some
quantitative parameters must be known. In the above example it is
necessary to generate random intervals between arrivals and random
service times. Here simulation is much more flexible than analysis simulation languages support generation of random numbers with
practically any distribution. In the above example both random figures
can be based on any (e.g. experimentally obtained) distributions.
Nevertheless any distribution needs either several parameters (if it is
a theoretical one) or directly the Distribution Function (if the
distribution is obtained by measuring). There can be also things in the
system (typically in the design stage) that can not be quantified and
often it is necessary to accept the fact that there might be aspects we
are not aware of at all.
CISM02 Decision Support for Management
Unit 10
15
Simulation:
Advantages & Disadvantages (3)
Too time consuming computation. An example is analysis of large
scale systems with many components working in parallel. Because
application of real parallelism is still not common, such systems are
simulated by a program performed by a single processor.
Parallel activities are then performed one at a time (even if the user
has an impression of parallelism and during the design of the
simulation model "thinks in parallel"). The result of this is the fact that
simulation could be much slower than the real time (1 second of the
model time takes 10 minutes of the CPU time). This of course
disables application of simulation in real time control.
Unit 10
16
Unit 10
17
Simulation Process:
a Descriptive Process
Simulation is the process of developing a model of a problem and
estimating measures of the problems performance by performing
sampling experiments on the model.
Simulation differs significantly form the modelling-solution framework
where we stress the formulation and development of analytical models
and the analytical solutions. In most cases the analytical solutions are in
the form of algorithms (e.g. that yielded optimal solutions).
Simulation emphasises neither of these factors it is a descriptive
modelling process as opposed to a normative process.
McKeown
CISM02 Decision Support for Management
Unit 10
18
Simulation Models
Reminder
Simulation models can be classified according to the time at which state
transitions occur. This way there is differentiation between continuous and
discrete simulation models.
In a continuous simulation, the state of the model changes continuously with
the times.
In a discrete simulation, the state transition occurs at intervals, i. e. at discrete
times.
Discrete simulation models are further differentiated into time-controlled,
event-driven, activity-oriented, process-oriented and transaction-oriented
simulation models.
Unit 10
19
Types of Simulation
There are three general types of simulation:
Analogue model
Continuous model
Discrete model
Unit 10
20
10
Continuous Models
Continuous models represent the system experiencing smooth
changes in characteristics over time.
The objective of the model is to plot the simultaneous (continuous)
variations of the different characteristics with time.
For example, in an inventory system the output might include time
changes of inventory levels, sales, unsatisfied demand, and
backorders.
Unit 10
21
Discrete Models
In discrete models a system is simulated by observing it only at
selected points in time.
These points coincide with the occurrence of certain events which
are crucial to effecting changes in systems performance.
The most common type of simulation is the discrete model.
A discrete event is something that occurs at an instant of time.
For example, pushing an lift button, starting of a motor, stopping of a
motor, and turning on a light, are all discrete events because there is
an instant of time at which each occurs.
CISM02 Decision Support for Management
Unit 10
22
11
Unit 10
23
Unit 10
24
12
Unit 10
25
Unit 10
26
13
Unit 10
27
Unit 10
28
14
Unit 10
29
Modifications/Refinements
Data Collection
.
CISM02 Decision Support for Management
Unit 10
30
15
Event
This approach describes an instantaneous change, usually from a stop event to a start
event. This is the most common one used, easy to understand and efficient and is
acceptable to implement.
Activities
Process
This approach groups activities to describe the life cycle of an entity e.g. a machine.
This is less common and more difficult to plan and implement, but is generally
thought to be the most efficient.
Unit 10
31
(2)
Unit 10
32
16
Unit 10
33
Unit 10
34
17
Random Numbers:
Midsquare Technique (2)
The midsquare procedure consists of taking a four-digit number (more
elaborative techniques may use up to ten digits), preferably (but not
necessarily) selected at random, squaring it, taking the four digits
starting at the third from the left, recording them, squaring them, and so
on.
For example, if we start with 3182, by squaring we obtain 10,125,124.
We then take the four digits, 1251, record them, square them, and so on.
Eventually this procedure will return to the number with which it started.
The length of the cycle generally falls between 10 4 and 10 6 .
Unit 10
35
Random Numbers:
Congruential Technique (3)
The congruential procedure, although more complicated, may yield
cycles as large as 1012 . This procedure consists of letting
X n 1 KX n (mod M )
This is, Xn+1 is equal to the number that remains after KXn is divided by M.
This method was first reported by Lehmer (1951), who used K=23, M= 10 1 .
8
Unit 10
36
18
F(x)
Random number
Random variate
X
CISM02 Decision Support for Management
Unit 10
37
Unit 10
38
19
Unit 10
39
F=P(1+r/m)
The inputs are the initial investment (P = $1000), annual interest rate
(r = 7% = 0.07), the compounding period (m = 12 months), and the
number of years (Y = 5).
Unit 10
40
20
Unit 10
41
A Hand Simulation:
Attendant Problem (1)
Let us consider an example which introduces the nature of simulation.
The filling station is managed by a single attendant who serves the
customers directly, each one taking between one and six minutes of his
time (the longer times corresponding to customers needing oil and a
battery and tyre check as well as petrol). The management problem to
be resolved is that of whether it would be worthwhile to employ a
second attendant to improve the service given to customers. For the
purposes of the example a change to self-service is not a feasible
alternative.
The aim of the simulation is, therefore, to test the effect that employing
the second attendant has on the queuing time of customers without
going to the trouble and expense of hiring one.
Kidd, 1985, pp.233
CISM02 Decision Support for Management
Unit 10
42
21
A Hand Simulation:
Attendant Problem (2)
There is a need for knowledge of the behaviour of a system in advance
of making changes to it and also the system is subject to random or
erratic events.
Customers do not arrive regularly and it takes different amounts of time
to serve them.
Unit 10
43
A Hand Simulation:
Attendant Problem (3)
Time
Events
08-01
Car
No
Service
Time
Time
No of arrivals
08-02
08-03
08-04
08-05
08-08
08-09
08-10
10
10
11
08-12
12
08-13
13
08-06
08-07
08-11
08-14
14
08-16
15
16
Unit 10
44
22
A Hand Simulation:
Attendant Problem (4)
Server
Server
Server
0
Server
. 7
Server
Server
Server
Server
Server
Server
8
Server
Server
4
Server
11
One Attendance
CISM02 Decision Support for Management
Server
Server
Server
Server
Server
Server
Server
Server
Server
10
Server
Server
Server
Server
Server
10
Server
Server
Server
Server
Server
Server
Server
Server
11
Server
Two Attendances
Unit 10
45
A Hand Simulation:
Attendant Problem (5)
A much longer simulation run would be needed to show the extent of the
improvement.
A major shortcoming of the hand simulation is the way it handles random
events. The randomness of customer behaviour is governed by the
observation made on a particular day and at a particular time.
If what happened when these observations were made was not typical,
the simulation results will not relate to representative behaviour of the
filling station.
Unit 10
46
23
A Hand Simulation:
Attendant Problem (6)
In order to overcome this difficulty an improved mechanism for handling
random events is needed.
One way of approaching this problem is to increase the range of initial
observations, but this may be very time-consuming and may still provide
only a limited set of observations.
A better way is to use the original observations to establish a pattern in
the random events and then to sample from the pattern rather than from
a particular set of observations. In this way an almost limitless number of
typical days can be created.
Unit 10
47
Unit 10
48
24
Unit 10
49
Unit 10
50
25
Unit 10
51
Unit 10
52
26
Unit 10
53
Monte Carlo:
Statistical Sampling Method
Monte Carlo simulation is categorized as a sampling method because
the inputs are randomly generated from probability distributions to
simulate the process of sampling from an actual population.
So, we try to choose a distribution for the inputs that most closely
matches data we already have, or best represents our current state of
knowledge.
The data generated from the simulation can be represented as
probability distributions (or histograms) or converted to error bars,
reliability predictions, tolerance zones, and confidence intervals.
Monte Carlo simulation can be defined as a method to generate random
sample data based on some known distribution for numerical
experiments.
Monte Carlo method is a sampling processs used to select sample
values randomly from a probability distribution.
CISM02 Decision Support for Management
Unit 10
54
27
Unit 10
55
+ y2
Unit 10
56
28
Unit 10
57
pi
% pi.m
% Matlab Program to Find pi using Random Numbers
Nrand = input('How Many Random Numbers ');
NInside = 0;
for nloops=1:Nrand
Xrand = rand;
% Generate Random XY Point
Yrand = rand;
Rrand = Xrand^2 + Yrand^2;
% Find its distance from origin
if (Rrand <= 1)
NInside = NInside + 1;
end
end
% disp(['Total Generated: ' num2str(Nrand) ' Inside Pts: ' ...
num2str(NInside)]);
piapprox = 4*NInside/Nrand;
disp([' Approximation to pi = ' num2str(piapprox)]);
CISM02 Decision Support for Management
Unit 10
58
29
Simulation Steps
Reminder
In case a simulation model is developed, the following steps must usually be
taken:
Unit 10
59
Unit 10
60
30