Lecture9
Lecture9
9.1 Introduction
By the end of this lesson you should check that you can:
explain what a simulation is
say why and when simulation is appropriate for use as a modeling tool
describe the benefits and drawbacks of using simulation
use random number tables to represent variability within a simulation model
use simulation to design a simple decision aid
explain the steps in simulation study
explain what is meant by Visual Interactive Simulation (VIS)
say what benefits can be achieved by using VIS.
Simulation is a way of using a model to imitate the behaviour of a particular situation. Many of you
will be familiar with video and computer games (if only because your son or daughter occupies
your PC with them!), flight simulators, model railways and business games. All these are
examples of efforts to mimic the real (and sometimes the fantasy) world. However, they are just
that – mimics – not the real thing.
In the business world, simulation is often used to study business operations. For instance, one
may want to mimic the workings of an assembly line of an automotive plant or the operation of a
call centre or some business service such as a bank. Simulation can also be used to mimic
business processes such as handling insurance applications or to model transport systems such
as freight coming into and out of a port.
Simulation involves a series of inputs, or data that go into a simulation model and the model
converts those inputs into some outputs, which indicate the behaviour of the real world system.
Therefore, a manager can experiment with different courses of action, by changing the inputs,
and the simulation provides an indication of the likely outcome. As a result, the manager gains a
better understanding of reality and is able to identify more appropriate courses of action to
undertake than would otherwise be the case. That is, he or she can make better, more informed,
decisions. Examples of some inputs and outputs are given in Table 6.1 below.
AHA – Lecture 9 1
Usually one experiments with the simulation model by asking a series of ‘what if’ questions and
getting the model to evaluate the likely outcomes. The simulation does not seek to provide the
best, or optimum, solution. It simply informs the modeller of the likely consequences of selecting a
particular combination of inputs. As examples of the use of simulation, Ford Motor Company used
simulation to aid in the planning and design of their Zetec engine plant in South Wales. This
represented an investment of some £500 million and Ford estimated that the simulations resulted
in increased output of about 30%. British Airports Authority (BAA) used simulation modelling to
help plan the train car requirements for the transit system at Stansted Airport and as each train
car cost £2 million it was obviously important to develop an efficient system of operations. The
same BAA model was also adapted for use at Hong Kong’s new airport for planning train car
requirements.
Characteristics of situations
Where simulation is a useful tool almost any business situation can be modelled and analysed
using simulation. However, in particular, simulations are best suited to situations where there is:
Variability – This may be predictable (for example, the time to set up a machine) or
unpredictable (for example, the number of customers arriving). This is what Pidd refers to
as a dynamic system.
Interaction – Components in the system interact with each other. For instance, the
number of customers arriving at a bank interacts with the number of tellers that are
serving and with the time it takes for a teller to serve a customer. Depending upon how
these interact, one gets shorter or longer queues in the bank. That is, these components
produce the distinctive behaviour of the particular system being considered.
Complexity – There is interaction between not just two or three elements, but between
many elements of the real situation. Often interaction between a small numbers of
elements in a system can be modelled analytically (for example, a single queue being
served by a single server). A system of many interactions may be impossible to model
analytically and may lead to behaviour that is unpredictable or that is difficult, if not
impossible, to foresee from consideration of the individual elements in isolation.
AHA – Lecture 9 2
Developing a simulation model is time consuming, especially for complex operations.
Consequently, it is an approach that tends only to be used when other modelling methods are not
applicable.
Advantages of simulation
When mathematical analysis methods are not available, simulation may be the only
investigation tool
When mathematical analysis methods are available, but are so complex that simulation may
provide a simpler solution
Allows comparisons of alternative designs or alternative operating policies
Allows time compression or expansion
Disadvantages of simulation
For a stochastic model, simulation estimates the output while an analytical solution, if
available, produces the exact output
Often expensive and time consuming to develop
An invalid model may result with confidence in wrong results.
AHA – Lecture 9 3
machines waiting for maintenance
telephone calls arriving at a service centre
passengers queuing to check in at an airline desk.
Very many systems can be regarded as having a queuing structure and as such they are
appropriate for discrete-event simulation. Just take a few minutes to think about a ‘typical’ day in
your life and see if you can identify situations where you may have to queue or wait. For instance,
this may be almost from the first moment when you get up and have to queue to use the family
bathroom (an all too familiar experience if you have teenage children!), or waiting at traffic lights
on your way to work, or queuing at lunchtime to pay for a sandwich. It should not take long for
you to identify well over a dozen instances in a day when you may have to queue.
One of the major aspects of discrete-event simulation is that it is able to model random events
based on both standard and non standard distributions. You already know about the normal
distribution as an example of a standard distribution. However, it should be clear from the reading
that you can also use non standard distributions based on collecting past data upon the
frequency of events (for example, the number of patients per day that are referred to a hospital
unit).
Therefore part of the way round these problems is to collect actual data on how frequently people
buy different numbers of burgers. If we do this, then suppose we obtain the following information:
As can be seen, people often order three or four burgers, although orders for other numbers also
occur from time to time. Armed with the above information we can now make use of random
numbers to help solve the remaining part of our problem with our simulation of this ordering
process. Random numbers are a sequence of numbers, normally on a scale of 0 to 99 (integer)
or 0 to 1 (real), which occur in a random or haphazard sequence. They possess three important
properties, which are that they are:
uniform – there is the same probability of any number occurring
AHA – Lecture 9 4
independent – once a number has been chosen it does not influence the chance of it
being chosen again
computer generated – most PCs have a random number generator available that can be
used in some software (for example, the Rand() function in Excel).
A good way to mimic the generation of random numbers would be to write each of the numbers
from 0 to 99 on 100 pieces of paper and put the paper pieces into a hat. One piece of paper is
picked out at random (that is, after the pieces have been given a good shuffle). The number on
that piece of paper is our first random number. It has a one in 100 chance of being chosen. If that
piece of paper is returned to the hat and a second piece drawn out, then the number on that
second piece constitutes the second random number. It also has a one in 100 chance of being
chosen (because we put the first number back in the hat). You could continue on all day pulling a
number out of the hat, noting it, and putting it back. At the end of the day you would find that if
you counted up how many times you had pulled each number out of the hat, then you would end
up with something like Figure 6.2.
Of course, you may not get exactly the same number of each integer if you try this and you might
get more of some and fewer of others. However, you would get the above diagram in the long
run. You can now see why we talk about random numbers being uniform – the distribution has a
uniform shape. We can also see from the hat analogy that choosing one particular random
number does not influence the number chosen on the next draw. Finally, random numbers are
computer generated since neither you, nor I, wants to stand round all day pulling numbers out of
hats.
In order to generate customer orders in the right proportion, random numbers are assigned in the
following way to the number of burgers that are ordered:
As can be seen, each number of burgers has the appropriate number of random numbers
allocated to it to reflect the frequency with which that number of burgers is ordered. So 20 of the
100 integer random numbers between 0 and 99 are allocated to two burgers (10 to 29), reflecting
the fact that this number of burgers are ordered 20% of the time. So you could go to a table of
AHA – Lecture 9 5
random numbers, pick a random start point in the table and, if the first number you pick is 58, this
then corresponds to an order of four burgers. If the second random number is 19, then this
corresponds to an order for two burgers, and so forth. Similarly, if we use real random numbers
(between zero and one) then the ranges allocated in the final column perform the same function.
9.3.1 Exercise
Use the random number tables on the last page, in conjunction with the above table of integer
random numbers, to complete the following table. You should use the random numbers from the
first column (commencing top left).
You should have chosen the random numbers 89, 31, 49, 9, 41, 70, 26, 95, 32 and 92 and these
correspond to 5, 3, 3, 1, 3, 4, 2, 6, 3 and 5 burgers respectively. Therefore, you should get a total
of 35 burgers, which gives a mean of 3.5 burgers per order. Now have another go, but choose a
different column of random numbers.
AHA – Lecture 9 6
of random numbers which will have given rise to a different number of burgers. This indicates a
facet of simulation. That is, we do not obtain an answer that is exactly correct. The answer should
lie close to the truth and will tend to lie closer to the truth the more random numbers we have
used. We will return to this point about accuracy in the next lesson.
You should find, however, that your mean number of burgers ordered is something close to 3.3.
In fact, it is very likely to lie in the range 2.5 to 4.1. This is because the mean of the distribution of
burgers is 3.3 (you can check this if you like) and we would expect our little simulation to give
results similar to what has been observed in the past. There would be something wrong with our
model if it did not! (If you are wondering why you are likely to get a result for the mean in the
range 2.5 to 4.1, then think about confidence intervals. The range 2.5 to 4.1 is a confidence
interval upon the mean of 3.3 for a random sample of size 10 taken from our distribution of burger
orders. So, you are very likely, but not certain, to get a result in this range.)
However, as mentioned, doing this by hand is tedious, especially if we want to simulate what
happens on many, many occasions. So we computerize this process. Spreadsheet software such
as Excel can be used to generate random numbers and, depending upon the number generated,
determine the appropriate number of burgers to which the generated random number
corresponds.
In Excel, typing the expression =Rand() in a cell in a spreadsheet generates a random number in
the range 0 to 1 in that cell. So, for instance, in a spreadsheet in cell A1, typing the expression
=Rand() generates a random number in the range 0 to 1 in cell A1.
To generate a whole series of random numbers in a column, simply copy the =Rand() expression
into the necessary cells in the column.
You can then use an IF statement to determine what value to put in another cell such that the
value is dependent upon the random number that has been generated. These IF statements have
the general form:
=IF(condition, value if condition true, expression or value if condition false).
Examples of IF statements and what they do are given below. In each case it is assumed that cell
A1 contains a random number and that the IF statement is typed in cell B1.
AHA – Lecture 9 7
9.3.3 Back to the burger bar!
Let us return to the example of the burger bar.
9.3.4 Exercise
Use Excel (or your own spreadsheet) to generate a random number in cell A1 (type Rand() in cell
A1). What we are now going to do is to use the IF function in Excel to store a value in cell B1 that
indicates the number of burgers that have been ordered, based on the random number in cell A1.
So, for instance, if the random number in cell A1 is less than 0.10, then we want Excel to put a
figure 1 in cell B1 to indicate that 1 burger is ordered. If the random number in cell A1 is greater
than or equal to 0.10 but less than 0.3, we want Excel to return a value of 2 in cell B1 to indicate
two burgers are ordered and so forth (refer back to the earlier table giving the number of burgers
and real random numbers).
This will return the appropriate number of burgers in cell B1 corresponding to the real random
number generated in cell A1.
AHA – Lecture 9 8
Note that any changes you make to the spreadsheet will result in a new set of random numbers
being generated and a new set of values for the number of burgers and, obviously, a new mean
number of burgers. (If you wish to try this deliberately, then press the F9 key to generate a new
set of random numbers.) As before, you should find that your mean varies around 3.3 but may not
be exactly equal to it. Of course, what we have done here is to simulate only part of what goes on
at the burger bar. In practice we would add additional entities, activities and processes. For
instance we have indicated nothing about the rate at which people arrive at the burger bar to
place an order. Nor have we indicated anything about the time it takes to fulfill an order for a
particular number of burgers or the number of people that are involved in fulfilling these orders
(the number of servers). To get a more complete picture of what is happening we would need to
add in these processes to our simulation. We could consider issues such as whether we should
have a single queue of customers that are served by one of several people once they get to the
head of any queue, or do we have a separate queue for each server. We would also need to
consider aspects such as balking (arriving but failing to join a queue, possibly because it is too
long) and reneging (arriving and starting to queue but then leaving, perhaps because one has
waited long enough). As you can see, even quite a simple scenario starts to become complex
when we consider the different inputs and entities in a system. However, if we capture all these
aspects using a computer simulation, we can then begin to address issues such as what would
happen if we added an extra person to those serving the burgers? How does it affect the time
people wait in the queue? How does it affect the amount of time the servers are standing around
with nothing to do? Answers to these questions can help us to make decisions about the value of
hiring extra servers, for example. You will have an opportunity to build up some (small) simulation
models if you attempt the questions at the end of this lesson. This will introduce you to the idea of
combining several processes together to see the effects of the interaction between them. As
mentioned above, simulation by hand is not practical for anything other than very simple models.
Most simulations are performed on a computer using a simulation language to construct the
model. If you have undertaken the above exercise you will see how easy it is to run the simulation
once the basic model has been set up. Modern simulations tend to be both visual and interactive.
9.3.5 Exercise
The management of company is considering the question of marketing a new product. The
investment or the fixed cost required in the project is Kshs. 5,000. There are three factors which
are uncertain viz. the selling price, variable cost and the annual sales volume. The product has a
life of only one year. The management feels as follows about the various possible levels of these
three factors:
Apply Monte Carlo simulation to assess the average profit from the said investment on the basis
of 25 trials (use the random numbers below). (Hint. Profit = (Price-cost)*(volume) – (Kshs. 5000)
Solution
Step 1: Deduce the random numbers
AHA – Lecture 9 9
Step 2: Allocate the random numbers
Model
No
conceptualization Experimental
Design
Setting of Yes
Problem objectives Model Yes
Verified? Validated? Production runs
formulation and overall translation
project plan and analysis
No
Yes Yes
Data No More runs?
collection
No
Documentation
Implementation and reporting
AHA – Lecture 9 10
9.4.1 Problem Formulation
A statement of the problem
the problem is clearly understood by the simulation analyst
the formulation is clearly understood by the client
Levels of Detail
• Low levels of detail may result in lost of information
and goals cannot be accomplished
Conceptual model • High levels of detail require:
• more time and effort
• longer simulation runs
• more likely to contain errors
Logical model
Coding
9.4.6JAVA,
Model verification
C++, Visual BASIC and validation SIMAN, SIMUL8, ARENA
AHA – Lecture 9 11
Verification: the process of determining if the operational logic is correct.
o Debugging the simulation software
Validation: the process of determining if the model accurately represents the system.
o Comparison of model results with collected data from the real system
Logical model
VERIFICATION
Simulation model
AHA – Lecture 9 12
Visual Interactive Simulation (VIS) was a phrase first introduced in 1976. VIS was a huge
advance for simulation in that previously simulation models tended to be ‘black boxes’ that were
built and used by an expert modeller. The client remained largely ignorant of the inner workings of
the ‘black box’ and so it was difficult for the modeller to establish the credibility of the model with
the client. Once visual animation was introduced into simulations this began to make them more
‘real’. By visual animation, we mean that you see an animated display on the computer screen
when a model actually runs. In our example above it might be a number of burgers being passed
to a customer as a consequence of an order. The computer screen may also show a record of
how many burgers had been ordered each time. Both the model builder and the client can view
the results of the simulation as it progresses. An example of such a screen is included below and
this represents a simulation of calls to a service facility.
Furthermore, the purpose of VIS is not just to provide a portrayal of the model but also to enable
interaction with the simulation as it runs. A simulation is interactive if it can be stopped at any
point to obtain information about what is going on and to change aspects of the model. Thus VIS
consists of two aspects that make it different to traditional simulation:
1. It is visual
An animated display of the running model is capable of showing the following:
Elements moving between locations, for example, people arriving to queue for a burger
or biscuits moving along a conveyor belt towards a packaging machine.
Elements changing state being represented by different colours, for example, a broken or
unoccupied supermarket till is displayed in red and working tills are displayed in green.
Results shown in graphical and tabular forms by making use of time-series, pie charts
and histograms.
2. It is interactive
The simulation is built up as a series of small steps. Runs are carried out at each stage in order to
check that the model performs correctly (for instance, in the burger example we can check that
our simulation produces an average order of 3.3 burgers, or something close to this).
Once the model is complete, experiments can then be conducted by running the simulation. Part
way through a run the model may be interrupted, changes made to the logic and the run
continued. For instance, a lunchtime peak in demand at our burger bar could lead to excessively
AHA – Lecture 9 13
long queues with long waiting times for customers. Interaction with the model means that
additional people serving burgers can be put in place for this peak period and the run continued
to see the effect of undertaking this change. The benefits of the visual and interactive elements
for both the model builder and the client are:
a greater understanding and awareness of the model and the processes involved
improved understanding of the results
a reduction in the credibility gap between the model builder and the client
improved communication about the simulation process between the people involved
simpler model validation (one can see where a model is going wrong)
easier and more appropriate experimentation
the ability to use the simulation as a training tool for operations staff.
AHA – Lecture 9 14
Non Standard (or empirical) distributions. Many mathematical models rely on the use of
theoretical distributions (for example, the normal distribution). Whilst historical data may have
been recorded (for example, on daily demand levels for an item), a mathematical model
requires that this actual data is approximated by a theoretical distribution. A simulation model
may use distributions based on historical data or may use theoretical distributions.
Dynamic and transient effects. Quite often one wants to know more than just the ‘typical’ or
‘average’ behaviour of a system. It becomes necessary to understand how a system behaves
under more extreme conditions (for example, what happens at periods of high demand and
not just what happens when demand is at average levels). Also it may be important to
understand what happens when occasional interruptions or temporary effects occur (for
example, a machine breaks down).
Interaction of random events. A mathematical model does not usually inform you of what
happens when some random event occurs such as a machine breaking down. This is
because the model is usually incapable of indicating what happens as a consequence of the
‘knock on’ effects. A simulation can address these issues.
A final aspect that has not been mentioned previously is explored next.
AHA – Lecture 9 15
However, we shall content ourselves here in this lesson with making use of Excel to illustrate
some of the simulation approaches. There is much more to this subject than buying a simulation
package and learning how to use it. There is also the issue of being able to apply the concepts of
simulation in a scientific manner to a sensible formulation of a problem.
In addition, one needs to make some decision as to how to start the simulation in a typical state
or position. For instance, if part of the simulation involves looking at the amount of an item that is
to be put in some limited storage facility (for example, a warehouse, a silo), then we need to
assume something about the state of the storage facility at the beginning of the simulation. Is it
empty, full or somewhere in between? Finally, we also need to know if the simulation represents
the real situation. Is it producing the correct results?
AHA – Lecture 9 16