Вы находитесь на странице: 1из 75

SIMULATION & MODELLING

Mupondo Ndava Constantine

NATIONAL UNIVERSITY OF SCIENCE AND TECHNOLOGY


constantine.mupondo@nust.ac.zw

February 19, 2018

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 1 / 75


Contents

Introduction
Modelling & Simulation Basics
Modelling
Simulation & Experimentation
Hand Simulation & Queuing Systems
Simulation Programming Languages
Simulation Environment- ARENA
Statistical Models in Simulation
Random number generation
Input Modelling
Verification & Validation of Simulation Models
References

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 2 / 75


Introduction

What is simulation?
to feign; to have or to assume a false appearance of; to mimic; to
recreate conditions of, for the purpose of training or experimentation.
simulation is an activity whereby one can draw conclusions about the
behaviour of a given system by studying the behaviour of a system
whose cause and effect relationships an the same as (or similar to)
those of the original.
simulation modelling is an experimental and applied methodology
that seeks to accomplish the following:
describe the behaviour of systems
construct theories or hypothesis that account for the observed
behaviour
use the model to predict future behaviour that is the effects produced
by changes in the system or in its method of operation

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 3 / 75


Types of models

A Model is defined as a representation of a system for the purpose of


studying the system.
Physical models - Scale models of the actual system. They are
static and do not show interactions. Highly specific and cannot be
easily altered
Mathematical models - Uses equations to represent important
factors of a system
Conceptual models - Concepts and beliefs in the analysts mind

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 4 / 75


Classification of methods
Prescriptive or Descriptive - Prescriptive models are those in which
a problem is analytically formulated and optimised to give a best
solution. Merely describe the system behaviour with the optimisation
process left to the analyst.
Discrete or Continuous - The discrete event or continuous
classification refers to the model variables. Discrete event simulation
products are used for modelling systems that change state at discrete
points in time as a result of specific events.
Stochastic or Deterministic - The difference between stochastic
and deterministic models is on the model variables. Models that are
based on one or more variables that are random in nature are referred
to as stochastic models.
Static or Dynamic - Models are classified as either static or dynamic
depending on whether or not the model variables change over time. In
this study the aim is to study the effect of loading on the performance
of MRP system, this implies a variation of loading (queue length) as
model execution progresses. The model is therefore dynamicA
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 5 / 75
Steps in a Simulation Study

Figure: Simulation Steps

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 6 / 75


Process of Making Decisions
Simulation is a tool to assist the making decision making process.
Intuitive - Decision based on past experience.
- Can often be difficulty as the size and level of complexity in the
system increases.
- Can lead to expensive mistakes being made.
Analytical - Where time and understanding allows a scientific
analysis can sometimes be justified. This often the case when cost of
a mistake is high. Precise mathematical formulation is required.
Experimental - Experimentation on the real system is.
Impractical - we need to be able to control the experiment, but it is
very difficult to do this on the shop floor. Time scales are inadequate,
an experiment might take months to complete.
Expensive - One cannot purchase equipment simply on the wish to
evaluate whether it is needed or not. One cannot hire labour without
training them and paying them, and this is expensive if they are
subsequently found not to be required.
Disruptive - A company must still satisfy existing customers and can
only do this by continuing to operate normally. This is difficult if
Mupondo Ndava resources are taken awayTEACHING
Constantine (NUST) to perform
NOTESan experiment, or if layouts
February 19, 2018are 7 / 75
We Need A Model Of Real System

The Simulation approach is an experimental approach. It allows the user to


conduct TRIAL & ERROR experiments. In order to conduct a simulation
requires the use of a MODEL: A logical representation (on a computer) of
the operation of the system and the uncertainty to which it is subjected.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 8 / 75


Operations

Activities: Start Cycle


Conditions: - In working order - Machine idle - Set-up for job
States: - Machine busy (change as a result of start cycle)Start Cycle
Duration: - Time
Change of State at end: - Machine idle
NOTE: IT IS THE RESOURCE THAT LINK THE ACTIVITIES
IN A SYSTEM

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 9 / 75


Uncertainty

Uncertainty is evident in many of the operations of a manufacturing


system. Uncertainty is a major cause of poor performance. Factors
involving uncertainty
Labour absenteeism
Demand pattern for products
Machine availability
Process variation
Any good simulation system should support the user by providing a means
of representing uncertainty. In most cases this is achieved by sampling
from statistical distributions

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 10 / 75


Sampling

Sampling is the method by which a random selection of values


representing the expected pattern of a variable can be made.The
distribution most often used are:
NORMAL.
NEGATIVE EXPONENTIAL
UNIFORM.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 11 / 75


Benefits Of The Simulation Approach

Better utilisation of resources


Feasibility studies can be carried out
Improved understanding of the system behaviour
Confidence in decisions taken Improved communication of objectives
and constraints
Training tool

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 12 / 75


When is Simulation the Appropriate Tool?
Simulation enables the study of, and experimentation with, the
internal interactions of a complex system, or of a subsystem within a
complex system.
Informational, organizational and environmental changes can be
simulated and the effect of these alterations on the models behaviour
can be observed.
The knowledge gained in designing a simulation model may be of
great value toward suggesting improvement in the system under
investigation.
By changing simulation inputs and observing the resulting outputs,
valuable insight may be obtained into which variables are most
important and how variables interact.
Simulation can be used as a pedagogical device to reinforce analytic
solution methodologies.
Simulation can be used to experiment with new designs or policies
prior to implementation, so as to prepare for what may happen.
Simulation can be used to verify analytic solutions.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 13 / 75
Advantages of Simulation
New policies, operating procedures, decision rules, information flows,
organizational procedures, and so on can be explored without
disrupting ongoing operations of the real system.
New hardware designs, physical layouts, transportation systems, and
so on, can be tested without committing resources for their
acquisition.
Hypotheses about how or why certain phenomena occur can be tested
for feasibility.
Time can be compressed or expanded allowing for a speed up or slow
down of the phenomena under investigation.
Insight can be obtained about the interaction of variables.
Insight can be obtained about the importance of variables on the
performance of the system.
Bottleneck analysis can be performed indicating where work in
process, information, materials, and so on are being excessively
delayed.
A simulation study can help in understanding how the system
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 14 / 75
Disadvantages of Simulation
Model building requires special training. It is an art that is learned
over time and through experience. Furthermore, if two models are
constructed by two competent individuals, they may have similarities,
but it is highly unlikely that they will be the same.
Simulation results may be difficult to interpret. Since most simulation
outputs are .essentially random variables (they are usually based on
random inputs), it may be hard to determine whether an observation
is a result of system interrelationships or randomness.
Simulation modelling and analysis can be time consuming and
expensive. Skimping on resources for modelling and analysis may
result in a simulation model or analysis that is not sufficient for the
task.
Simulation is used in some cases when an analytical solution is
possible, or even preferable. This is particularly true in the simulation
of some waiting lines where closed-form queueing models are
available.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 15 / 75
Areas of Application

Manufacturing systems
Health care
Military
Natural resources
Transportation systems
Construction systems
Restaurant and entertainment systems
Business process reengineering
Food processing
Computer system performance

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 16 / 75


2. Modelling And Simulation Basics

THE OBJECTS OF A SYSTEM


System- is a group of objects that are joined together in some regular
interaction or interdependence toward the accomplishment of some
purpose e.g. production system manufacturing automobiles (machines,
components parts and workers operate jointly along an assembly line to
produce a high-quality vehicle)
ENTITIES - These are the elements of the system being simulated and
can be individually identified and processed;
Machines in a factory
Jobs waiting to be processed
Vehicles
People
or ANYTHING else that changes STATE as a simulated system
proceeds

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 17 / 75


ATTRIBUTES, Sets
Attributes are used to describe an entity in greater detail, to convey some
specific information about it or is a property of an entity e.g. The Class
Body may have an ATTRIBUTE called Doors which describes whether it
has 3, 4 or 5 doors.
Attributes may be used for many varied purposes:
Determining a queue position based on some queuing discipline ie.
FIFO, LIFO, Sorted
Specifying a priority
Controlling the behaviour of an object e.g. the payload of an aircraft
may affect the size of runway that it can use
SETS
Sets can represent a classification of STATES that an entity(s) may pass
through e.g. Car bodies leaving a Paint Shop may either
Bad paint (needing rectification)
or Good (ready for next operation)
These two States can be represented as sets and these sets can contain a
dynamic quantity of entities Often sets can be thought of as QUEUES
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 18 / 75
Terms

EVENT - An INSTANT in time when a change of state takes place


of one or more entities. e.g. Machine finishes cycle, part enters buffer
PROCESS - A sequence of events through which an entity passes,
usually in chronological order. A process can represent all or some of
the LIFE CYCLE of an entity (usually a temporary entity)
SIMUALTION CLOCK. (The Clock) - This is the value of
simulated time
System - A collection of entities (eg people and machines) that
interact together over time to accomplish one or more goals Model -
An abstract representation of a system, usually containing structural,
logical or mathematical relationships which describe a system in terms
of state, entities and their attributes, sets, processed, events,
activities, and delays
System State - A collection of variables that contain all the
information necessary to describe the system at any time
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 19 / 75
Terms (Continued)

Entity - Any object or component in the system which requires


explicit representation in the model ( eg server, a customer, a
machine)
Attributes - The properties of a given entity (eg priority of a waiting
customer, routing of a job through a job shop)
List - A collection of (permanent or temporarily) associated entities,
ordered in some logical fashion (such as all customers currently in a
waiting line, ordered by first come, first served or by priority)
Event - An instantaneous occurrence that changes the state of a
system ( such as an arrival of a new customer)
Event Notice - A record of an event to occur at the current or some
future time along with any associated data necessary to execute the
event; at a minimum, record includes the event type and event time
Event list - A list of event notices for future events, ordered by time
of occurrence; also known as the future event list (FEL)
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 20 / 75
THE LIFE CYCLE OF AN ENTITY.

Figure: LIFE CYCLE DIAGRAM

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 21 / 75


THE OBJECTS OF A SYSTEM
System- is a group of objects that are joined together in some regular
interaction or interdependence toward the accomplishment of some
purpose e.g. production system manufacturing automobiles (machines,
components parts and workers operate jointly along an assembly line to
produce a high-quality vehicle)
ENTITIES - These are the elements of the system being simulated and
can be individually identified and processed;
Machines in a factory
Jobs waiting to be processed
Vehicles
People
or ANYTHING else that changes STATE as a simulated system
proceeds

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 22 / 75


4.0 MODELLING
The activity cycle diagram (ACD) is formed from the combination of
individual life cycle diagrams. The details of combination represent the
logic of entity interaction.
RULES & CONVENTIONS IN ACDs.
Queues and Activities must Alternate
The diagram must be closed loop
Queues are represented diagrammatically by circles.
Activities are represented diagrammatically by rectangles.
The direction of the life cycle sequence is represented with a directed
arrow.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 23 / 75


Problem 1
There are three machines and one mechanic. When any one of the
machines is broken down it is repaired by the mechanic. After repair the
machine runs until it breaks down again.
The company involved, wants to determine the average waiting time of
the machine before it is repaired and the percentage of time the mechanic
is idle. The objective of such an exercise may be to determine if the
mechanic could be put in charge of a fourth machine (or conversely there
is a need for a second mechanic).
Specify a model using an activity cycle diagram.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 24 / 75


THE LIFE CYCLE OF AN ENTITY.

Figure: Mechine

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 25 / 75


THE LIFE CYCLE OF AN ENTITY.

Figure: Mechanic

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 26 / 75


Problem 2
As an extension to the previous machine maintenance problem (Problem
1), suppose that the repair of a machine can be broken down into the
following activities:-
An electrician disconnects the supply.
A sub-contractor removes/re-sites the machine.
A fitter repairs the machine.
There is one mechanic, one fitter and three persons in the sub-contracting
team.
Draw the Activity Cycle diagram for this system.
The following priority rules are applied:
Reconnection of the electricity supply has priority over disconnection.
Re-siting a machine is more important than removal.
How can these priorities be reflected in the Activity cycle diagram?
There is a shortage of floor space and only two machines can be
removed from their mountings at any one time. How can this be
represented on the Activity Cycle Diagram?
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 27 / 75
IMPLEMENTATION ON A COMPUTER
The ACD is one formalism for representing the logic of entity interaction
in a discrete event system.
It in effective when the system comprises alternating queues and activities.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 28 / 75


BENEFITS OF THE ACTIVITY CYCLE DIAGRAM
The logic of the system operation is clearly represented.
It provides a focus for discussion and understanding.
All the entities are identified.
The interactions between entities is explicitly stated.
The inputs and outputs of the system can be identified.
The logic of the model is documented for future reference
The model can be maintained, it can be developed
It helps control the development for complex models.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 29 / 75


SIMULATION AND EXPERIMENTATION
THE THREE PHASE APPROACH
START PHASE For each activity in turn test to see if it can start. If
it can, move all participating entities from their respective queues into
the activity and determine the time it will end.
TIME PHASE Advance the simulation clock time to the earliest
activity end time. This is known as the A phase.
END PHASE End all activities due to end at the current Simulation
Clock time and send all participating entities to their destination
queues. This is also known as the Bound or B phase, because these
activities are bound to end at this time. The activities had
determinate duration.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 30 / 75


SAMPLING
Many systems behave stochastically (governed by probability) and must
therefore before simulated by a model with stochastic elements.
PROBABILITY DISTRIBUTIONS
To illustrate the concept of a probability distribution, consider the
historical data relating to the breakdown of a particular machine.
Days since last Number of Prob. Of 2 Cumulative failure
repaired observations failure probabilities
1 5 .05 .05
2 15 .15 .2
3 20 .20 .4
4 30 .30 .7
5 20 .20 .9
6 10 .10 1
Development gran data

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 31 / 75


RANDOM SAMPLING
There are two requirements for random sampling in discrete event
simulation.
A sequence of random numbers in the range 0 to 1. Random Number
Stream
A method of converting these into samples from an appropriate
distribution
PSEUDO RANDOM NUMBER GENERATOR SEED

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 32 / 75


5.0 HAND SIMULATION OF QUEUIND SYSTEMS
Simulation of Queuing Systems
A queuing system is described by its calling population, the nature of the
arrivals and services, the system capacity and the queueing discipline.

Figure: Queuing systems

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 33 / 75


5.0 HAND SIMULATION OF QUEUIND SYSTEMS

In this system the calling population is infinite i.e. if a unit leaves the
calling population and joins the waiting line or enters service there is
no change in the arrival rate of other units that may need service
System arrivals for service occur one at a time in a random fashion
and 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 overtime.
In addition, the system capacity is unlimited.
Callers are served in the order of their arrival (FIFO) by a single server
or channel.
Arrivals and services are described by the distributions of time
between arrivals and service times.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 34 / 75


5.0 HAND SIMULATION OF QUEUIND SYSTEMS

Table 5.2 contains a set of five inter-arrival times generated from rolling a
die five times and recording the up face. These are used to compute the
arrival times of six customers at the queuing system.
Table 5.2:Interarrival and clock times.
Customer Interarrival Time Arrival Time on Clock
1 - 0
2 2 2
3 4 6
4 1 7
5 2 9
6 6 15

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 35 / 75


5.0 HAND SIMULATION OF QUEUIND SYSTEMS

Customer Service Time


1 2
2 1
Table 5.3:Service time. 3 3
4 2
5 1
6 4

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 36 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

Table 5.4:Simulation table emphasizing clock time.


Customer Arrival Time Time Service Service Time Time Service
Number (Clock) Begins(Clock) (Duration) Ends(Clock)
1 - 0 2 2
2 2 2 1 3
3 6 6 3 9
4 7 9 2 11
5 9 11 1 12
6 15 15 4 19

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 37 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

5.5 Chronological Ordering of Events


Event type Customer Number Clock Time
Arr 1 0
Dep 1 2
Arr 2 2
Dep 2 3
Arr 3 6
Arr 4 7
Dep 3 9
Arr 5 9
Dep 4 11
Dep 5 12
Arr 6 15
Dep 6 19

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 38 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

Figure 5.6 depicts the number of customers in the system at the


various clock times

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 39 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

Example 5.1: Single Channel Queue


A small grocery store has only one checkout counter. Customers arrive at
this checkout counter at random from 1 to 8 minutes apart. Each possible
value of inter arrival time has the same probability of occurrence.
Time between Probability Cumulative Random Digit
Arrivals (min) Probability Assignment
1 0.125 0.125 001-125
2 0.125 0.250 126-250
3 0.125 0.375 251-375
4 0.125 0.500 376-500
5 0.125 0.625 501-625
6 0.125 0.750 626-750
7 0.1255 0.875 751-875
8 0.125 1.000 876-000

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 40 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

The service times vary from 1 to 6 min with the probabilities shown in
Table 5.7
Table 5.7: Service Time Distribution
Service Probability Cumulative Random Digit
Times (min) Probability Assignment
1 0.10 0.10 01-10
2 0.20 0.30 11-30
3 0.30 0.60 31-60
4 0.25 0.85 61-85
5 0.10 0.95 86-95
6 0.05 1.00 96-00

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 41 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

Table 5.8: Time-between-arrival determination


Cust Rand Tim btwn Cust Random Time btwn
Dig Arr Digits arr
1 - - 11 109 1
2 913 8 12 093 1
3 727 6 13 607 5
4 015 1 14 738 6
5 948 8 15 359 3
6 309 3 16 888 8
7 922 8 17 106 1
8 753 7 18 212 2
9 235 2 19 493 4
10 103 3 20 535 5

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 42 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS

Table 5.9: Service Times Generated


Cust Rand Serv Cust Random Servi
Dig Time Digits Time
1 84 4 11 32 3
2 10 1 12 94 5
3 74 4 13 79 4
4 53 3 14 05 1
5 17 2 15 79 4
6 79 4 16 84 4
7 91 5 17 52 3
8 67 4 18 55 3
9 89 5 19 30 2
10 38 3 20 50 3

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 43 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS
Table 6.0:
Cust Time Arr Serv Time Time Time Time Serv
Sinc Time Time Serv Cust Serv in idle
Last Beg Wait ends Syst Time
Arr que
1 - 0 4 0 0 4 4 0
2 8 8 1 8 0 9 1 4
3 6 14 4 14 0 18 4 5
4 1 15 3 18 3 21 6 0
5 8 23 2 23 0 25 2 2
6 3 26 4 26 0 30 4 1
7 8 34 5 34 0 39 5 4
8 7 41 4 41 0 45 4 2
9 2 43 5 45 2 50 7 0
- - - - - - - - -
20 5 82 3 83 1 86 4 0
Total 68 56 124 18
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 44 / 75
5.0 HAND SIMULATION OF QUEUING SYSTEMS
Example 5.2: The Able Baker Carhop Problem
Purpose to indicate simulation procedure when there is more than one
channel. Consider a drive-in restaurant where carhops take orders and
bring food to the car. Cars arrive in the manner shown in Table 5.11.
There are two carhops. Able and Baker. Able is better to do the job and
works some what faster than Baker. A simplifying rule is that Able gets
the customer if both carhops are idle. The problem is to find how well the
current arrangement is working. To estimate the system measures. A
simulation of 1 hour-of operation will be used.
Table 5.11: Interarrival Distribution Cars
Time between Probability Cumulative Random Digit
Arrivals (min) Probability Assignment
1 0.25 0.25 01-25
2 0.40 0.65 26-65
3 0.20 0.85 66-85
4 0.15 1.00 84-00
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 45 / 75
5.0 HAND SIMULATION OF QUEUING SYSTEMS

Table 5.12: Service Distribution of Able


Service Probability Cumulative Random Digit
Times (min) Probability Assignment

2 0.30 0.30 01-30


3 0.28 0.58 31-58
4 0.25 0.83 59-83
5 0.17 1.00 84-00
Table 5.13: Service Distribution of Baker
Service Probability Cumulative Random Digit
Times (min) Probability Assignment

3 0.35 0.35 01-35


4 0.25 0.60 36-60
5 0.20 0.80 61-80
5 0.20 1.00 81-00

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 46 / 75


5.0 HAND SIMULATION OF QUEUING SYSTEMS
Table 5.14 Simulation Table for Carhop Example.
Able Baker
Cu Ran Tm Clk Ran Tim Sev Tim Tim Sev Tim
No. Dig Bet Tim Dig sev Tim Sev Tim sev in
for Arr of for beg end Beg end
Arr Arr sev que
1 - - 0 95 0 5 5
2 26 2 2 21 2 3 5
3 28 4 6 51 6 3 9
4 90 4 10 92 10 5 15
5 26 2 22 89 12 6 18
6 42 2 14 38 15 3 18
7 74 3 17 13 18 2 20
8 80 3 20 61 20 4 24
9 68 3 23 50 23 4 27
- - - - - - - - - - -
26 92 4 59 47 59 3 62
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 47 / 75
8.0 Statistical Models in Simulation

Discrete Random Variables


Continuous Random Variables
8.1.4 ExpectationP
Discrete E (X ) = xRi p(xi )
Continuous E (X ) = xi p(xi )

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 48 / 75


9.0 RANDOM NUMBER GENERATION
9.1 Properties of Random Numbers
The numbers produced should appear to be distributed uniformly on
[0, 1] and should NOT exhibit any correlation with each other thus
independent from one other.
The generator should be fast and does not need a lot of storage.
The random number stream should be repeatable.
The generator should be able to generate separate streams of random
numbers.
9.2 Departures from ideal randomness
The generated numbers may not be uniformly distributed.
The generated numbers may be discrete-valued instead of
continuous-valued.
The mean of the generated numbers may be too high or too low.
The variance of the generated numbers may be too high or too low.
There may be cyclic variations. The following are examples:
Autocorrelation between numbers.
Numbers successively higher or lower than adjacent numbers.
Mupondo Ndava Several
Constantine numbers
(NUST) above the meanNOTES
TEACHING followed by several February
numbers below49 / 75
19, 2018
9.0 RANDOM NUMBER GENERATION

9.3 Techniques for Generating Random Numbers


9.3.1 Generate by hand
Casting lots
Throwing dice
Dealing out cards
Drawing numbered balls
Picking numbers from phone books
9.3.2 Generate using devices
Rapidly spinning disks
Electric circuits
9.3.3 Generate using numerical algorithms
von Neumann and Metropolis method
Linear Congruential Generator

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 50 / 75


9.0 RANDOM NUMBER GENERATION

9.3.3 Generate using numerical algorithms


Linear Congruential Generator
Produces a sequence of integers X1 , X2 , between zero and m − 1
according to the following recursive relationship:
Xi+1 = (aXi + c)mod m, i = 1, 2, 3, ...
X0 the seed, a is the constant multiplier, c is the increment and m is
the modulus
If c 6= 0 it is called Congruential method
If c = 0 it is called the multiplicative Congruential method
The random numbers between zero and 1 can be generated by
Ri = Xmi , i = 1, 2, ...
I0 = 9, a = 8, c = 5, m = 25 − 1

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 51 / 75


9.0 RANDOM NUMBER GENERATION

Pk j−1 X

Xi = j=1 (−1) ij , mod m1 − 1,
Quadratic Congruential Generator
Composite Generator
Taueworthe s methods

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 52 / 75


9.0 RANDOM NUMBER GENERATION
9.4 Tests for Random Numbers
Frequency test. Uses the Kolmogorov-Smirnov or the chi-square test
to compare the distribution of the set of numbers generated to a
uniform distribution.
Runs test. Tests the runs up and down or the runs above and below
the mean by comparing the actual values to expected values. The
statistic for comparison is the chi-square.
Autocorrelation test. Tests the correlation between numbers and
compares the sample correlation to the expected correlation of zero.
Gap test. Counts the number of digits that appear between
repetitions of a particular digit and then uses the
Kolmogorov-Smirnov test to compare with the expected size of gaps.
Poker test. Treats numbers grouped together as a poker hand. Then
the hands obtained are compared to what is expected using the
chi-square test.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 53 / 75
9.0 RANDOM NUMBER GENERATION
9.4.1.1. The Kolmogorov-Smirnov test.
Frequency test. Uses the Kolmogorov-Smirnov or the chi-square test
to compare the distribution of the set of numbers generated to a
uniform distribution.
Runs test. Tests the runs up and down or the runs above and below
the mean by comparing the actual values to expected values. The
statistic for comparison is the chi-square.
Autocorrelation test. Tests the correlation between numbers and
compares the sample correlation to the expected correlation of zero.
Gap test. Counts the number of digits that appear between
repetitions of a particular digit and then uses the
Kolmogorov-Smirnov test to compare with the expected size of gaps.
Poker test. Treats numbers grouped together as a poker hand. Then
the hands obtained are compared to what is expected using the
chi-square test.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 54 / 75
9.0 RANDOM NUMBER GENERATION
9.4.1 Frequency Tests
Used in testing for independence
This test compares the continuous cdf, F(x), of the uniform
distribution to the empirical cdf, SN(x), of the sample of N
observations.
The Kolmogorov-Smirnov test is based on the largest absolute
deviation between F(x) and SN(x) over the range of the random
variable. That is, it is based on the statistic
The sampling distribution of D is known and is tabulated as a
function of N in Table for Kolmogorov-Smirnov critical value. For
testing against a uniform cdf, the test procedure follows these steps;
Step 1. Rank the data from smallest to largest. Let R = i, denote the
i th smallest observation, so that R1 ≤ R2 ≤ .... ≤ RN
Step 2. Compute
D+ = max i

1≤i≤N N
− Ri
D− = max
Ri − i−1

1≤i≤N N

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 55 / 75


9.0 RANDOM NUMBER GENERATION

9.4.1 Frequency Tests


Step 3. Compute D = max(D + , D − ).
Step 4. Determine the critical value, Dalpha , from
Kolmogorov-Smirnov Table for the specified significance level α and
the given sample size N.
If the sample statistic Dalpha is greater than the critical value, Dalpha ,
the null hypothesis that the data are a sample from a uniform
distribution is rejected. If D ≤ Dalpha , conclude that no difference has
been detected between the true distribution of (R1 , R2 , ..., RN ) and
the uniform distribution.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 56 / 75


9.0 RANDOM NUMBER GENERATION
EXAMPLE 9.6
Suppose that the five numbers 0.44, 0.81, 0.14, 0.05, 0.93 were generated
and it is desired to perform a test for uniformity using the
Kolmogorov-Smirnov test with a level of significance of 0.05.
Table 8.2. CALCULATIONS FOR KOLMOGOROV-SMIRNOV
TEST
Ri 0.05 0.14 0.44 0.81 0.93
i
N 0.20 0.40 0.60 0.80 0.1.00
i
N − R i 0.15 0.26 0.16 - 0.07
i−1
Ri − N 0.05 0.04 0.21 0.13
The computations for D + and D − , are easily accomplished using
Table 8.2.
The statistics are computed as D + = 0.26 and D − = 0.21.
Therefore, D = max0.26, 0.21 = 0.26.
The critical value of D, obtained from Table A. 8 for α = 0.05 and N
= 5,is 0.565.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 57 / 75
9.0 RANDOM NUMBER GENERATION
EXAMPLE 9.6
Since the computed value, 0.26, is less than the tabulated critical
value, 0.565, the hypothesis of no difference between the distribution
of the generated numbers and the uniform distribution is not rejected
9.4.1.2 The chi-square Test 2
2
Pn Oi −Ei
The chi-square test uses the sample static χ0 = i−1 Ei
0.34 0.90 0.25 0.89 0.87 0.44 0.12 0.21 0.46 0.67
0.83 0.76 0.79 0.64 0.70 0.81 0.94 0.74 0.22 0.74
0.96 0.99 0.77 0.67 0.56 0.41 0.52 0.73 0.99 0.02
0.47 0.30 0.17 0.82 0.56 0.05 0.45 0.31 0.78 0.05
0.79 0.71 0.23 0.19 0.82 0.93 0.65 0.37 0.39 0.42
0.99 0.17 0.99 0.46 0.05 0.66 0.10 0.42 0.18 0.49
0.37 0.51 0.54 0.01 0.81 0.28 0.69 0.34 0.75 0.49
0.72 0.43 0.56 0.97 0.30 0.94 0.96 0.58 0.73 0.05
0.06 0.39 0.84 0.24 0.40 0.64 0.40 0.19 0.79 0.62
0.18 0.26 0.97 0.88 0.64 0.47 0.60 0.11 0.29 0.78
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 58 / 75
9.0 RANDOM NUMBER GENERATION
EXAMPLE 9.7
(Oi −Ei )2
Interval Oi Ei Ei
1 8 10 0.4
2 8 10 0.4
3 10 10 0.0
4 9 10 0.1
5 12 10 0.4
6 8 10 0.4
7 10 10 0.0
8 14 10 1.6
9 10 10 0.0
10 11 10 0.1
3.4
The value of χ0 is 3.4. This is compared with the critical value χ20.05,9
2

= 16.9. Since χ20 is much smaller than the tabulated value of χ20.05,9 ,
the null hypothesis of no difference between the sample distribution
and the uniform distribution
Mupondo Ndava Constantine (NUST)
is not rejected.
TEACHING NOTES February 19, 2018 59 / 75
9.0 RANDOM NUMBER GENERATION

9.4.2 Runs Tests 9.4.2.1 Runs up and runs down.


2N−1
µa = 3
16N−29
σa2 = 90
a−[(2N−1)/3]
Z0 = √
(16N−29)/90
where a is the total number of runs in a truly random sequence
EXAMPLE 9..8
Based on runs up and runs down, determine whether the following
sequence of 40 numbers is such that the hypothesis of independence can
be rejected where α = 0.05.
0.41 0.68 0.89 0.94 0.74 0.91 0.55 0.62 0.36 0.27
0.19 0.72 0.75 0.08 0.54 0.02 0.01 0.36 0.16 0.28
0.18 0.01 0.95 0.69 0.18 0.47 0.23 0.32 0.82 0.53
0.31 0.42 0.73 0.04 0.83 0.45 0.13 0.57 0.63 0.29

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 60 / 75


9.0 RANDOM NUMBER GENERATION

9.4.2 Runs Tests 9.4.2.1 Runs up and runs down.


The sequence of runs up and down is as follows:
+++-+-+---++-+--+-+--+--+-++--++-+
--++-
There are 26 runs in this sequence. With N = 40 and a =26
2(40)−1
µa = 3 = 26.33
16(40)−29
σa2 = 90 = 6.79
√26−26.33
Z0 = = −0.13
6.79)/90

Now, the critical value is Z0.025 = 1.96, so the independence of the


numbers cannot be rejected on the basis of this test.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 61 / 75


9.0 RANDOM NUMBER GENERATION

9.4.2.2. Runs above and below the mean.


The test for runs up and runs down is not completely adequate to assess
the independence of a group of numbers
Let n1 and n2 be the number of individual observations above and
below the mean and let b the total number of runs .
Notice that the maximum number of runs is N = n1 + n2 and the
minimum number of runs is one.
2n1 n2 1
µb = N3 + 2
2n1 n2 (2n1 n2 −N)
σb2 = N 2 (N−1)
b−(2n1 n2 /N)−1/2
Z0 =  2n 1/2
1 n2 (2n1n2−N)
N 2 (N−1)

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 62 / 75


9.0 RANDOM NUMBER GENERATION
9.4.2.2. Runs above and below the mean.
EXAMPLE 9.9
Determine whether there is an excessive number of runs above or below
the mean for the sequence of numbers given in Example 9.8. The
assignment of +’s and ”s results in the following:
-+++++++---++-+-------++----++--+-+--
++-
The values of n1 , n2 and b are as follows:
n1 = 18 n2 = 22 N = n1 + n2 = 40 b = 17
Let n1 and n2 be the number of individual observations above and
below the mean and let b the total number of runs .
Notice that the maximum number of runs is N = n1 + n2 and the
minimum number of runs is one.
2(18)(22)
µb = 40 + 12 = 20.3
2(18)(22){2(18)(22)−40)}
σb2 = 402 (40−1)
= 9.54
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 63 / 75
9.0 RANDOM NUMBER GENERATION

9.4.2.2. Runs above and below the mean.


EXAMPLE 9.9
Since n2 is greater than 20, the normal a approximation is acceptable,
resulting in a Z0 ,value of:
Z0 = 17−20.3 = −1.07
9.54]1/2

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 64 / 75


9.0 RANDOM NUMBER GENERATION

9.4.3 Tests for Autocorrelation


The tests for autocorrelation are concerned with the dependence between
numbers in a sequence.
The test to be described below requires the computation of the
autocorrelation between every m numbers
Thus, the autocorrelation ρim between the following numbers would
be of interest: Ri , RI +M ; Ri+2m , Ri+(M+1)m .
The value M is the largest integer such that i + (M + 1)m ≤ N.
where N is the total number of values in the sequence.
ρbim
Z0 = σ−b ρim
1
 PM 
ρbim = M+1 k=0 Ri+km Ri+(k+1)m − 0.25

13M+7
σρbim = 12(M+1)

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 65 / 75


9.0 RANDOM NUMBER GENERATION

EXAMPLE 9.12
Test whether the 3rd , 8th , 13th and so on, numbers in the sequence at the
beginning of this section are autocorrelated. (Use α = 0.05.) Here, i = 3
(beginning with the third number), m = 5 (every five numbers), N = 30
(30 numbers in tie sequence), and M = 4 (largest integer such that 3 +
(M + 1)5 30). Then,
1

ρbim = 4+1 (0.23)(0.28) + (0.28)(0.33) + (0.33)(0.27) +
(0.27)(0.05) + (0.05)(0.36)] − 0.25 = −0.1945

13(4)+7
σρbim = 12(4+1) = 0.1280
Then, the test statistics assumes the value
−0.1945
Z0 = 0.1280 = −1.516
Now. the critical value is Z0.025 = 1.96
Therefore, the hypothesis of independence cannot be rejected on the
basis of this test.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 66 / 75
10.0 INPUT MODELLING
There are four steps in the development of a useful model of input data:
Collect data from the real system of interest. This often requires a
substantial time and resource commitment. Unfortunately, in some
situations it is not possible to collect data (for example, when time is
extremely limited, when the input process does not yet exist, or when
laws or rules prohibit the collection of data). When data are not
available, expert opinion and knowledge of the process must be used
to make educated guesses.
Identify a probability distribution to represent the input process.
When data are available, this step typically begins by developing a
frequency distribution. or histogram, of the data. Based on the
frequency distribution and structural knowledge of the process, a
family of distributions is chosen. Fortunately, as described in Chapter
6, several well-known distributions often provide good approximations
in practice.
Choose parameters that determine a specific instance of the
distribution family. When data are available these parameters may be
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 67 / 75
10.0 INPUT MODELLING

10.1 Data Collection


There is need to do planning and a pre-observing session using
devised forms. Watch for unusual circumstances and consider how
they will be handled
Try to analyze the data as it is being collected determining whether
the data is adequate to provide the distributions needed as input to
simulation
Try to combine homogenous data sets.
10.1 Data Collection
Histograms or frequency distribution
Selecting the Family Distribution
10.3 Parameter Estimation
10.4 Goodness of fit Tests

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 68 / 75


10.0 INPUT MODELLING

10.4 Goodness of fit Tests


Provide helpful guidance for evaluating the suitability of a potential input
model.
Chi-Square Test
Chi-Square Test with Equal Probabilities
Kolmogorov-Smirnov Goodness-of-Fit Test

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 69 / 75


11 Verification and Validation of Simulation Models

Verification is concerned with building the model right. It is utilized in the


comparison of the conceptual model to the computer representation that
implements that conception. It asks the questions: Is the model
implemented correctly in the computer? Are the input parameters and
logical structure of the model correctly represented?

Validation is concerned with building the right model. It is utilized to


determine that a model is an accurate representation of the real system.
Validation is usually achieved through the calibration of the model, an
iterative process of comparing the model to actual system behavior and
using the discrepancies between the two, and the insights gained, to
improve the model. This process is repeated until model accuracy is
judged to be acceptable.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 70 / 75


11 Verification and Validation of Simulation Models

11.1 Model Building, Verification and Validation

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 71 / 75


11 Verification and Validation of Simulation Models

11.2 Verification of Simulation Models


Many common sense suggestions can be given for use in the verification
process.
Have the computerized representation checked by someone other than
its developer
Make a flow diagram which includes each logically possible action a
system can take when an event occurs, and follow the model logic for
each action for each event type.
Closely examine the model output for reasonableness under a variety
of settings of the input parameters. Have the computerized
representation print out a wide variety of output statistics.-
Have the computerized representation print the input parameters at
the end of the simulation, to be sure that these parameter values
have not been changed inadvertently.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 72 / 75


11 Verification and Validation of Simulation Models
11.2 Verification of Simulation Models
Make the computerized representation as self-documenting as
possible. Give a precise definition of every variable used, and a
general description of the purpose of each major section of code.
If the computerized representation is animated, verify that what is
seen in the animation imitates the actual system. Examples of errors
that can be observed through animation are automated guided
vehicles (AGVs) that pass through one another on a unidirectional
path or at an intersection and entities that disappear (unintentionally)
during a simulation.
11.3 Calibration and Validation of Models
Verification and validation, although conceptually distinct, usually are
conducted simultaneously by the modeler. Validation is the overall process
of comparing the model and its behavior to the real system and its
behavior.
Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 73 / 75
11 Verification and Validation of Simulation Models
11.3 Calibration and Validation of Models
Calibration is the iterative process of comparing the model to the real
system, making adjustments (or even major changes) to the model,
comparing the revised model to reality, making additional adjustments,
comparing again, and so on. Figure 11.3 shows the relationship of model
calibration to the overall validation process.

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 74 / 75


THE END
IT IS TIME OF THE END
IT IS TIME OF THE END
IT IS TIME OF THE END

Mupondo Ndava Constantine (NUST) TEACHING NOTES February 19, 2018 75 / 75

Вам также может понравиться