Module01 TourOfSimulation 190513 PDF
Module01 TourOfSimulation 190513 PDF
Simulation
Dave Goldsman
Georgia Tech
Atlanta, GA, USA
[email protected]
www.isye.gatech.edu/~sman
5/13/19
1
0. Getting to Know You
Goals:
* Contact Info
* Course Info
2
Contact Info
Instructor:
Prof. Dave Goldsman
School of ISyE, Georgia Tech
[email protected]
www.isye.gatech.edu/~sman
(404)822-8949
Office Hours: Anytime you can get me!
3
Course Objectives
Intro to simulation models and simulation
studies.
Organization of simulation languages.
Modeling with Arena – or any comprehensive
simulation package with animation
capabilities.
Statistical aspects including input analysis,
random variate generation, output analysis,
and variance reduction techniques.
4
Prerequisites
You ought to know some probability
and statistics.
You should be familiar with some
programming language and maybe
even a spreadsheet package.
Good News: Don’t panic! I’ll make the
course as self-contained as possible!
5
Suggested Texts / Resources
Banks, J., Carson, J.S., Nelson, B.L., and Nicol, D.M.,
Discrete-Event System Simulation, 5th ed., Prentice
Hall, Upper Saddle River, 2010.
Law, A.M., Simulation Modeling and Analysis, 5th ed.,
McGraw-Hill Education, New York, 2015.
Kelton, W.D., Sadowski, R.P., and Zupick, N.B.,
Simulation with Arena, 6th edition, McGraw-Hill, New
York, 2015.
Free Arena software download:
https://www.arenasimulation.com/academic/students
6
Course Notes
I’ll provide pretty extensive notes on a
course website.
This doesn't mean that you can simply
print out the notes and skip the fun
class…
…so we’ll also do some hands-on work.
7
Computer Programming
We’ll do a reasonable amount of
computer programming. You’ll have some
choice, but you can expect to use:
A spreadsheet package, e.g., Excel.
Python.
A simulation language, e.g., Arena.
8
Syllabus – Let’s Get Going!
Introduction
Calculus, Probability, and Statistics Boot
Camp (Law, Chapter 4)
Hand Simulations; Spreadsheet
Simulations
General Modeling Concepts (Law, 1&2)
Verification and Validation (Law, 5)
Is your simulation doing what you think?
9
Syllabus – Fun with Arena
Arena Basics (KSZ, Chapter 4)
A Generic Call Center in Arena (KSZ, 5)
An Inventory Model (KSZ, 5)
A Manufacturing Center (KSZ, 6)
Entity Transfers in Arena (KSZ, 7)
More-Advanced Arena Stuff (KSZ, 8)
10
Syllabus – Randomness
Random Number Generation (Law, 7)
generate “randomness” on a computer
Random Variate Generation (Law, 8)
single random variables
multivariate random variables
random processes
financial models
11
Syllabus – Statistical Issues
Input Analysis (Law, 6)
What should drive the simulation?
Output Analysis (Law, 9)
Analyze what comes out of the simulation.
Comparing Systems (Law, 10)
Which system is better / best?
Variance Reduction + Other Cool Stuff
12
Module 1 – A Whirlwind Tour!
1. Intro to Simulation
2. Some Easy Examples
3. Generating Randomness
4. Analyzing Randomness
5. Some Bigger Examples
6. Selecting a Simulation Language
13
1. Intro to Simulation
Models are high-level representations of the
operation of a real-world process or system.
Our concern will be with models that are
Discrete (vs. continuous)
Stochastic (vs. deterministic)
Dynamic (vs. static)
How can you “solve” a model?
Analytic methods
Numerical methods
Simulation methods
14
Examples of Models
Toss a stone off of a cliff. You can model its
position via the usual physics equations –
analytical models.
Model the weather. Too tough for exact
analytical models, so you might use numerical
methods.
Add a little randomness, and you may have to
resort to a simulation model (plenty of
examples coming up).
15
What is Simulation?
Simulation is the imitation of a real-
world process or system over time.
Simulation involves the generation of an
artificial history to draw inferences
concerning the operating characteristics
of the real system that is represented.
16
Simulation is…
One of the top three industrial
engineering / operations research /
management science technologies
Used by academics and practitioners on
a wide array of theoretical and applied
problems
An indispensable problem-solving
methodology
17
What is It Good for?
Describe and analyze system behavior
(systems can be real or conceptual)
Ask “what if” questions about the system
Aid in system design and optimization
Pretty much anything can be simulated
Fixed systems with no “customer” arrivals (e.g.,
estimate stock option prices), or
Service systems like Queueing Centers, Manufacturing
Processes, Supply Chains, Health Systems, etc.
18
Reasons to Simulate
Will the system accomplish its goals?
Current system won’t accomplish its goals.
Now what?
Need incremental improvement
Create a specification or plan of action
Resolve disputes
Solve a problem, like a bottleneck
Sell an idea
19
Advantages of Simulation
Can study models too complicated for analytical or
numerical treatment
Study detailed relations that might be lost in the
analytical or numerical treatment
Use as a basis for experimental studies of systems
Use to check results and give credibility to
conclusions obtained by other methods
Reduce design blunders
Really nice demo method
(Sometimes) very easy
…
20
Disadvantages
Sometimes not so easy
Sometimes time consuming / costly
Simulations give “random” output (and
lots of misinterpretation of results is
possible)
To do a certain problem, better
methods than simulation may exist.
…
21
History
1777 – Buffon’s Needle Problem
22
More History
1946 – Ulam, Metropolis, von
Neumann, and the H-Bomb
24
Origins: Mfg/Material Handling
Simulation is the technique of choice
Calculates movement of parts and
interaction of system components
Evaluates flow of parts through the system
Examines conflicting demand for resources
Examines contemplated changes before
their introduction
Eliminates major design blunders
25
Typical Questions
What will be the throughput?
How can we change it?
Where are the bottlenecks?
Which is the best design?
What is the reliability of the system?
What is the impact of breakdowns?
26
What I Used to Think Simulation
Was…
27
Actual Applications
Manufacturing
Automobile Production Facility
Carpet Production Facility
Queueing Problems
Call Center Analysis
Fast Food Drive-Thru
Fast Food Drive-Thru Call Center
Airport Security Line
28
Ex: Generic Queueing System
Combination meat processing center /
fast-food restaurant / amusement park
29
Application: Supply Chains
35
Dr. Harold Shipman
Killed his patients using heroin overdoses
(2nd ranked serial killer in UK)
Was caught after carelessly revising a
patient’s will, leaving all her assets to himself
(don’t use your own typewriter next time)
His computer records were doctored to show
his patients had needed the morphine.
However, the software recorded the dates of
these modifications.
Hung himself in prison, never confessed 36
Dr. Harold Shipman
37
How Does Simulation Help?
Surveillance relies on a series of sequential
statistical hypothesis tests, where the null
hypothesis is “no disease” (or “no murder”)
The statistics involved in the test have very difficult
distributions, even under the null hyp H0
Simulation can be used to approximate the
probability distributions of the statistics under H0
If sampling reveals deviations from this simulated
distribution, you reject H0
Thanks to Prof. Bill Woodall for this example! 38
π
39
Happy Birthday
How many people do you need in a
room in order to have a 50% chance
that at least two will have the same
birthday?
9
23
42
183
40
41
Let’s Make Some Pi
Use Monte Carlo simulation to estimate π.
Idea:
Area of a unit square is 1.
Area of an inscribed circle is π/4.
Probability that a dart thrown at the square
will land in the circle is π/4.
Throw lots of darts. Proportion that will land
in circle should approach π/4.
Multiply proportion by 4 to estimate π. 42
43
Fun With Calculus
Use simulation to integrate
f(x) = sin(πx) over [0,1].
Idea:
Sample n rectangles.
Each is centered randomly on [0,1] and
has width 1/n and height f(x).
Add up areas.
Make n really, really big.
Sum of areas approaches integral of f(x).
44
45
Random Numbers Gone Bad
See what happens when you use a bad
random number generator.
Idea:
Simulate heights vs weights.
Should be a 2-D bell curve (normal
distribution) with most observations in the
middle and some on the outside.
Do observations “look” random?
46
47
48
Queues ‘R Us
Single-server queue at McWendys.
Customers show up, wait in line, get
served first-in-first-out.
What happens as arrival rate
approaches service rate?
Nothing much?
Line gets pretty long?
Hamburgers start to taste better?
49
Queues ‘R Us (cont’d)
Can analyze queues via simulation.
Can analyze via numerical or exact
methods.
50
51
52
Stock Market Follies
Simulate a portfolio of various stocks
Stock prices change randomly from year
to year, with various volatilities
Can consider different mixes for
portfolio
Simple spreadsheet application
53
54
Taking a Random Walk
Take a normal step up or down every
time unit and plot where you are as
time progresses
This “random walk” converges to Brownian
motion
Einstein and Black+Scholes won Nobel
Prizes for this research.
55
3. Generating Randomness
Need random variables to run the simulation,
e.g., interarrival times, service times, etc.
Generate Unif(0,1) pseudo-random numbers
(PRN’s)
Use a deterministic algorithm
Not really random, but appear to be
Generate other random variables
Start with Unif(0,1)’s
Apply certain transformations to come up with just
about any other type of random variable
56
Unif(0,1) PRN’s
Deterministic algorithm
Example: Linear Congruential Generator
Choose an integer “seed,” X(0)
Set X(i) = (a X(i-1) + c) mod(m), where a,
c, and m are carefully chosen constants,
and mod is the modulus function.
Set the ith PRN as U(i) = X(i)/m
57
Unif(0,1) PRN’s
Pretend Example:
Set X(i) = (5 X(i-1) + 3) mod(8), with X(0) = 0
58
(4,7)
(7,6)
(2,5)
(5,4)
(0,3)
(3,2)
(-2,1) (6,1)
(1,0)
The random
numbers fall
mainly on the
planes
60
Generating Other Random
Variates
Start with U(i) ~ Unif(0,1)
Apply some appropriate transformation
Example: -(1/λ) ln(U(i)) ~ Exp(λ)
Inverse transform method – can use this
for various important distributions
Many other more-sophisticated methods
available, e.g., Box-Muller method for
normals
61
4. Analyzing Randomness
Simulation output is nasty. Consider
consecutive customer waiting times.
Not normally distributed – usually skewed
Not identically distributed – patterns
change throughout the day
Not independent – usually correlated
Can’t analyze via “usual” statistics
methods!
62
Analyzing Randomness
Two general cases to consider
Terminating Simulations
Interested in short-term behavior
Example: Avg customer waiting time in a bank
over the course of a day
Example: Avg # of infected victims during a
pandemic
Steady-State Simulations
Interested in long-term behavior
Example: Continuously running assembly line
63
Terminating Simulations
Usually analyzed via Independent
Replications
Make independent runs (replications) of
the simulation, each under identical
conditions
Sample means from each replication are
assumed to be approximately i.i.d. normal
Use classical statistics techniques on the
i.i.d. sample means (not on the original
observations) 64
Steady-State Simulations
First deal with initialization (start-up) bias.
Usually “warm up” simulation before collecting
data
Failure to do so can ruin statistical analysis
Many methods for dealing with steady-state
data
Batch Means
Overlapping Batch Means / Spectral Analysis
Standardized Time Series
Regeneration
65
Steady-State Simulations
Method of Batch Means
Make one long run (vs. many shorter rep’s)
Warm up simulation before collecting data
Chop remaining observations into contiguous
batches
Sample means from each batch are assumed to be
approximately i.i.d. normal
Use classical statistics techniques on the i.i.d.
batch means (not on the original observations)
66
Batch Means Example
Get a confidence interval (CI) for the
mean of an autoregressive process
This process is highly correlated
CI’s via classical statistics (“CLT” method
on next page) result in severe
undercoverage
Look at batch means and overlapping
batch means
BM and OBM do better than CLT.
67
68
5. Some Bigger Examples
Immunization Clinic
Maternity Clinic
Guinea Worm Disease
Airline Routing Structure
Pandemic Disease Propagation
69
Immunization Clinic
Partnership of Immunization Providers
Use simulation to
Study operations of an immunization clinic
Model generic clinic
Read interarrival and service distributions
from spreadsheet
Study alternative clinic configurations
70
71
72
6. Selecting a Simulation
Language
More than 100 languages out there
Commercial
Freeware
Maybe 5 to 10 major players
Cost considerations
Ease of learning
Ease of use
Classes, conferences
73