Title: Introduction to Simulation
1Introduction to Simulation
2An Overview
- An Illustrative Case The Ptube Story
- Discrete event simulation example
- Overview of simulation
- In general
- Spreadsheet based
- Randomness, random numbers and random variables
- Walton Bookstore model
- _at_Risk
3Computer Simulation
- Computerized, descriptive, model of a stochastic,
discrete event, system - Explicitly model uncertainty by representing
uncertain variables with probability
distributions - Discrete event Monte-carlo (spreadsheet)
- Facilitates experimentation (What if?)
- Art of Modeling
- Many commercial tools available
- Entities, attributes, locations, resources,
processing logic, network, variables, graphics,
etc.
4Why Important to Model Uncertainty?
- The world is uncertain
- Replacing random quantities with averages or
single guesstimates can be dangerous - Allows prediction of distribution of results
- Not just one predicted number or outcome
- Sensitivity analysis of outputs to inputs
- Which inputs really affect the outputs?
5Hospital Based Pneumatic Tube Systems
- Ptube System Components
- Carriers contain products to be transported (e.g.
blood, meds) - Stations send receive carriers (user-interface)
- Stations belong to a zone
- One blower per zone
- Storage pipes connect zones
- Carriers sent across zones require two blower
moves - Entire system is computer controlled from central
site
6Why Simulate?
- Complex system - many controllable parameters
- Critical material handling system (e.g. EC to
Lab) - Expanding system capacity is expensive and
effects on performance are unpredictable - System vendors doing analysis? I dont think so!
- System creates detailed transaction data file
- Many priority queueing related system performance
measures (rob Peter to pay Paula)
Simulation provides low cost, low risk method for
improving system performance.
7Simulation Analysis of Pneumatic Tube Systems
Transaction Data
Simulation Input Machinery
Simulation Input Files
Output Reports
- Model validation - Scenario generation -
Scenario analysis
Computer Simulation Models
Simulation Output Analysis Machinery
Simulated Transaction Data
8Decision Support Framework
Operational Improvement
Ongoing Managerial Reporting
Advanced Reporting
Historical Data
Computer Simulation
New System Design
Input Data
System Expansion or Modification
Analysis of System Performance
Volume Forecasts and Design Proposals
9Cost Structure
- Huge range in pricing for simulation packages
- ARENA, ProModel, Taylor ED - 15K
- SILK (Java object library based) - 3K
- Extend - 1300
- ProcessModel - 1000
- Simul8 - 500
- Academic pricing differs dramatically
No comparison!
10A Few Industries
- Fast food operations (Burger King, Taco Bell)
- Telephone call-centers (telesales, technical
support, reservations, appointments) - Material handling systems
- Manufacturing systems
- Computer/communications systems
- Financial decisions (portfolio planning, capital
budgeting) - War games
- Biological systems (epidemics)
11Example of Specific Questions
- How does time spent waiting in line to order a
Whopper change if we add another staffed cash
register between 4p-6p? - What are the expected wait times and delivery
times in the proposed pneumatic tube system in
the hospital? - How does customer loyalty affect profit?
- How does the average and 90th percentile of
response time change in our computer network if
we increase bandwidth by 30? - What is the likelihood that this project will
have a negative NPV? What is the probability that
NPVgtX? - How do different organ allocation policies affect
the death rates among people on organ transplant
lists?
12Monte-Carlo Simulation ExampleBookstore
Inventory Problem (WALTON1.XLS)
- Bookstore needs to set order quantity for
calendar - Unit cost and selling price known
- Unsold calendars can be returned for partial
refund (amount known) - Demand unknown - probability distribution
- Decision Variable - order quantity
- Whats the best order quantity?
13Overview of Computer Simulation
- A technique for conducting experiments (such as
what-if analysis) with a computer on a model of a
management system. - Imitation of operation of real world process or
system over time using a computer - generates an artificial history of the process
- statistical inferences can be drawn from analysis
of this artificial history
14Monte-Carlo Simulation
- Quasi-static model often doesnt really capture
detailed flow of events over time - One or more random elements
- Often called Risk Analysis
- _at_RISK - Palisade Software
- Spreadsheets provide good environment
- Goes beyond expected values and point estimates
- Facilitates scenario analysis
15Building a Spreadsheet Based Simulation Model
- Build deterministic (no random quantities)
spreadsheet model first - Inputs
- Outputs
- Formulas that relate outputs to inputs
- Select inputs to treat as random or uncertain
- Model uncertain quantities with probability
distributions - Recalculate the spreadsheet many times
- Running the model
- Collect output data for each replication of the
model - Analyze the output
16Building a Spreadsheet Based Simulation Model
(1) Build deterministic model
Formulas
Inputs
Outputs
Deterministic Inputs
(2) Choose inputs to model as random
Inputs
Stochastic or Uncertain or Random Inputs
(3) Model uncertain inputs with probability
distributions
Uniform
Normal
Poisson
Exponential
Empirical
Many more
17Building a Spreadsheet Based Simulation Model
Running the model
(4.1) Manually, through formulas and either
many rows or VBA
(4) Recalculate spreadsheet many times
2 options
(4.2) Use spreadsheet simulation add-in such as
_at_Risk or Crystal Ball
- Crystal Ball
- www.decisioneering.com
- 686-1500
- academic pricing avail
- bundled with several texts
- Developer toolkits exist
- Many complementary products
- _at_Risk
- http//www.palisade.com/
- 695 for Prof. Edition
- academic pricing avail
- bundled with several texts
- Developer toolkits exist
- Many complementary products
18(5) Analyze outputs
Probability distribution of output variable, NOT
just expected value.
19The Bigger Picture
- Create several or many scenarios to simulation
- Input variable values (including parameters for
probability distributions - Perhaps model structure itself
- Analyze performance measures for each scenario
- Synthesize results
- Pick best system or best k out of n systems
- Interpret results and make decision
- Embed in optimization framework to formally
compare many scenarios with respect to some
objective function
20Some Advantages
- Often models can be reused
- Simulation often easier than analytical models
for complex systems - Simulation usually requires fewer simplifying
assumptions than analytical models - Simulation may provide only available approach to
analyzing complex systems
21Some Disadvantages
- Development may be time consuming
- Dazzle of the technique can mask flaws in design
and/or input data - Simple analytical models might be overlooked
- Run times may be long
- More difficult to embed within optimization
framework
22Revisiting Walton (WALTON1.XLS)
- Bookstore needs to set order quantity for
specific book - Unit cost and selling price known
- Unsold books can be returned for partial refund
(amount known) - Demand unknown - probability distribution
- Decision Variable - order quantity
- Whats the best order quantity?
23Accomplishments
- In the body of the simulation rows 19-1018, we
randomly generated 1000 possible demands and the
corresponding profits. - There are only five possible demand values and
also for our order quantity, 200, the profit is
500 regardless of whether demand is 200, 250, or
300. - There are 290 trials with profit equal to - 250,
227 trials with profit equal to 125, and 483
trials with profit equal to 500. (Answers may
differ because of the random numbers.) - The average of the 1000 profits is 197.38 and
their standard deviation is 328.58. (Answers may
differ because of the random numbers.)
24Probability Distributions
- The probability distribution of profit is as
follows - P(Profit -250) 290/1000 0.29
- P(Profit -125) 227/1000 0.227
- P(Profit -500) 483/1000 .483
- We also estimate the mean of this distribution to
be 197.38 and its standard deviation to be
328.58. - It is important to be aware that with computer
simulation each time it is run the answers will
be slightly different. - This is the reason for the confidence interval.
25Confidence Intervals
- The confidence intervals can be found in cells
E13 and E14. - This interval expresses our uncertainty about the
mean of the profit distribution. - Our best guess is the value we observed but
because the corresponding confidence interval is
very wide, from 177.43 to 217.32, we are not
sure of the true mean of the profit distribution.
26Confidence Intervals -- continued
- It is common in computer simulation to estimate
the mean of some distribution by the average of
1000 profits. - The usual practice is then to accompany this
estimate with a confidence interval, which
indicates the accuracy of the estimate. - You might recall from statistics that to obtain a
confidence interval for the mean, you start with
the estimated mean and then add and subtract a
multiple of the standard error of the estimated
mean.
27The large sample 100(1-a) CI on the sample mean
1-a
a/2
a/2
sample mean
S sample standard deviation
28Finding the Best Order Quantity
- So far we have ran the simulation for only a
single order quantity, 200. - Waltons ultimate goal is to find the best order
quantity - that is, the order quantity that
maximizes the mean profit. - This goal can be achieved by using a data table
to rerun the simulation for other order
quantities. - Should compare confidence intervals or do t-tests
on the mean profits to see if statistically
different results are obtained
29To Freeze or Not To Freeze
- In developing this simulation, we suggested that
you freeze the random numbers in column B. - If you neglect this step, every time you press
the F9 key or make any change to your spreadsheet
model, a new set of simulated answers will
appear. - However, the drawback is that once the random
numbers are frozen, you are stuck with that
particular set of random numbers.
30Using Data Tables to do Replications
- Open Walton2_Isken.xls
- Notice just one row of formulas for the model
- We take advantage of how Data Tables work to do
the spreadsheet recalculations
31Uniform Random Variables
- If XUniform(0,1) Then EX1/2 (expected value)
- X is equally likely to take any value between 0
and 1 - ProbabilityXltx x
- Excels RAND() function
32Uniform Random Numbers
- Building blocks of simulation
- Modeling randomness
- Basis for generating random variables
- Normal
- Exponential
- Poisson, etc.
- Excels RAND() function
- How do computers generate random numbers?
- All examples in RandNum_Isken.xls. Lets open it.
33Uniform Distribution Function
Implication of shape of distribution?
Question
How could you use a U(0,1) number to create a
random number between a and b? Lets do it in
RandNum_Isken.xls
34How do computers generate U(0,1) random variables?
- Pseudo-random number generators
- not really random
- actually based on deterministic formulas
- Important considerations
- method should be fast
- shouldnt require lots of memory
- long cycle (different numbers generated before
sequence repeats) - should be replicable
- should approximate statistical properties of
uniformity and independence
35Linear Congruential Method
Xi1 (aXi c) mod m, i0, 1, 2, ...
- X0 is the seed
- a - constant multiplier
- c - increment
- m - modulus
- Values of a, c, m and seed greatly affect
statistical properties and cycle length. - Recall that (a mod b) is remainder from a/b
- Generates numbers between 0 and (m-1)
- Xi/m is the sequence of random numbers used in
the simulation
36Linear Congruential Method - Example
Xi1 (aXi c) mod m, i0, 1, 2, ...
- X0 123,457
- a 16,807
- c 0
- m 231-1 2,147,483,647
- These values used in IMSL Scientific Subroutine
Package (FORTRAN)
37Using U(0,1)s to generate other random variables
Find U(0,1) random number in cumulative
distribution of random variable you want to
generate.
Return value of random variable.
38Using U(0,1)s to generate Normal random variables
NORMDIST(122.57,160,40,TRUE).1747
NORMINV(.1747,160,40)122.57
Random 122.57
39First peek at _at_Risk
- _at_Risk is a widely used Excel add-in that
facilitates creation and analysis of spreadsheet
based simulation models - Contains many probability distributions for
modeling random inputs - Includes tool (BestFit) for fitting input
distributions - Automates bookkeeping for running many simulation
replications and creates a ton of tabular and
graphical output reports - WaltonRisk_Isken.xls (prep for next time)