You are on page 1of 27

AMA 518 Simulation

Daihai He
Time & Venue: Wed 18:30-21:20, Y302
Ofce Hour: Tuesday 9:00-11:00am, HJ614, or by appointment
Assessment: Examination 60% + Continuous assessment 40%
(Tentatively: Midterm 25% + Assignment 10% + R Lab 5%)
Objectives: To enable students to appreciate the principles and methods of system simu-
lation. Emphasis is placed on the process of translating real-world problems into simula-
tion models, and the model building techniques involved.
Acknowledgement: Drs. Chi-kin Chan and Eugene Lee for lecture notes, with references
to the textbook of Sheldon Ross (Simulation).
1
Keyword Syllabus:
Fundamental of Simulation Models:
Principles of mathematical simulation, advantages and disadvantages of simulation, types
of simulation models, steps in a simulation study.
Discrete-Event Simulation:
General principles, components and organization of a discrete-event simulation model,
simulation examples (e.g. queueing and inventory systems), event scheduling, gathering
summary statistics.
Random Numbers:
Generation of pseudo-random numbers, mid-square method, congruential methods, sta-
tistical tests of randomness.
2
Random Variates:
Generation of randomvariates, inverse transformation method, acceptance-rejection method,
comparison of the methods, generation of random variates of discrete and continuous the-
oretical distributions.
Tactical Planning in Simulation Models:
Starting condition and equilibrium, problem of variability, estimation of population param-
eters, determination of sample size, variance reduction techniques.
Validity and Analysis:
Verication and validation of simulation models, comparisons, appropriate statistical tests,
sensitivity analysis, simulation run statistics, replication of runs, elimination of initial bias,
batch means, and regenerative techniques.
Computer Language for Discrete-Event Simulation:
General-purpose and special-purpose languages (e.g. GPSS, SIMSCRIPT) for simula-
tion, simulation using special-purpose languages, data structures for discrete-event sim-
ulation languages.
3
Fundamental of Simulation Models
A simulation model seeks to duplicate the behaviour of the system under investigation by
studying the interaction among its components. While simulation may offer a way out for
many analytically intractable models, it is not in itself a panacea. There are a considerable
number of pitfalls one may encounter in using simulation. Since simulation is comparable
to analysis by experimentation, one has all the usual problems associated with running
experiments in order to make inuences concerning the real world and must be concerned
with such things as run length, number of replications and statistical signicance. How-
ever, the theory of statistics (including, of course experimental design) can be of help here.
Simulation basically represents a statistical experiment, its results must be interpreted
in terms of the appropriate statistical tests. Unlike the mathematical models represent a
long-run steady state behaviour, its results will reach steady state only after the experi-
ment is repeated a sufciently large number of times. As a result, in order for the output
or the model to be representative of what would be expected in the long run, one must
run the simulation long enough to ensure that steady-state conditions prevail.
4
The nature of simulation allows greater exibility in representing complex systems that
are normally difcult to analyse by standard mathematical models. Although simulation
is a exible technique, the development of a simulation model is both time consuming
and costly, particularly when one is trying to optimize the simulated system. A simulation
model can be considered as consisting of two basic phases: data generation and book-
keeping.
Data generation involves producing representative observations from pre-specied prob-
ability distributions.
Book-keeping deals with updating the system when new events occur, monitoring and
recording the system states as they change, and keeping track of quantities of interest.
5
Discrete-event Simulation
Example 1
Suppose that we wish to simulate a queuing model in which arrivals are Poisson with
mean 3 customers per hour and the service time is either 0.2 hour with probability 0.5 or
0.6 hour with probability 0.5.
Given random numbers: 0.058962 0.673284 0.479909
0.948578 0.613960 0.934123
6
Arrival Event
1. Generate the next arrival, i.e., compute p (following exponential distribution) and add
it to the current simulation time.
2. Does the facility idle?
If Yes, goto step 3.
If No, put the arriving customer in the queue, i.e., increase queue size by 1. Then
goto step 7 (Return).
3. Generate a service time q.
4. Compute the customers departure time = current simulation time +q.
5. Set the status of the facility = busy.
6. Update the idle record of the facility.
7. Return.
7
Departure Event
1. Does the queue empty?
If No, goto step 2.
If Yes, Set the status of the facility = idle Then goto step 6 (Return).
2. Start the rst waiting customer in service, and the reduce queue size by 1.
3. Update waiting time record.
4. Generate a service time q.
5. Compute the customers departure time = current simulation time +q.
6. Return.
8
Example 2
A doctor who has introduced an appointment system for daily consultations has derived
the following information regarding patient punctuality:
Minutes early 3 6%
2 29%
1 41%
On time 12%
Minutes late 1 7%
2 5%
The doctor times his consultations over a period and derives the following frequency dis-
tribution
Minutes 12 10%
13 15%
14 28%
15 34%
16 13%
9
The doctor would like to issue appointments at 15-minute intervals and wishes to have an
idea of his idle time, the patients waiting time, and whether he can complete his appoint-
ments on schedule.
Required:
Given the following series of random numbers:
17 14 50 40 83 13 94 08
49 98 79 51 43 74 90 24
09 21 40 12 46 91 09 05
95 44 52 79 91 53 15 16
simulate sixteen consultations and derive the required information.
10
The given patient punctuality and consultation time frequency distributions are converted
to probability distributions and random numbers are allotted to each level of punctuality
and consultation time (in accordance with the relevant relative probabilities).
Patient punctuality Probability (%) Random numbers allocated
Minutes early: 3 6 00-05
2 29 06-34
1 41 35-75
On time: 12 76-87
Minutes late: 1 7 88-94
2 5 95-99
Consultation time (mins) Probability (%) Random numbers allocated
12 10 00-09
13 15 10-24
14 28 25-52
15 34 53-86
16 13 87-99
11
The given series of random numbers is:
17 14 50 40 83 13 94 08
49 98 79 51 43 74 90 24
09 21 40 12 46 91 09 05
95 44 52 79 91 53 15 16
These are read as pairs and used to determine the patient punctuality and consultation
time for each patient in turn in a simulated period of activity.
12
Consultation Random Arrival Random Consultation Idle Waiting
number number time Start number time End time time
1 17 -2 0 14 13 13 0 2
2 50 14 14 40 14 28 1 0
3 83 30 30 13 13 43 2 0
4 94 46 46 08 12 58 3 0
5 49 59 59 98 16 75 1 0
6 79 75 75 51 14 89 0 0
7 43 89 89 74 15 104 0 0
8 90 106 106 24 13 119 2 0
9 09 118 119 21 13 132 0 1
10 40 134 134 12 13 147 2 0
11 46 149 149 91 16 165 2 0
12 09 163 165 05 12 177 0 2
13 95 182 182 44 14 196 5 0
14 52 194 196 79 15 211 0 2
15 91 211 211 53 15 226 0 0
16 15 223 226 16 13 239 0 3
13
Note: It has been assumed that a base of 0 marks the start of the rst consultation.
Alternatively, it could be assumed that the rst patient is waiting and hence the rst pair
of random numbers would be applied to consultation. A different table would then result.
14
Example 3
A company trading in motor vehicles spares wishes to determine the levels of stock it
should carry for the items in its range. Demand is not certain and there is a lead-time for
stock replenishment. For one item, X, the following information is obtained.
Demand Probability
(units per day)
3 0.1
4 0.25
5 0.25
6 0.3
7 0.1
Holding costs (per unit per day) 0.20
Ordering cost (per order) 5.00
Lead time for replenishment (in days) 3
15
Stock on hand at the beginning of the simulation exercise was 21 units. You are required
to carry out a simulation run over a period of ten days with the objective of evaluating the
following inventory rule; Order 15 units when present inventory plus any outstanding order
falls below 15 units. The sequence of random numbers to be used is 0911518635712998
using the rst number for day one. Your calculation should include the total cost of oper-
ating this inventory rule for eight days.
Solution The purpose of the simulation is to help management to decide the optimum
stock re-ordering policy
Demand (units per day) Probability Random numbers
3 0.1
4 0.25
5 0.25
6 0.3
7 0.1
The model would now show the following pattern of stock holding and costs using the
random number given
16
Stock b/f Random Demand Stock c/f Order Holding Total
Day units number units units Costs Costs Costs
1
2
3
4
5
6
7
8
17
Example 4
In any one day, the price of stock traded on a certain stock exchange can rise, fall or
remain unchanged. It is assumed that the direction of the change today depends upon
what happened to the stock yesterday. The following probabilities are available:
Today
Up Unchanged Down
Up 0.7 0.2 0.1
Yesterday Unchanged 0.3 0.4 0.3
Down 0.1 0.3 0.6
18
Moreover, if the price changes, it changes by the following amounts:
Amount of change (p) Probability
0.5 0.3
1 0.4
1.5 0.2
2 0.05
2.5 0.05
19
Using the numbers digits below, simulate the next 10 days trading on the assumption that
the stock closed yesterday unchanged at 100. Estimate the average daily price.
Random numbers for the direction of changes: 72, 94, 52, 78, 12, 21, 25, 20, 34, 93
Random numbers for the amount of change: 27, 49, 14, 34, 05, 99, 17, 69, 11, 84
20
Advantages
1. As an alternative to analytical methods
It is often possible to simulate without making as many simplications to the model
as an analytical model would would require.
2. As an alternative to real life experiments
Maybe cheaper and it is possible to conduct closely controlled experiments.
3. In communications with management
Easily understandable by management.
21
Decision-making process.
(The simulation proceeds until such a decision is required, the management is
presented with all relevant information and asked to make the decision. This kind
of simulation is often known as a management game, particularly when two or
more people involved in a competitive or collaborative situation.)
4. As a diagnostic tool
Disclose the interactions of various parts of the system.
Identify the bottlenecks and other causes of trouble.
22
Disadvantages
1. Maybe an expensive way of solving the problem. The more easily identiable costs
of a simulation project are:
writing the computer program,
running the simulation: To obtain an estimate of a single parameter may require
many simulation runs. One must run the simulation long enough to ensure that
steady-state conditions prevail.
Collection of data. Much input data may need to be collected for the simulation
and this could involve a costly and elaborate contribution by work study.
2. Simulation is non-optimizing.
A simulation model will only yield estimate of the effects if a given operating policy.
The user needs to propose and test new policies in searching for better solutions
to the problem.
23
Simulation: Descriptive or Normative?
Descriptive models describe the behavior of a system by means of appropriate relation-
ships between variables and parameters. The major use of a descriptive model is for
learning how a given system behaves so that improvements can be made. Simulation
models almost always fall into this category in that they are oriented to answering what
if questions such as what will be the effect on customer waiting time if the number of
servers is reduced from three to two?
Normative (or prescriptive) models embody criteria and the means for determining the
best possible solution to a problem. Whereas a descriptive model is designed to showhow
a system will behave in given circumstances, a normative model attempts to predict how
a system should behave ideally. The basic EOQ model is normative in that it species an
order quantity which minimizes total stock control costs. On a rather larger scale, doctors
can be said to use a normative model of health in treating patients in that they attempt to
prescribe an ideal course of action in response to a particular illness.
24
Exercise
1. (a) Describe the advantages and disadvantages of using simulation to investigate
queue ing situations compared with the use of queuing theory formulae.
(b) The time between arrivals at a complaints counter in a large department store
has been observed to follow the distribution shown below:
Time between arrivals (minutes) Probability
0 - 4 0.25
4 - 8 0.45
8 - 12 0.20
12 - 16 0.10
Customers complaints are handled by a single complaints ofcer, but all cus-
tomers who consider their complaints to be serious or who have to wait ve
minutes or more before being served by the complaints ofcer demand to see
the store manager directly, who deals with them separately. The time to deal with
complaints by the complaints ofcer has a mean of seven minutes and a standard
25
deviation of two minutes with the following probability distribution:
No. of standard deviation from mean Probability
-2.5 0.02
-2.0 0.03
-1.5 0.06
-1.0 0.11
-0.5 0.17
0.0 0.22
+0.5 0.17
+1.0 0.11
+1.5 0.06
+2.0 0.03
+2.5 0.02
Furthermore, the probability distribution for whether a complaint is serious is esti mated
as follows:
Complaint Probability
Serious 0.2
Non-serious 0.8
26
i. Use the following random digits to simulate the handling of ten complaining cus-
tomers, some of whom may have serious complaints.
Interarrival time (IAT): 09 06 51 62 83 61 59 20 82 68
Serious complaint: 5 0 7 3 8 2 9 8 1 6
Service time: 39 60 50 31 02 02 83 90 71 16
Use your simulation to estimate the proportion of customers who eventually see the
store manager. Hence estimate the average total amount per day that the store man-
ager spends dealing with complaints, assuming an eight hour day and that the time
he spends per complaint also has a mean of 7 minutes.
ii. Explain briey how to use simulation to decide if it would be worth while em ploying
an additional complaints ofcer.
27

You might also like