You are on page 1of 139

RISK ANALYSIS AND DECISIONS IN

MINING
DAY 3
SIMULATION AND OPERATIONAL RISK
José Munizaga-Rosas, Adapted from Banks, Carson, Nelson & Nicol
Discrete-Event System Simulation and Ptolemy II Documentation - October 2016
Outline
 Introduction
 Discrete Event Simulation Concepts
 Random Variables Models
 Some Distributions (Reference)
 Random Variable Generation (Optional)
 Ptolemy II
 Iron Ore MultiPit Simulation
 Hands-on Ptolemy II
Introduction
A Starting Point…
What is a Simulation?
 A simulation can be defined as an imitation of the operation of
a real-world process or system over time:
 Requires the generation of an artificial history of a system.
 Observes that history and draws inferences about system characteristics.
 Can be used as:
 Analysis tool for predicting the effect of changes to existing systems.
 Design tool to predict performance of new systems.
 Many real-world systems are very complex that cannot be
solved mathematically.
 Hence, numerical, computer-based simulation can be used to imitate the
system behavior.

4
When to use Simulation?
 Simulation can be used for the purposes of:
 Study and experiment with internal interactions of a complex system.
 Observe the effect of system alterations on model behavior.
 Gain knowledge about the system through design of simulation model.
 Use as a pedagogical device to reinforce analytic solution methodologies,
also to verify analytic solutions.
 Experiment with new designs or policies before implementation.
 Determine machine requirements through simulating different capabilities.
 For training and learning.
 Show animation.
 Model complex system.

5
When Not to Use Simulation?
 Simulation should not be used when:
 Problem can be solved by common sense.
 Problem can be solved analytically.
 If it is easier to perform direct experiments.
 If the costs exceed the savings.
 If the resources or time to perform simulation studies are not available.
 If no data, not even estimates, is available.
 If there is not enough time or personnel to verify/validate the model.
 If managers have unreasonable expectations: overestimate the power of
simulation.
 If system behavior is too complex or cannot be defined.

6
Advantages and Disadvantages of Simulation
 Simulation is frequently used in problem solving.
 It mimics what happens in a real system.
 It is possible to develop a simulation model of a system without dubious
assumptions of mathematically solvable models.
 In contrast to optimization models, simulation models are “run” rather
than solved.
 Advantages:
 Explore new policies or procedures without disrupting ongoing operations
of the real system.
 Test new hardware or physical systems without committing to acquisition.
 Test hypotheses about how or why certain phenomena occur.
 Study speed-up or slow-down of the phenomena under investigation.

7
Advantages and Disadvantages of Simulation
 Advantages (cont.):
 Study interactions of variables, and their importance to system
performance.
 Perform bottleneck analysis.
 Understand how the system operates.
 Test “what if” questions.
 Disadvantages:
 Model building requires special training.
 Simulation results can be difficult to interpret.
 Simulation modeling and analysis can be time consuming and expensive.
 Simulation is used in some cases when an analytical solution is possible (or
even preferable).

8
Areas of Application
 The applications of simulation are vast.
 The Winter Simulation Conference: an excellent way to learn
more about the latest in simulation applications and theory.
 Some areas of applications:
 Manufacturing
 Construction engineering and project management.
 Military.
 Logistics, supply chain, and distribution.
 Transportation modes and traffic.
 Business process simulation.
 Healthcare.
 Computer and communication systems.

9
Areas of Application
 Some general trends:
 Risk analysis, e.g. pricing, insurance.
 Call-center analysis.
 Large-scale systems, e.g., internet backbone, wireless networks.
 Automated material handling systems as test beds for the development
and functional testing of control-system software.

10
Systems and System Environment
 A system is a group of objects joined together in some regular
interaction or interdependence to accomplish some purpose.
 e.g., a production system: machines, component parts & workers operate
jointly along an assembly line to produce vehicle.
 Affected by changes occurring outside the system.
 System environment: “outside the system”, defining the boundary
between system and it environment is important.

11
Components of a System
 An entity: an object of interest in the system, e.g., computing jobs in
queue.
 An attribute: a property of an entity, e.g., priority class, or vector of
resource requirements.
 An activity: represents a time period of a specified length, e.g. job
receiving service.
 The state of a system: collection of variables necessary to describe
the system at any time, relative to the objectives of the study, e.g. the
number of busy servers, the number of jobs in queue.
 An event: an instantaneous occurrence that may change the system
state, can be endogenous or exogenous, e.g. a new job arrival, or
service time completion

12
Discrete and Continuous Systems
 Discrete system: in which state variable(s) change only at a discrete
set of points in time.
 e.g., the number of jobs in queue changes when a new job arrives or when
service is completed for another
 Continuous system: in which state variable(s) change continuously
over time.
 e.g., the head of water behind a dam.

Discrete System Continuous System


13
Model of a System
 Studies of systems are often accomplished with a model of a
system.
 A model: a representation of a system for the purpose of
studying the system.
 A simplification of the system.
 Should be sufficiently detailed to permit valid conclusions to be drawn
about the real system.
 Should contain only the components that are relevant to the study.

14
Types of Models
 Two types of models: mathematical or physical.
 Mathematical model: uses symbolic notation and mathematical
equations to represent a system.
 Simulation is a type of mathematical model.
 Simulation models:
 Static or dynamic.
 Deterministic or stochastic.
 Discrete or continuous.
 Our focus: discrete, dynamic, and stochastic models.

15
Discrete Event System Simulation
 This lecture will focus in discrete-event system simulation.
 Simulation models are analyzed by numerical methods rather
than by analytical methods.
 Analytical methods: deductive reasoning of mathematics to “solve” the
model.
 Numerical methods: computational procedures to “solve” mathematical
models.

16
Steps in a Simulation Study
Steps in a Simulation Study
 Four phases:
 Problem formulation, and setting objective and overall design (step 1 to
2).
 Modeling building and data collection (step 3 to 7)
 Running of the model (step 8 to 10).
 Implementation (step 11 to 12).
 An iterative process.

18
Simulation Concepts
Foundations for the Rest to Come…
Concepts in Discrete-Event Simulation
 System: a collection of entities that interact together over time, e.g.,
people and machines.
 Model: an abstract representation of a system.
 System state: a collection of variables that contain all the info
necessary to describe the system at any time.
 Entity: any object or component in the system, e.g., a server, a
customer, a machine.
 Attributes: the properties of a given entity.

20
Concepts in Discrete-Event Simulation
 Lists: a collection of associated entities, ordered in some logical
fashion, a.k.a, sets, queues and chains.
 Event: an instantaneous occurrence that changes the state of a
system, e.g., an arrival of a new customer.
 Event list: a list of event notices for future events, ordered by time of
occurrence, a.k.a. the future event list (FEL)
 Activity: a duration of time of specified length which is known when it
begins , e.g., a service time.
 Clock: a variable representing simulated time.

Note: different simulation packages use different terminology for the


same or similar concepts

21
Concepts in Discrete-Event Simulation
 An activity typically represents a service time, an interarrival time, or
any processing time whose duration has been characterized/defined
by the modeler.
 An activity’s duration may be specified:
 Deterministic
 Statistical
 A function depending on system variables and/or entity attributes.
 Duration is not affected by the occurrence of other events, hence, activity
is also called an unconditional wait.
 Completion of an activity is an event, often called a primary event.
 For example
 If the current simulated time is CLOCK = 100 minutes, and an inspection time
of exactly 5 minutes is just beginning, then an event notice is created that
specified the type of event and the event time (100+5 = 105 min).

22
Concepts in Discrete-Event Simulation
 A delay’s duration is determined by system conditions (not specified
by the modeler ahead of time.)
 Also called a conditional wait.
 For example, a customer’s delay in a waiting line may be dependent on
the number and duration of service of other customers ahead in line and,
whether a server has a failure during the delay.
 Dynamic: Function of time and constantly changing over time.
 System state, entity attributes, the number of active entities, the contents
of sets, and the activities and delays currently in progress are all function
of time.

23
Concepts in Discrete-Event Simulation
 Example: Able-Baker Call Center System. A discrete-event model has the
following components:
 System state:
 The number of callers waiting to be served at time t
 Indicator that Able is idle or busy at time t
 Indicator that Baker is idle or busy at time t
 Entities: neither the caller nor the servers need to be explicitly represented, except
in terms of the state variables, unless certain caller averages are desired.
 Events:
 Arrival
 Service completion by Able
 Service completion by Baker
 Activities:
 Inter-arrival time
 Service time by Able
 Service time by Baker
 Delay: a caller’s wait in queue until Able or Baker becomes free.

24
Concepts in Discrete-Event Simulation
 The definition of the model components provides a static
description of the model.
 A description of the dynamic relationships and interactions
between the components is also needed.
 e.g., how does each event affect system state? What events mark the
beginning or end of each activity? What is the system state at time 0?
 A discrete-event simulation is:
 The modeling over time of a system all of whose state changes occur at
discrete points in time.
 Proceeds by producing a sequence of system snapshots.

25
Event Scheduling/Time Advance Algorithm
 The mechanism for advancing simulation time and guaranteeing that
all events occur in correct chronological order.
 At any given time t, the future event list (FEL) contains all previously
scheduled future events and their associated event times (t1,t2, …)
 FEL is ordered by event time, and the event time satisfy:
t  t1  t2  t3  …  tn where t is the value of CLOCK

Update Remove event from FEL


system Advance and execute event, i = i
clock to ti+1
snapshot ti +1

Repeat

26
List Processing
 The management of a list.
 The major list processing operations performed on a FEL are:
 Removal of the imminent event
 Addition of a new event to the list
 Occasionally removal of some event (cancellation of an event).
 Efficiency of search within the list depends on the logical organization of
the list and how the search is conducted.
 When an event with event time t* is generated, its correct
position on the FEL can be found via:
 A top-down search, or
 A bottom-up search.

27
Future Events
 An exogenous event is a happening “outside the system” that
impinges on the system, e.g., arrival and service completion in a
queueing system.
 Arrival event:
 An exogenous event is a happening “outside the system” that impinges on
the system.
 For example, an arrival to a queueing system, at time 0, the 1st arrival
event is generated and is scheduled on the FEL. When the clock eventually
is advanced to the time of this first arrival, a second arrival event is
generated.
 The end of an interarrival interval is an example of a primary event
(primary event is managed by placing an event notice on the FEL.)

28
Future Events
 Service completion event:
 Conditional event
 Triggered only on the condition that a customer is present and a server is
free.
 A service time is an example of an activity.
 Alternate generation of runtimes and downtimes for a machine subject
to breakdowns.
 Stopping event, E:
 At time 0, schedule a stop simulation event at a specified future time TE.
 Run length TE is determined by the simulation itself. Generally, TE is the
time of occurrence of some specified event E.

29
World Views
 The most prevalent world views are:
 Event-scheduling world view (variable time advance.)
 Process-interaction world view (variable time advance.)
 Activity-scanning world view (fixed time increment.)

 Event-scheduling approach
 Concentrates on events and their effect on system state
 Summarized in the previous slides; manual simulation will be discussed
next.

30
World Views
 Process-interaction approach
 Concentrates on the processes: a process is a time-sequenced list of events,
activities and delays that define the life cycle of one entity as it moves
through a system.
 Usually, many processes are active simultaneously in a model, and the
interaction among processes could be quite complex.
 A popular approach because it has intuitive appeal and ease of
simulation package implementation.
 An example of a “customer process”:

31
World Views
 Activity-scanning approach:
 Concentrates on activities of a model and those conditions that allow an
activity to begin.
 At each clock advance, the conditions for each activity are checked, and
if the conditions are true, then the corresponding activities begins.
 Simple in concept but slow runtime on computers.
 The modified approach is called the three-phase approach.
 Events are considered to be activities of duration zero time units.
 Activities are divided into 2 categories:
 B-type: activities that are bound to occur, e.g. primary events.
 C-type: activities or events that are conditional upon certain conditions being true
 Simulation proceeds with repeated execution of the 3 phases: from removal of
events, then execute B-type events, and then execute C-type events.

32
World Views
 Commercial Use:
 Process-interaction approach has been adopted by simulation packages
most popular in the U.S.
 Activity-scanning packages are popular in the UK and Europe.

33
Dump-Truck Example
 Six dump trucks are used to haul coal from the entrance of a small
mine to the railroad.
 Each truck is loaded by one of two loaders.
 After loading, the truck immediately moves to the scale to be weighed.
 The loaders and the scale have a FCFS waiting line (or queue) for trucks.
 After being weighed, a truck begins a travel time (during which the truck
unloads) and returns to the loader queue.

34
Dump-Truck Example
 The distributions of loading time, weighing time and travel time are:
Cumulative Random Digit
Loading Time Probability Probability Assignment
5 0.3 0.3 1-3
10 0.5 0.8 4-8
15 0.2 1 9-0

Weighing Cumulative Random Digit


Time Probability Probability Assignment
12 0.7 0.7 1-7
16 0.3 1 8-0

Cumulative Random Digit


Travel Time Probability Probability Assignment
40 0.4 0.4 1-4
60 0.3 0.7 5-7
80 0.2 0.9 8-9
100 0.1 1 0
35
Dump-Truck Example
 Purpose: to estimate the loader and scale utilizations (% of time busy.)
 The model has the following components:
 System State [ LQ(t), L(t), WQ(t), Q(t)], where
 LQ(t) = number of trucks in loader queue
 L(t) = number of trucks (0, 1, or 2) being loaded
 WQ(t) = number of trucks in weigh queue
 W(t) = number of trucks (0 or 1) being weighed
 Event Notices:
 (ALQ, t, DTi), dump truck i arrives at loader queue (ALQ) at time t
 (EL, t, DTi), dump truck i ends loading (EL) at time t
 (EW, t, DTi), dump truck i ends weighing (EQ) at time t
 Entities: The six dump trucks (DT1, …, DT6)
 Lists:
 Loader queue, all trucks waiting to begin loading, ordered in FCFS basis.
 Weigh queue, all trucks waiting to be weighed, ordered on a FCFS basis.
 Activities: Loading time, weighing time, and travel time.
 Delay: Delay at loader queue, and delay at scale
36
Dump-Truck Example
 When an end-loading (EL) event occurs, say for truck j at time t,
other events are triggered:
 If the scale is idle [W(t) = 0], truck j begins weighing and an end-weighing
event (EW) is scheduled on the FEL. Otherwise, truck j joins the weigh queue.
 If there is another truck waiting for a loader, it will be removed from the
loader queue and begin loading by the scheduling of an end-loading event
(EL) on the FEL.
 Both this logic for the occurrence of the end-loading event and the
appropriate logic for the other two events should be incorporated into an
event diagram.

37
Dump-Truck Example
Truck 3 joins the weigh queue Truck 4 begins to load, schedule
(because the scale is occupied.) an EL event for future time 10
 Simulation Table:
System State Loader Weigh Cumulative Statistics
Clock t Future Event List BL BS
At time 0, 5 LQ(t) L(t) WQ(t) W(t) Queue Queue
trucks at the 0 3 2 0 1 DT4 (EL, 5, DT3) 0 0
DT5 (EL, 10, DT2)
loaders and DT6 (EW, 12, DT1)
1 is at the 5 2 2 1 1 DT5 DT3 (EL, 10, DT2) 10 5
scale DT6 (EL, 5+5, DT4)
(EW, 12, DT1)
10 1 2 2 1 DT6 DT3 (EL, 10, DT4) 20 10
DT2 (EW, 12, DT1)
(EL, 10+10, DT5)
The imminent 10 0 2 3 1 DT3 (EW, 12, DT1) 20 10
event is an EL DT2 (EL, 20, DT5)
DT4 (EL, 10+15, DT6)
event with time
12 0 2 2 1 DT2 (EL, 20, DT5) 24 12
5, hence clock is DT4 (EW, 12+12, DT3)
advanced to (EL, 25, DT6)
time t=5 (ALQ, 12+60, DT1)
20 0 1 3 1 DT2 (EW, 24, DT5) 40 20
DT4 (EL, 25, DT6)
DT5 (ALQ, 72, DT1)
24 0 1 2 1 DT4 (EL, 25, DT6) 44 24
DT5 (EW, 24+12, DT2)
(ALQ, 72, DT1)
(ALQ, 24+100, DT3)
25 0 0 3 1 DT4 (EW, 36, DT2) 45 25
DT5 (ALQ, 72, DT1)
DT6 (ALQ, 124, DT3)
36 0 0 2 1 DT5 (EW, 36+16, DT4) 45 36
DT6 (ALQ, 72, DT1)
(ALQ, 36+40, DT2) 38
(ALQ, 124, DT3)
Dump-Truck Example
 Two cumulative statistics are maintained:
 BL = total busy time of both loaders from time 0 to time t
 BS = total busy time of the scale from time 0 to time t
 From the simulation table, we know that:
 Both loaders are busy from time 0 to time 20, so BL = 40 at time = 20.
 From time 20 to time 24, only one loader is busy, thus BL increases by only 4
minutes over the time interval [20, 24].
 From time 25 to time 36, both loaders are idle (L(25) = 0), so BL does not
change.

39
Dump-Truck Example
 Under the activity-scanning approach, the conditions for
beginning each activity are:
Activity Condition
Load time Truck is at front of loader queue, and at
least one loader is idle.
Weighing time Truck is at front of weigh queue, and weigh scale
is idle.
Travel time Truck has just completed a weighing.

40
Dump-Truck Example
 Using process-interaction approach, we view the model from the
viewpoint of one dumper truck and its “life cycle.”
 Considering a life cycle as beginning at the loader queue, we can picture a
dump-truck process as:

41
Lists: Basic Properties and Operations
 Lists are a set of ordered or ranked records.
 In simulation, each record represents one entity or one event notice.
 They have top or head (1st item) and bottom or tail.
 Ways to traverse the list (to find the 2nd, 3rd, etc. items on the list) are
necessary.
 An entity identifier and its attributes are fields in the entity record.
 Each record on a list has a field that holds a “next pointer” that points
to the next record on the list.

42
Lists: Basic Properties and Operations
 The main operations on a list are:
 Removing a record from the top of the list
 Removing a record from any location on the list
 Adding an entity record to the top or bottom of the list
 Adding a record at an arbitrary position in the list, specified by the ranking rule.
 In the event-scheduling approach, when time is advanced and the
imminent event is due to be executed:
 First, the removal operation takes place.
 If an arbitrary event is being canceled, or an entity is removed from a list based on
some of its attributes to being an activity, then the second removal operation is
performed
 If a queue has the ranking rule earliest due date first, then, upon arrival at the
queue, an entity must be added to the list determined by the due-date ranking rule.

43
Lists: Basic Properties and Operations
 For simulation on a computer:
 All records are stored in arrays: arrays hold successive records in contiguous
locations in computer memory, referenced by array index.
 All entities and event notices are represented by structure (as in C) or classes (as in
Java) allocated from RAM memory as needed, and tracked by pointers to a record
or structure.

44
Using Arrays
 The array method of list storage is typical of FORTRAN.
 Most modern simulation packages do not use arrays for list storage,
but rather use dynamically allocated records.
 Advantages of arrays:
 Any specified record (say the ith record) can be retrieved quickly without
searching, merely by referencing R(i)
 Disadvantages of arrays:
 The list is rearranged when items are added to the middle of a list.
 Have a fixed size which is determined at compile time.

45
Using Arrays
 Two basic methods for keeping track of record ranking in a list:
 Method 1: Store the 1st record in R(1), 2nd in R(2), …, and list in R(tailptr).
 Extremely inefficient.
 For example, adding a record in position 41 in a list of 100 items, it requires
that the last 60 records be physically moved down one array position to make
space for the new record.
 Method 2: Use head pointer.
 A variable that points to the record at the top of the list, denoted as headptr.
 For example, if the record in position R(11) were the record at the top of the list,
then headptr would have the value 11.

46
Random Variables Models
Brief introduction to Random Variables Models
Discrete Random Variables
 X is a discrete random variable if the number of possible values
of X is finite, or countably infinite.
 Example: Consider jobs arriving at a job shop.
 Let X be the number of jobs arriving each week at a job shop.
 Rx = possible values of X (range space of X) = {0,1,2,…}
 p(xi) = probability the random variable is xi = P(X = xi)
 p(xi), i = 1,2, … must satisfy:
1. p( xi )  0, for all i



2. i 1
p( xi )  1

 The collection of pairs [xi, p(xi)], i = 1,2,…, is called the probability


distribution of X, and p(xi) is called the probability mass function (pmf) of
X.
48
Continuous Random Variables
 X is a continuous random variable if its range space Rx is an interval or a
collection of intervals.
 The probability that X lies in the interval [a,b] is given by:
b
P(a  X  b)   f ( x)dx
a

 f(x), denoted as the probability density function (pdf) of X, satisfies:


1. f ( x)  0 , for all x in R X
2.  f ( x)dx  1
RX

3. f ( x)  0, if x is not in RX
 Properties


x0
1. P( X  x0 )  0, because f ( x)dx  0
x0

2. P(a  X  b)  P(a  X  b)  P(a  X  b)  P(a  X  b) 49


Continuous Random Variables
 Example: Life of an inspection device is given by X, a continuous
random variable with pdf:

 1  x / 2
e , x0
f ( x)   2
0, otherwise

 X has an exponential distribution with mean 2 years


 Probability that the device’s life is between 2 and 3 years is:

1 3 x / 2
P(2  x  3)   e dx  0.14
2 2
50
Cumulative Distribution Function
 Cumulative Distribution Function (cdf) is denoted by F(x),
where F(x) = P(X ≤ x)
 If X is discrete, then F ( x)   p( xi )
all
xi  x
 If X is continuous, then x
F ( x)   f (t )dt


 Properties
1. F is nondecreasing function. If a  b, then F (a)  F (b)
2. lim x F ( x)  1
3. lim x F ( x)  0

 All probability questions about X can be answered in terms of the cdf, e.g.:
P(a  X  b)  F (b)  F (a), for all a  b

51
Cumulative Distribution Function
 Example: An inspection device has cdf:

1 x t / 2
F ( x)   e dt  1  e  x / 2
2 0

 The probability that the device lasts for less than 2 years:
P(0  X  2)  F (2)  F (0)  F (2)  1  e1  0.632

 The probability that it lasts between 2 and 3 years:

P(2  X  3)  F (3)  F (2)  (1  e(3/ 2) )  (1  e1 )  0.145

52
Expectation
 The expected value of X is denoted by E(X)
 If X is discrete E ( x)   xi p( xi )
all i

 If X is continuous E ( x)   xf ( x)dx


 a.k.a the mean, m, or the 1st moment of X


 A measure of the central tendency
 The variance of X is denoted by V(X) or var(X) or s2
 Definition: V(X) = E[(X – E[X]2]
 Also, V(X) = E(X2) – [E(X)]2
 A measure of the spread or variation of the possible values of X around the
mean
 The standard deviation of X is denoted by s
 Definition: Square root of V(X)
 Expressed in the same units as the mean

53
Expectations
 Example: The mean of life of the previous inspection device is:

1  x/2  
E ( X )   xe dx   xe x / 2   e  x / 2 dx  2
2 0 0 0

 To compute variance of X, we first compute E(X2):


1  2 x/2  
E ( X )   x e dx   x e
2 2 x / 2   e  x / 2 dx  8
2 0 0
0

 Hence, the variance and standard deviation of the device’s life are:

V ( X )  8  22  4
s  V (X )  2
54
Useful Statistical Models
 In this section, statistical models appropriate to
some application areas are presented. The areas
include:
 Queueing systems
 Inventory and supply-chain systems

 Reliability and maintainability

 Limited data
Queueing Systems
 In a queueing system, inter-arrival and service-time patterns
can be probabilistic.
 Sample statistical models for inter-arrival or service time
distribution:
 Exponential distribution: if service times are completely random
 Normal distribution: fairly constant but with some random variability
(either positive or negative)
 Truncated normal distribution: similar to normal distribution but with
restricted value.
 Gamma and Weibull distribution: more general than exponential
(involving location of the modes of pdf’s and the shapes of tails.)
Inventory and supply chain
 In realistic inventory and supply-chain systems, there are at
least three random variables:
 The number of units demanded per order or per time period
 The time between demands
 The lead time
 Sample statistical models for lead time distribution:
 Gamma
 Sample statistical models for demand distribution:
 Poisson: simple and extensively tabulated.
 Negative binomial distribution: longer tail than Poisson (more large
demands).
 Geometric: special case of negative binomial given at least one demand
has occurred.
Reliability and maintainability
 Time to failure (TTF)
 Exponential: failures are random
 Gamma: for standby redundancy where each
component has an exponential TTF
 Weibull: failure is due to the most serious of a large
number of defects in a system of components
 Normal: failures are due to wear
Other areas
 For cases with limited data, some useful distributions
are:
 Uniform, triangular and beta
 Other distribution: Bernoulli, binomial and
hyperexponential.
Some Distributions
The Ones Commonly Used in Applications
(Material for Reference Purposes)
Discrete Distributions
 Discrete random variables are used to describe
random phenomena in which only integer values can
occur.
 In this section, we will learn about:
 Bernoullitrials and Bernoulli distribution
 Binomial distribution

 Geometric and negative binomial distribution

 Poisson distribution
Bernoulli Trials and Bernoulli Distribution
 Bernoulli Trials:
 Consider an experiment consisting of n trials, each can be a success or a
failure.
 Let Xj = 1 if the jth experiment is a success
 and Xj = 0 if the jth experiment is a failure
 The Bernoulli distribution (one trial):
 p, x j  1, j  1,2,..., n

p j ( x j )  p( x j )  1  p  q, x j  0,j  1,2,...,n
0,
 otherwise
 where E(Xj) = p and V(Xj) = p(1 – p) = pq
 Bernoulli process:
 The n Bernoulli trials where trails are independent:
p(x1,x2,…, xn) = p1(x1)p2(x2) … pn(xn)
62
Binomial Distribution
 The number of successes in n Bernoulli trials, X, has a binomial
distribution.
 n  x n  x
  p q , x  0,1,2,..., n
p( x)   x 
0,
 otherwise

The number of Probability that


outcomes having the there are
required number of x successes and (n-x)
successes and failures failures

 The mean, E(x) = p + p + … + p = n*p


 The variance, V(X) = pq + pq + … + pq = n*pq

63
Geometric & Negative Binomial Distribution
 Geometric distribution
 The number of Bernoulli trials, X, to achieve the 1st success:

q x 1 p, x  0,1, 2,..., n
p( x)  
0, otherwise

 E(X) = 1/p, and V(X) = q/p2


 Negative binomial distribution
 The number of Bernoulli trials, X, until the kth success
 If X is a negative binomial distribution with parameters p and k, then:
 x  1 x k k
  q p , x  k , k  1, k  2,...
p( x)   k  1
0,
 otherwise

 E(X) = k/p, and V(X) = kq/p2


64
Poisson Distribution
 Poisson distribution describes many random processes quite well
and is mathematically quite simple.
 where a > 0, pdf and cdf are:
 e a a x x
e a a i

p( x)   x! , x  0,1,... F ( x)  
i 0 i!
0, otherwise

 E(X) = a = V(X)

65
Poisson Distribution
 Example: A computer repair person is “beeped” each time
there is a call for service. The number of beeps per hour ~
Poisson(a = 2 per hour).

 The probability of three beeps in the next hour:


p(3) = e–223/3! = 0.18
also, p(3) = F(3) – F(2) = 0.857 – 0.677 = 0.18

 The probability of two or more beeps in a 1-hour period:


p(2 or more) = 1 – p(0) – p(1)
= 1 – F(1)
= 0.594

66
Continuous Distributions
 Continuous random variables can be used to
describe random phenomena in which the variable
can take on any value in some interval.
 In this section, the distributions studied are:
 Uniform

 Exponential

 Normal

 Weibull

 Lognormal

67
Uniform Distribution
 A random variable X is uniformly distributed on the interval
(a,b), denoted U(a,b), if its pdf and cdf are:
0, xa
 1 xa
 , a xb 
f ( x)   b  a F ( x)   , a xb
 b  a
0, otherwise
1, xb

 Properties
 P(x1 < X < x2) is proportional to the length of the interval:
F(x2) – F(x1) = (x2 – x1)/(b – a)
 E(X) = (a+b)/2 V(X) = (b – a)2/12
 U(0,1) provides the means to generate random numbers, from
which random variates can be generated.
68
Exponential Distribution
 A random variable X is exponentially distributed with
parameter l > 0 if its pdf and cdf are:
le  lx , x  0 0, x0
f ( x)   F ( x)   x  lt
 0 l e dt  1  e , x  0
l x
0, elsewhere

 E(X) = 1/l V(X) = 1/l2


 Used to model interarrival times when
arrivals are completely random, and
to model service times that are highly
variable
 For several different exponential pdf’s
(see figure), the value of intercept on
the vertical axis is l, and all pdf’s
eventually intersect.
69
Exponential Distribution
 Memoryless property
 For all s and t greater or equal to 0:
P(X > s + t | X > s) = P(X > t)

 Example: A lamp ~ exp(l = 1/3 per hour), hence, on


average, 1 failure per 3 hours.
 The probability that the lamp lasts longer than its mean life
is: P(X > 3) = 1-(1-e-3/3) = e-1 = 0.368
 The probability that the lamp lasts between 2 to 3 hours is:
P(2 <= X <= 3) = F(3) – F(2) = 0.145
 Theprobability that it lasts for another hour given it is
operating for 2.5 hours:
P(X > 3.5 | X > 2.5) = P(X > 1) = e-1/3 = 0.717

70
Normal Distribution
 A random variable X is normally distributed if it has the pdf:
1  1  x  m 2 
f ( x)  exp     ,   x  
s 2  2  s  
 Mean:   m  
 Variance: s 2  0
 Denoted as X ~ N(m,s2)
 Special properties:
 lim x f ( x)  0, and lim x f ( x)  0 .
 f(m – x) = f((m + x); the pdf is symmetric about m.
 The maximum value of the pdf occurs at x = m; the mean and mode are
equal.

71
Normal Distribution
 Evaluating the distribution:
 Use numerical methods (no closed form)
 Independent of m and s, using the standard normal distribution:
Z ~ N(0,1)
 Transformation of variables: let Z = (X – m) / s,
F ( x)  P  X  x 
 xm 
 PZ  
 s 
( xm ) /s 1  z2 / 2
 e dz

2
( xm ) /s
  ( z )dz


  1 t 2 / 2
z
 xm
s where ( z )   e dt

2 72
Normal Distribution
 Example: The time required to load an oceangoing vessel, X, is
distributed as N(12,4)
 The probability that the vessel is loaded in less than 10 hours:
 10  12 
F (10)     (1)  0.1587
 2 
 Using the symmetry property, (1) is the complement of  (-1)

73
Weibull Distribution
 A random variable X has a Weibull distribution if its pdf has the form:
 b  x   b 1   x   b 

f ( x)  a  a 
exp   , x  
  a  
0,
 otherwise

 3 parameters:
(    )
 Location parameter: u,
 Scale parameter: b , b  0
 Shape parameter. a,  0
 Example: u = 0 and a = 1:

When b = 1,
X ~ exp(l =
1/a)
74
Lognormal Distribution
 A random variable X has a lognormal distribution if its pdf has
the form:
 1   ln x  μ  2 
 exp   , x  0 m=1,
f ( x)   2πσx  2 σ 2
 s2=0.5,1,2
 .
0, otherwise

2
 Mean E(X) = em+s /2
2 2
 Variance V(X) = e2m+s (es - 1)

 Relationship with normal distribution


 When Y ~ N(m, s2), then X = eY ~ lognormal(m, s2)
 Parameters m and s2 are not the mean and variance of the lognormal

75
Poisson Distribution
 Definition: N(t) is a counting function that represents the
number of events occurred in [0,t].
 A counting process {N(t), t ≥ 0} is a Poisson process with
mean rate l if:
 Arrivals occur one at a time
 {N(t), t ≥ 0} has stationary increments
 {N(t), t ≥ 0} has independent increments
 Properties
e  lt ( l t ) n
P[ N (t )  n]  , for t  0 and n  0,1,2,...
n!

 Equal mean and variance: E[N(t)] = V[N(t)] = lt


 Stationary increment: The number of arrivals between time s and time
t > s is also Poisson-distributed with mean l(t – s)
76
Interarrival Times
 Consider the interarrival times of a Possion process (A1, A2, …), where Ai is
the elapsed time between arrival i and arrival i+1

 The 1st arrival occurs after time t iff there are no arrivals in the interval [0,t],
hence:
P{A1 > t} = P{N(t) = 0} = e-lt
P{A1 ≤ t} = 1 – e-lt [cdf of exp(l)]
 Interarrival times, A1, A2, …, are exponentially distributed and independent with
mean 1/l

Arrival counts Interarrival time


~ Poisson(l) ~ Exp(1/l)

77
Splitting and Pooling
 Splitting:
 Suppose each event of a Poisson process can be classified as Type I,
with probability p and Type II, with probability 1-p.
 N(t) = N1(t) + N2(t), where N1(t) and N2(t) are both Poisson processes
with rates l p and l (1-p)
lp N1(t) ~ Poi[lp]
N(t) ~ Poi(l) l

l(1-p) N2(t) ~ Poi[l(1-p)]


 Pooling:
 Suppose two Poisson processes are pooled together
 N1(t) + N2(t) = N(t), where N(t) is a Poisson processes with rates l1 +
l2
N1(t) ~ Poi[l1] l1
l1  l2
N(t) ~ Poi(l1  l2)
N2(t) ~ Poi[l2] l2
78
Nonstationary Poisson Process (NSPP)
 Poisson Process without the stationary increments, characterized by l(t), the
arrival rate at time t.
 The expected number of arrivals by time t, L(t):
t
Λ(t)   λ(s)ds
0

 Relating stationary Poisson process n(t) with rate l1 and NSPP N(t) with rate
l(t):
 Let arrival times of a stationary process with rate l = 1 be t1, t2, …, and
arrival times of a NSPP with rate l(t) be T1, T2, …, we know:
ti = L(Ti)
Ti = L1(ti)

79
Nonstationary Poisson Process (NSPP)
 Example: Suppose arrivals to a Post Office have rates 2 per minute from 8 am
until 12 pm, and then 0.5 per minute until 4 pm.
 Let t = 0 correspond to 8 am, NSPP N(t) has rate function:
2, 0t 4
l (t )  
0.5, 4  t  8
Expected number of arrivals by time t:
2t , 0t 4

L(t )   4 t
 0 4
t
2 ds  0.5ds   6, 4  t  8
2
 Hence, the probability distribution of the number of arrivals between 11 am
and 2 pm.
P[N(6) – N(3) = k] = P[N(L(6)) – N(L(3)) = k]
= P[N(9) – N(6) = k]
= e(9-6)(9-6)k/k!
= e3(3)k/k!
80
Empirical Distributions
 A distribution whose parameters are the observed values in a
sample of data.
 May be used when it is impossible or unnecessary to establish that a
random variable has any particular parametric distribution.
 Advantage: no assumption beyond the observed values in the sample.
 Disadvantage: sample might not cover the entire range of possible values.

81
Properties of Random Numbers
 Two important statistical properties:
 Uniformity
 Independence.
 Random Number, Ri, must be independently drawn from a
uniform distribution with pdf:

1, 0  x  1
f ( x)  
0, otherwise
1
1 2


x 1
E ( R)  xdx  
0 2 2
0
Figure: pdf for
random numbers
82
Generation of Pseudo-Random Numbers
 “Pseudo”, because generating numbers using a known method
removes the potential for true randomness.
 Goal: To produce a sequence of numbers in [0,1] that simulates, or
imitates, the ideal properties of random numbers (RN).
 Important considerations in RN routines:
 Fast
 Portable to different computers
 Have sufficiently long cycle
 Replicable
 Closely approximate the ideal statistical properties of uniformity and
independence.

83
Techniques for Generating Random
Numbers
 Linear Congruential Method (LCM).
 Combined Linear Congruential Generators (CLCG).
 Random-Number Streams.

84
Linear Congruential Method
 To produce a sequence of integers, X1, X2, … between 0 and m-1
by following a recursive relationship:

X i 1  (aX i  c) mod m, i  0,1,2,...

The The The


multiplier increment modulus

 The selection of the values for a, c, m, and X0 drastically affects


the statistical properties and the cycle length.
 The random integers are being generated [0,m-1], and to convert
the integers to random numbers:
Xi
Ri  , i  1,2,...
m
85
Example
 Use X0 = 27, a = 17, c = 43, and m = 100.
 The Xi and Ri values are:
X1 = (17*27+43) mod 100 = 502 mod 100 = 2, R1 = 0.02;
X2 = (17*2+32) mod 100 = 77, R2 = 0.77;
X3 = (17*77+32) mod 100 = 52, R3 = 0.52;

86
Characteristics of a Good Generator
 Maximum Density
 Such that he values assumed by Ri, i = 1,2,…, leave no large gaps on
[0,1]
 Problem: Instead of continuous, each Ri is discrete
 Solution: a very large integer for modulus m
 Approximation appears to be of little consequence
 Maximum Period
 To achieve maximum density and avoid cycling.
 Achieve by: proper choice of a, c, m, and X0.
 Most digital computers use a binary representation of numbers
 Speed and efficiency are aided by a modulus, m, to be (or close to) a
power of 2.

87
Combined Linear Congruential Generators
 Reason: Longer period generator is needed because of the
increasing complexity of stimulated systems.
 Approach: Combine two or more multiplicative congruential
generators.
 Let Xi,1, Xi,2, …, Xi,k, be the ith output from k different multiplicative
congruential generators.
 The jth generator:
 Has prime modulus mj and multiplier aj and period is mj-1
 Produces integers Xi,j is approx ~ Uniform on integers in [1,
m-1]
 Wi,j = Xi,j -1 is approx ~ Uniform on integers in [1, m-2]

88
Combined Linear Congruential Generators
 Suggested form:
 Xi
 k   m , Xi  0
X i    (1) X i , j  mod m1  1
 j 1
Hence, Ri   1
 j 1  m 1
 1 , Xi  0
 m1
The coefficient:
Performs the
subtraction Xi,1-1

 The maximum possible period is:


(m1  1)(m2  1)...(mk  1)
P
2 k 1

89
Combined Linear Congruential Generators
 Example: For 32-bit computers, L’Ecuyer [1988] suggests combining k = 2
generators with m1 = 2,147,483,563, a1 = 40,014, m2 = 2,147,483,399
and a2 = 20,692. The algorithm becomes:
Step 1: Select seeds
 X1,0 in the range [1, 2,147,483,562] for the 1st generator
 X2,0 in the range [1, 2,147,483,398] for the 2nd generator.
Step 2: For each individual generator,
X1,j+1 = 40,014 X1,j mod 2,147,483,563
X2,j+1 = 40,692 X1,j mod 2,147,483,399.
Step 3: Xj+1 = (X1,j+1 - X2,j+1 ) mod 2,147,483,562.
Step 4: Return
 X j 1
 , X j 1  0
R j 1   2,147,483, 563
 2,147,483,562 , X j 1  0
 2,147,483,563
Step 5: Set j = j+1, go back to step 2.
 Combined generator has period: (m1 – 1)(m2 – 1)/2 ~ 2 x 1018
90
Random-Numbers Streams
 The seed for a linear congruential random-number generator:
 Is the integer value X0 that initializes the random-number sequence.
 Any value in the sequence can be used to “seed” the generator.
 A random-number stream:
 Refers to a starting seed taken from the sequence X0, X1, …, XP.
 If the streams are b values apart, then stream i could defined by starting seed:
Si  X b (i 1)
 Older generators: b = 105; Newer generators: b = 1037.
 A single random-number generator with k streams can act like k distinct
virtual random-number generators
 To compare two or more alternative systems.
 Advantageous to dedicate portions of the pseudo-random number sequence to
the same purpose in each of the simulated systems.

91
Tests for Random Numbers
 Two categories:
 Testing for uniformity:
H0: Ri ~ U[0,1]
H1: Ri ~/ U[0,1]
 Failure to reject the null hypothesis, H0, means that evidence of non-uniformity
has not been detected.
 Testing for independence:
H0: Ri ~ independently
H1: Ri ~
/ independently
 Failure to reject the null hypothesis, H0, means that evidence of dependence
has not been detected.
 Level of significance a, the probability of rejecting H0 when it is
true: a = P(reject H0|H0 is true)
92
Tests for Random Numbers
 When to use these tests:
 If a well-known simulation languages or random-number generators is
used, it is probably unnecessary to test
 If the generator is not explicitly known or documented, e.g., spreadsheet
programs, symbolic/numerical calculators, tests should be applied to
many sample numbers.
 Types of tests:
 Theoretical tests: evaluate the choices of m, a, and c without actually
generating any numbers
 Empirical tests: applied to actual sequences of numbers produced. Our
emphasis.

93
Frequency Tests
 Test of uniformity
 Two different methods:
 Kolmogorov-Smirnov test
 Chi-square test
Kolmogorov-Smirnov Test
 Compares the continuous cdf, F(x), of the uniform distribution
with the empirical cdf, SN(x), of the N sample observations.
 We know: F ( x)  x, 0  x  1
 If the sample from the RN generator is R1, R2, …, RN, then the empirical
cdf, SN(x) is:
number of R1 , R2 ,..., Rn which are  x
S N ( x) 
N

 Based on the statistic: D = max| F(x) - SN(x)|


 Sampling distribution of D is known (as a function of N)
 A more powerful test, recommended.
Kolmogorov-Smirnov Test
 Example: Suppose 5 generated numbers are 0.44, 0.81, 0.14, 0.05,
0.93.
Arrange R(i) from
Step 1: R(i) 0.05 0.14 0.44 0.81 0.93 smallest to largest
i/N 0.20 0.40 0.60 0.80 1.00
D+ = max {i/N – R(i)}
i/N – R(i) 0.15 0.26 0.16 - 0.07
Step 2:
R(i) – (i-1)/N 0.05 - 0.04 0.21 0.13
D- = max {R(i) - (i-1)/N}

Step 3: D = max(D+, D-) = 0.26


Step 4: For a = 0.05,
Da = 0.565 > D

Hence, H0 is not rejected.


Chi-square test
 Chi-square test uses the sample statistic:
n is the # of classes Ei is the expected
n
(Oi  Ei ) 2
# in the ith class
 
2
0
i 1 Ei Oi is the observed
# in the ith class

 Approximately the chi-square distribution with n-1 degrees of freedom


(where the critical values are tabulated)
 For the uniform distribution, Ei, the expected number in the each class is:
N
Ei  , where N is the total # of observation
n
 Valid only for large samples, e.g. N >= 50
Tests for Autocorrelation
 Testing the autocorrelation between every m numbers (m is
a.k.a. the lag), starting with the ith number
 The autocorrelation rim between numbers: Ri, Ri+m, Ri+2m, Ri+(M+1)m
 M is the largest integer such that i  (M  1 )m  N
 Hypothesis:
H 0 : rim  0, if numbers are independent
H1 : rim  0, if numbers are dependent

 If the values are uncorrelated:


 For large values of M, the distribution of the estimator of rim, denoted r̂im
is approximately normal.

98
Tests for Autocorrelation
 Test statistics is: rˆ im
Z0 
sˆ rˆ
im

 Z0 is distributed normally with mean = 0 and variance = 1, and:


1 M 
ρˆ im   
M  1  k 0
Ri  km i (k 1 )m   0.25
R

13M  7
σˆ ρim 
12(M  1 )
 If rim > 0, the subsequence has positive autocorrelation
 High random numbers tend to be followed by high ones, and vice versa.
 If rim < 0, the subsequence has negative autocorrelation
 Low random numbers tend to be followed by high ones, and vice versa.

99
Example
 Test whether the 3rd, 8th, 13th, and so on, for the following
output on P. 265.
 Hence, a = 0.05, i = 3, m = 5, N = 30, and M = 4
1 (0.23)(0.28)  (0.25)(0.33)  (0.33)(0.27)
ρˆ 35     0.25
4  1  (0.28)(0.05)  (0.05)(0.36) 
 0.1945
13(4)  7
σˆ ρ35   0.128
12( 4  1 )
0.1945
Z0    1.516
0.1280

 From Tables, z0.025 = 1.96. Hence, the hypothesis is not rejected.

100
Shortcomings
 The test is not very sensitive for small values of M, particularly
when the numbers being tests are on the low side.
 Problem when “fishing” for autocorrelation by performing
numerous tests:
 If a = 0.05, there is a probability of 0.05 of rejecting a true hypothesis.
 If 10 independence sequences are examined,
 The probability of finding no significant autocorrelation, by
chance alone, is 0.9510 = 0.60.
 Hence, the probability of detecting significant
autocorrelation when it does not exist = 40%

101
Random Variable Generation
How to Create Those Strange Things in the
Computer (optional, and just for the sake of
completeness)
Inverse-transform Technique
 The concept:
 For cdf function: r = F(x)
 Generate r from uniform (0,1)
r = F(x)
 Find x:
x = F-1(r) r1

x1

103
Exponential Distribution
 Exponential Distribution:
 Exponential cdf:

r= F(x)
= 1 – e -l x for x  0

 To generate X1, X2, X3 …

Xi = F-1(Ri)
= -(1/l ln(1-Ri) [Eq’n 8.3]
Figure: Inverse-transform
technique for exp(l = 1)

104
Exponential Distribution
 Example: Generate 200 variates Xi with distribution exp(l= 1)
 Generate 200 Rs with U(0,1) and utilize eq’n 8.3, the histogram of Xs
become:

 Check: Does the random variable X1 have the desired distribution?

P( X1  x0 )  P( R1  F ( x0 ))  F ( x0 )

105
Other Distributions
 Examples of other distributions for which inverse cdf
works are:
 Uniform distribution
 Weibull distribution

 Triangular distribution
Empirical Continuous Distribution
 When theoretical distribution is not applicable
 To collect empirical data:
 Resample the observed data
 Interpolate between observed data points to fill in the gaps
 For a small sample set (size n):
 Arrange the data from smallest to largest

x (1)  x (2)    x (n)


 Assign the probability 1/(n–1) to each interval x (i-1)  x  x (i)

ˆ 1  (i  1) 
X  F ( R)  x(i 1)  ai  R  
 n 
where x(i )  x(i 1) x(i )  x(i 1)
ai  
1 / n  (i  1) / n 1/ n

107
Empirical Continuous Distribution
 Example: Suppose the data collected for 100 broken-widget
repair times are:
Interval Relative Cumulative Slope,
i (Hours) Frequency Frequency Frequency, c i ai
1 0.25 ≤ x ≤ 0.5 31 0.31 0.31 0.81
2 0.5 ≤ x ≤ 1.0 10 0.10 0.41 5.0
3 1.0 ≤ x ≤ 1.5 25 0.25 0.66 2.0
4 1.5 ≤ x ≤ 2.0 34 0.34 1.00 1.47

Consider R1 = 0.83:

c3 = 0.66 < R1 < c4 = 1.00

X1 = x(4-1) + a4(R1 – c(4-1))


= 1.5 + 1.47(0.83-0.66)
= 1.75

108
Discrete Distribution
 All discrete distributions can be generated via
inverse-transform technique
 Method: numerically, table-lookup procedure,
algebraically, or a formula
 Examples of application:
 Empirical

 Discrete uniform
Discrete Distribution
 Example: Suppose the number of shipments, x, on the loading
dock of IHW company is either 0, 1, or 2
 Data - Probability distribution:
x p(x) F(x)
0 0.50 0.50
1 0.30 0.80
2 0.20 1.00

 Method - Given R, the generation


scheme becomes:
0, 0.0  R  0.5
x  1, 0.5  R  0.8
2, 0.8  R  1.0 Consider R1 = 0.73:
F(xi-1) < R <= F(xi)
F(x0) < 0.73 <= F(x1)
Hence, x1 = 1 110
Acceptance-Rejection technique
 Useful particularly when inverse cdf does not exist in closed form, a.k.a.
thinning
 Illustration: To generate random variates, X ~ U(1/4, 1)
Generate R
Procedures: no
Step 1. Generate R ~ U[0,1] Condition
Step 2a. If R >= ¼, accept X=R. yes
Step 2b. If R < ¼, reject R, return to Step 1 Output R’

 R does not have the desired distribution, but R conditioned (R’) on the event
{R  ¼} does.
 Efficiency: Depends heavily on the ability to minimize the number of
rejections.
NSPP
 Non-stationary Poisson Process (NSPP): a Possion arrival process with
an arrival rate that varies with time
 Idea behind thinning:
 Generate a stationary Poisson arrival process at the fastest rate, l* =
max l(t)
 But “accept” only a portion of arrivals, thinning out just enough to get the
desired time-varying rate
Generate E ~ Exp(l*)
t=t+E
no

Condition
R <= l(t)
yes
Output E ’~ t
NSPP
 Example: Generate a random variate for a NSPP
Data: Arrival Rates Procedures:
Step 1. l* = max l(t) = 1/5, t = 0 and i = 1.
Step 2. For random number R = 0.2130,
E = -5ln(0.213) = 13.13
t = 13.13
Step 3. Generate R = 0.8830
l(13.13)/l*=(1/15)/(1/5)=1/3
Since R>1/3, do not generate the arrival
Step 2. For random number R = 0.5530,
E = -5ln(0.553) = 2.96
t = 2.96
Step 3. Generate R = 0.0240
l(2.96)/l*=(1/15)/(1/5)=1/3
Since R<1/3, T1 = t = 2.96,
and i = i + 1 = 2 113
Special Properties
 Based on features of particular family of
probability distributions
 For example:
 Direct Transformation for normal and lognormal
distributions
 Convolution

 Beta distribution (from gamma distribution)


Direct Transformation
 Approach for normal(0,1):
 Consider two standard normal
random variables, Z1 and Z2,
plotted as a point in the plane:

In polar coordinates:
Z1 = B cos 
Z2 = B sin 

 B2 = Z21 + Z22 ~ chi-square distribution with 2 degrees of freedom


= Exp(l = 2). Hence, B  2 ln  R 
 The radius B and angle  are mutually independent.
Z1  2ln  R1  cos  2 R2  
 independent N  0,1
Z 2  2ln  R1  sin  2 R2  

115
Direct Transformation
 Approach for normal(m,s2):
 Generate Zi ~ N(0,1)

Xi = m + s Zi

 Approach for lognormal(m,s2):


 Generate X ~ N(m,s2)
Yi = eXi
Ptolemy II
An Open Source Tool for Simulation
Introduction to Ptolemy II
 “Ptolemy II is an open-source software framework
supporting experimentation with actor-oriented
design catering to heterogeneous modeling” (Eker,
et al. 2003)
 Actors are software components that execute
concurrently and communicate through messages
sent via interconnected ports
What is Ptolemy
 Ptolemy is a software infrastructure (kernel)
developed by EECS dept, Berkeley
 Object-oriented
 Support modeling, simulation, design and code
generation for concurrent, embedded real-time system.
 Support multiple domains
 Support heterogeneous environment
How Does Ptolemy II Works? (1)
 A model is a set of interconnected actors and one
director
 Actor
 Input& output ports, states, & parameters
 Atomic or composite

 Communicates using tokens

 When it is fired it produces and consumes tokens

Ports

producer consumer
actor actor
How Does Ptolemy II Works? (2)
 Director
 Manages the data flow and the scheduling of the
actors
 The director fires the actors

 Receiver
 Defines the semantics of the port buffers
 Models of Computation
 Definethe interaction semantics
 Implemented in Ptolemy II by a domain
 Director + Receiver
Crash Course on Ptolemy II (1)
Crash Course on Ptolemy II (2)

An actor is implemented
using java.
Ptolemy II is highly
extensible
DE model (1)
 Provides a generic environment for time-oriented
simulation system
 Queuing system
 Communication network

 High-level modeling of computer architecture

 Particles represent event: change of system state


DE model (2)
 Each particle has an associated timestamp
 A global event queue sorts events by timestamp
 DE processes event in a chronological order (fetches
the first one)
IRON ORE MULTIPIT SIMULATION

An Illustrative Example
(Presented at MPES 2012, New Delhi, India)
The Problem (1)
 The problem considered was the determination of
the fleet size for a surface mining operation:
 The operations consists of multiple pits
 The different times involved in the operation of the
system were considered stochastic
 The pits are exploited in such a way that the hauling
distance to the ROM pad and the waste dumps are
variable in time
The Problem (2)

Waste Dump 1

Pit 1

Port

ROM
Pit 2

Waste Dump 2
Modelling Assumptions (1)
 There are two styles of truck available for mine operation,
large trucks with a capacity of 180t, and small trucks with a
capacity of 100t.
 All shovels in the mine are identical in terms of their loading
capabilities, and one is located in each mine.
 All shovels can serve only one truck at a time and trucks may
form queues, with no queue’s forming at dump locations.
 Mining of ore happens at random with a 20% probability, i.e.,
1 in 5 trucks is sent to the R.O.M. (strip ratio)
 Each mine has an associated waste dump, being used by that
mines trucks only.
Modelling Assumptions (2)
 Breakdowns are not taken into consideration in this simulation,
assuming a clean shift of operation with minor random delays
accounted for in travel time standard deviation.
 Current mining fleet comprises a limit of 12 large trucks and 4
small trucks available to the operation for materials
transportation of ore and waste.
 All trucks start operation at the parking area near the
dumping point at the start of the shift and park there at the
end of each shift.
 During a program run, the haulage system performs without
any rest (i.e. ten hours per shift).
Modelling Assumptions (3)
 Cycle times have been broken down into the following:
 Travel empty into pit – truck reaching crest of pit ramp traveling to
loading area in pit.
 Queue time – time taken from truck arriving at loading bay to backing
up under shovel.
 Loading Time – time taken for shovel to load material into truck until
capacity is reached.
 Travel full out of pit – time taken for truck to leave shovel loaded and
travel to crest of pit ramp.
 Travel full to dump location – time taken for trucks to travel from crest of
pit ramp to dump location, dump load and return to crest of ramp. (Both
ore to R.O.M. and waste to waste dump).
Modelling Assumptions (4)

Task Time (min) Standard Deviation


Travel Empty Into Mine 1 0.01*x+2 0
Travel empty into Mine 2 0.01*x+1 0
Load Time Large Truck 4.5 0.1
Load Time Small Truck 3 0.1
Travel Loaded out Mine 1 0.01*x+10 0
Travel Loaded out Mine 2 0.01*x+8 0
Travel Mine 1 to Dump, Back to Mine 1 10 0.4
Travel Mine 2 to Dump, Back to Mine 2 18 0.4
Travel Mine 1 to ROM, Back to Mine 1 17 0.4
Travel Mine 2 to ROM, Back to Mine 2 17 0.4
Ptolemy II Model (1)
Overview of the Model
Ptolemy II Model (2)
Composite Actor
Results (1)
Simulation Results for Different Fleet Configurations (Ore and Waste)

Both Ore & Waste


Mine Mine 1 Mine 2 Mine 1 Mine 2 Mine 1 Mine 2 Mine1 Mine2
Fleet 4 Large 5 Large 5 Large 6 Large 5 Large 6 Large 5 Large 7 Large
2 Small 2 Small 2 Small 2 Small 1 Small 1 Small
Total Loads 121 126 135 143 118 127 102 126
Avg. Queue 1.18 1.24 1.45 1.47 1.34 1.47 1.13 1.26
Length

Table 3 Simulation Results for Different Fleet Configurations (Just Waste)

Both Waste
Mine Mine 1 Mine 2 Mine 1 Mine 2 Mine 1 Mine 2 Mine1 Mine2
Fleet 4 Large 1 6 Large 4 Large 6 Large 5 Large 7 Large 5 Large 5 Large
Small 1 Small 2 Small 2 Small 1 Small 1 Small
Total Loads 109 126 128 133 108 126 128 109
Avg. Queue 0.89 1.20 1.09 1.73 0.87 1.25 1.02 1.00
Length
Results (2)
Fleet 1 Fleet 2 Fleet 3 Fleet 4 Fleet 5
Mine 1 5 Large, 3 Small 5 Large, 2 Small 4 Large, 2 Small 3 Large, 2 Small 3 large, 1 Small
Mine 2 8 Large, 1 Small 8 Large 7 Large 6 Large 5 Large
Remarks (1)
 The results of the simulation study have shown that
while increasing trucks in theory could be translated
into increased production, resulting queues grow
substantially after a point thus decreasing
equipment utilization.
 Simulations can provide a method of assessing the
consequences of decisions and is a timely addition
to time and motion study data, which is gathered
regularly in modern surface mining operations
Remarks (2)
 Ptolemy II has proved to be a very flexible tool that
allows representing some of the great complexity
that mining operations provide:
 Being based on the use of graphical models it greatly
helps to follow the logic of the operations
 Ptolemy II’s is modularity increases its applicability into
the mining domain
 Ptolemy II is not only limited to discrete event simulation
models but rather it provides a wide range of possible
simulation paradigms
Hands-on Ptolemy II
Creating a Discrete Event Simulation Together
Step by Step

You might also like