You are on page 1of 59

1

2
Simulation
• Simulation
– A descriptive tool for the study of the behavior
of a system under various conditions.
– The goal in simulation is to create a model that
will reflect the behavior of some real-life
system in order to be able to observe how it
may behave when certain inputs or parameters
are changed.
– Unlike analytical techniques, it is not an
optimizing technique.
Simulation vs Optimization
In an optimization model, the values of the decision variables are
outputs.
The result of the model is a set of values for the decision variables
that will maximize (or minimize) the value of the objective
function.

In a simulation model, the values of the decision variables are


inputs. The model evaluates the objective function for a particular
set of values.

The result of the model is a measure of the quality of a suggested


solution and the variability in various performance measures due to
randomness in the inputs.
4
Types of Simulations

• Discrete Simulations
– Experimental situations in which outcome
variables are discrete and are described by a
count of the number of occurrences.
• Continuous Simulations
– Experimental situations in which the variable of
interest is continuous in that it can assume both
integer and noninteger values over a range of
values that are measured rather than counted.
Types of Simulations (cont’d)
• Fixed-Interval Simulations
– Experiments simulating the value of a variable
over a given or fixed interval of time, distance
or area.
– Interest is centered on the accumulated value of
a variable over a length of time or other
interval.
• Next-Event Simulations
– Experiments focused on when something
happens, or how much time is required to
perform a task.
Types of Simulations (cont’d)

• Deterministic Simulations
– Cases in which a specific outcome is certain,
given a set of inputs.
• Probabilistic Simulations
– Cases that involve random variables and,
therefore, the exact outcome cannot be
predicted with certainty, given a set of inputs.
– Cases that incorporate some mechanism for
mimicking random behavior in one or more
variables.
Steps in Simulation
1. Problem formulation Phase 1
Problem Definition
2. Set objectives and overall project plan

4. Data Collection
Phase 2
3. Model conceptualization
Model Building
5. Model Translation

No Phase 3
6. Verified
Yes Experimentation
No No
7. Validated
Yes
8. Experimental Design
Phase 4
Implementation
9. Model runs and analysis

Yes No 11. Documentation, reporting and


10. More runs 8
implementation
Verification (efficiency)

• Is the model correctly built/programmed?


• Is it doing what it is intended to do?

Validation (effectiveness)
• Is the right model built?
• Does the model adequately describe the reality you
want to model?
• Does the involved decision makers trust the model?

Two of the most important and most challenging


issues in performing a simulation study

9
Steps in Simulation
Define the
problem
Set objectives

Develop model

Gather data

Validate model

Design
experiments

Run simulations

Analyze and
interpret results
The Monte Carlo Method

• Monte Carlo Simulation


– A commonly used approach for achieving
randomness that derives its name from its
similarity to games of chance.
• Characteristics of random numbers
– All numbers are equally likely.
– No patterns appear in sequences of numbers.
Random Numbers
Two Common Types of Multiple-
Variable Simulations
Design of Docking Facilities. In the following model,
trucks of different sizes carrying different types of loads,
arrive at a warehouse to be unloaded.

D D D
T o T o T o
r c r c r c
u k u k u k
c 3 c 2 c 1
k k k
Exit Entrance

Truck waiting Truck waiting


14
The uncertainties are:
When will a truck arrive?
What kind and size of load will it be carrying?
How long will it take to unload the trucks?
Each uncertain quantity would be a random variable
characterized by a probability distribution.
The planners must address a variety of design
questions:
How many docks should be built?
What type and quantity of material-handling
equipment are required?
How many workers are required over what
15
periods of time?
The design of the unloading dock will affect its cost of
construction and operation. Management must balance
the cost of acquiring and using the various resources
against the cost of having trucks wait to be unloaded.

16
Determination of Inventory Control Policies. Simulation
can be used to study inventory control models.

Factory

Warehouse 1 Warehouse 2 Warehouse 3

Demand Demand Demand

In this model, the factory produces goods that are sent


to the warehouses to satisfy customer demand.

The random variables are: daily demand at each


warehouse and shipping times from factory to
17
warehouse.
Simulation can be used to study inventory control
models.
Some of the operational questions are:
When should a warehouse reorder from the
factory and how much?
How much stock should the factory maintain to
satisfy the orders of the warehouses?
The main costs are:
Cost of holding the inventory
Cost of shipping goods from a factory to a
warehouse
Cost of not being able to satisfy customer
demand at the warehouse
The objective is to find a stocking and ordering policy
18
that keeps the total cost low while meeting demand.
The Cumulative Distribution Function (CDF). Consider a
random variable, D, the demand. The CDF for D [called
F(x)] is then defined as the probability that D takes on a
value < x.
F(x) = Prob{D < x}

Knowing the probability distribution for D, the CDF for


key values of D is:

X 8 9 10 11 12 13
F(x) 0.1 0.3 0.6 0.8 0.9 1.0
Here is a graph of the CDF. To generate a discrete
demand using the graph:

Probability
1.2
Step 1: Locate
the particular F(x)
1 value of U on
this axis
0.8

0.6 u Step 2: Read the


particular value
0.4 of the random
quantity, d, on
0.2 this axis
d
0 x

7 8 9 10 11 12 13 14
20
Suppose you want to model a discrete uniform
distribution of demand where the values of 8 through 12
all have the same probability of occurring (uniform,
equally likely).
The spreadsheet has a function, =RAND(), that returns a
random number between 0 and 1. However, this will
result in a continuous uniform distribution.
To create a discrete uniform distribution, use the INT()
function. For example:

In general, if you want a discrete, uniform distribution of


integer values between x and y, use the formula:
21
INT(x + (y – x + 1)*RAND() )
THE GENERAL METHOD
APPLIED TO CONTINUOUS DISTRIBUTIONS:
The two-step process for generating a continuous
random variable W is shown below: The cumulative
Probability distribution
1.1
F(x)=Prob{W<x} function of W
1
0.9 u
0.8 As before, first
0.7 locate the value
0.6 (u) of the random
0.5 variable U
0.4 F(w)
0.3
0.2
Then, read the
0.1 w particular value of
0 the random
0 1 2 3 4 5 6 7 8 9 x
10 quantity, W, on
this axis
22
Assigning Random Numbers for
the Replacement Parts Example
Conversion of a Random Number to
a Uniform Distribution
Generating from the Exponential Distribution.
The exponential distribution is often used to model the
time between arrivals in a queuing model. Its CDF is
given by:
F(x) = Prob{t>T} = e-lT

Where 1/l is the mean of the random variable T.

Therefore, we want to solve the following equation for w:


u = e-lT

The solution is: T = -1/l ln(u)


where we can get “u” from Random number which
represents cumulative distribution function
25
Generating from the Normal Distribution.
The normal distribution plays an important role in many
simulation and analytic models.
Consider drawing a random demand from a normal
distribution with a mean (m) of 1000 and a standard
deviation (s) of 100.
If Z is a unit normal random variable (normally
distributed with a mean of 0 and a standard deviation of
1) then m + Zs is a normal random variable with mean m
and standard deviation s.
So, we can draw from a unit normal distribution. Excel
has a built-in function that can do this:
= NORMINV( RAND() , 1000, 100)
Excel will automatically return a normally distributed
26
random number with mean 1000 and std. dev. 100.
60 Random Numbers Generated
by the RAND() Function
200 Random Numbers
Generated Between 0 and 100
200 Uniform Discrete Random Numbers
Generated Between 20 and 100
QUEING MODELS

30
QUEUE PROBLEM- M/M/1—
USE SIMULATION & COMPARE
• Assume a small branch office of a local bank with only
one teller.
• Empirical data gathering indicates that inter-arrival
and service times are exponentially distributed.
– The average arrival rate = l = 5 customers per hour
– The average service rate = m = 6 customers per hour
• Using our knowledge of queuing theory we obtain
–  = the server utilization = 5/6  0.83
– Lq = the average number of people waiting in line
– Wq = the average time spent waiting in line

Lq = 0.832/(1-0.83)  4.2 Wq = Lq/ l  4.2/5  0.83


• How do we go about simulating this system?
– How do the simulation results match the analytical ones? 31
MAINTAINANCE PROBLEM

32
Corrective Maintenance versus
Preventive Maintenance
• The Heavy Duty Company has just purchased a large machine for a
new production process.
• The machine is powered by a motor that occasionally breaks down and
requires a major overhaul. Therefore, a second standby motor is kept,
and the two motors are rotated in use.
• The breakdowns always occur on the fourth, fifth, or sixth day that the
motor is in use. Fortunately, it takes fewer than three days to overhaul
a motor, so a replacement is always ready.

Cost of Replacement Cycle that Begins with Breakdown


Replace a Motor $2,000
Lost production during replacement 5,000
Overhaul a motor 4,000
33
Total $11,000
Probability Distribution of Breakdowns

Probability of Corresponding
Day a Breakdown Random Numbers
1, 2, 3 0
4 0.25 0.0000 to 0.2499
5 0.5 0.2500 to 0.7499
6 0.25 0.7500 to 0.9999
7 or more

34
Computer Simulation of Corrective
Maintenance
Random Time Since Last Cumulative Cumulative Distribution of
Breakdown Number Breakdown Day Cost Cost Time Between Breakdowns
1 0.5304 5 5 $11,000 $11,000 Number
2 0.6585 5 10 $11,000 $22,000 Prob Cumu. Prob
no. of Days
3 0.8922 6 16 $11,000 $33,000 0.25 0 4
4 0.7599 6 22 $11,000 $44,000 0.5 0.25 5
5 0.7965 6 28 $11,000 $55,000 0.25 0.75 6
6 0.3225 5 33 $11,000 $66,000
7 0.9594 6 39 $11,000 $77,000 Breakd $11,000
8 0.9747 6 45 $11,000 $88,000 own
9 0.0367 4 49 $11,000 $99,000 Cost
10 0.1526 4 53 $11,000 $1,10,000
26 0.6292 5 132 $11,000 $2,86,000
27 0.5751 5 137 $11,000 $2,97,000
28 0.4455 5 142 $11,000 $3,08,000
29 0.2885 5 147 $11,000 $3,19,000 Average Cost per Day
30 0.9201 6 153 $11,000 $3,30,000 $2,157

35
Preventive Maintenance Options
• Preventive maintenance would involve scheduling the motor to be
removed (and replaced) for an overhaul at a certain time, even if a
breakdown has not occurred.
• The goal is to provide maintenance early enough to prevent a
breakdown.
• Scheduling the overhaul enables removing and replacing the
motor at a convenient time when the machine is not in use, so no
production is lost.

Cost of Replacement Cycle that Begins without a Breakdown


Replace a motor on overtime $3,000
Lost production during replacement 0
Overhaul a motor before a breakdown 3,000
36
Total $6,000
Replace Motor After 5 Days
Random Time Until Scheduled Time Event That Cumulative Cumulative Distribution of
Cycle Number Breakdown Until Replacement Concludes Cycle Day Cost Cost Time Between Breakdowns
1 0.3543 5 5 Breakdown 5 $11,000 $11,000 Number
2 0.2204 4 5 Breakdown 9 $11,000 $22,000 Probability Cumulative of Days
3 0.0583 4 5 Breakdown 13 $11,000 $33,000 0.25 0 4
4 0.8282 6 5 Replacement 18 $6,000 $39,000 0.5 0.25 5
5 0.9815 6 5 Replacement 23 $6,000 $45,000 0.25 0.75 6
6 0.4620 5 5 Breakdown 28 $11,000 $56,000
7 0.7658 6 5 Replacement 33 $6,000 $62,000 Breakdown Cost $11,000
8 0.4318 5 5 Breakdown 38 $11,000 $73,000 Replacement Cost $6,000
9 0.8745 6 5 Replacement 43 $6,000 $79,000
10 0.9448 6 5 Replacement 48 $6,000 $85,000 Replace After 5 days
11 0.0987 4 5 Breakdown 52 $11,000 $96,000
12 0.5796 5 5 Breakdown 57 $11,000 $107,000
13 0.7489 5 5 Breakdown 62 $11,000 $118,000
14 0.2480 4 5 Breakdown 66 $11,000 $129,000
15 0.5809 5 5 Breakdown 71 $11,000 $140,000
16 0.9055 6 5 Replacement 76 $6,000 $146,000
17 0.5844 5 5 Breakdown 81 $11,000 $157,000
18 0.0157 4 5 Breakdown 85 $11,000 $168,000
19 0.0949 4 5 Breakdown 89 $11,000 $179,000
20 0.1892 4 5 Breakdown 93 $11,000 $190,000
21 0.9239 6 5 Replacement 98 $6,000 $196,000
22 0.1051 4 5 Breakdown 102 $11,000 $207,000
23 0.8739 6 5 Replacement 107 $6,000 $213,000
24 0.5229 5 5 Breakdown 112 $11,000 $224,000
25 0.6667 5 5 Breakdown 117 $11,000 $235,000
26 0.3945 5 5 Breakdown 122 $11,000 $246,000
27 0.7721 6 5 Replacement 127 $6,000 $252,000
28 0.2253 4 5 Breakdown 131 $11,000 $263,000
29 0.6972 5 5 Breakdown 136 $11,000 $274,000 Average Cost per Day
30 0.5078 5 5 Breakdown 141 $11,000 $285,000 $2,021 37
Random
Replace Motor on 4 Days
Time Until Scheduled Time Event That Cumulative Cumulative Distribution of
Cycle Number Breakdown Until ReplacementConcludes Cycle Day Cost Cost Time Between Breakdowns
1 0.3926 5 4 Replacement 4 $6,000 $6,000 Number
2 0.4904 5 4 Replacement 8 $6,000 $12,000 Probability Cumulative of Days
3 0.8207 6 4 Replacement 12 $6,000 $18,000 0.25 0 4
4 0.6811 5 4 Replacement 16 $6,000 $24,000 0.5 0.25 5
5 0.1084 4 4 Breakdown 20 $11,000 $35,000 0.25 0.75 6
6 0.1032 4 4 Breakdown 24 $11,000 $46,000
7 0.5737 5 4 Replacement 28 $6,000 $52,000 Breakdown Cost $11,000
8 0.0718 4 4 Breakdown 32 $11,000 $63,000 Replacement Cost $6,000
9 0.5408 5 4 Replacement 36 $6,000 $69,000
10 0.9918 6 4 Replacement 40 $6,000 $75,000 Replace After 4 days
11 0.9948 6 4 Replacement 44 $6,000 $81,000
12 0.1657 4 4 Breakdown 48 $11,000 $92,000
13 0.1035 4 4 Breakdown 52 $11,000 $103,000
14 0.3365 5 4 Replacement 56 $6,000 $109,000
15 0.1650 4 4 Breakdown 60 $11,000 $120,000
16 0.4908 5 4 Replacement 64 $6,000 $126,000
17 0.0267 4 4 Breakdown 68 $11,000 $137,000
18 0.1388 4 4 Breakdown 72 $11,000 $148,000
19 0.9297 6 4 Replacement 76 $6,000 $154,000
20 0.5908 5 4 Replacement 80 $6,000 $160,000
21 0.1035 4 4 Breakdown 84 $11,000 $171,000
22 0.6132 5 4 Replacement 88 $6,000 $177,000
23 0.5361 5 4 Replacement 92 $6,000 $183,000
24 0.0726 4 4 Breakdown 96 $11,000 $194,000
25 0.0593 4 4 Breakdown 100 $11,000 $205,000
26 0.7241 5 4 Replacement 104 $6,000 $211,000
27 0.3092 5 4 Replacement 108 $6,000 $217,000
28 0.4092 5 4 Replacement 112 $6,000 $223,000 38
29 0.2356 4 4 Breakdown 116 $11,000 $234,000 Average Cost per Day
30 0.6483 5 4 Replacement 120 $6,000 $240,000 $2,000
Inventory Problem

The daily demand of an item has the following distribution:

Demand per day 0 1 2 3 4 5


(units)
No. of days on which 4 10 15 39 22 10
demand occurred

When an order is placed to replenish inventory there is a delivery time


lag, which follows the following distribution:

Lead time (days) 2 3 4


No. of times of 24 12 4
occurrence

The management is of the opinion that proportion of stockouts should


not exceed 5%.
39
Newspaper Boy Problem
• Newsvendor sells newspapers on the street
– Buys for c = $0.55 each, sells for r = $1.00 each
• Each morning, buys q copies
– q is a fixed number, same every day
• Demand during a day: D = max (X, 0)
– X ~ normal (m = 135.7, s = 27.1), from historical data
– X rounds X to nearest integer
• If D  q, satisfy all demand, and q – D  0 left over, sell for
scrap at s = $0.03 each
• If D > q, sells out (sells all q copies), no scrap
– But missed out on D – q > 0 sales
• What should q be? 40
Newspaper Boy Problem – Formulation

• Choose q to maximize expected profit per day


– q too small – sell out, miss $0.45 profit per paper
– q too big – have left over, scrap at a loss of $0.52 per paper
• Classic operations-research problem
– Many versions, variants, extensions, applications
– Much research on exact solution in certain cases
– But easy to simulate, even in a spreadsheet
• Profit in a day, as a function of q:
W(q) = r min (D, q) + s max (q – D, 0) – cq
Sales revenue Scrap revenue Cost
– W(q) is a random variable – profit varies from day to day
• Maximize E(W(q)) over nonnegative integers q
41
Steps: Newspaper boy Problem –
Simulation
• Set trial value of q, generate demand D, compute profit for
that day
– Then repeat this for many days independently, average
to estimate E(W(q))
• Also get confidence interval, estimate of P(loss),
histogram of W(q)
– Try for a range of values of q
• Need to generate demand D = max (X, 0)
– So need to generate X ~ normal (m = 135.7, s = 27.1)
42
•Demands = MAX(ROUND(NORMINV(RAND(),µ, σ), 0)
Advantages of Simulation

1. It is particularly well-suited for problems that are difficult


or impossible to solve mathematically.
2. It allows an analyst or decision maker to experiment with
system behavior in a controlled environment instead of in
a real-life setting that has inherent risks.
3. It enables a decision maker to compress time in order to
evaluate the long-term effects of various alternatives.
4. It can serve as a mode for training decision makers by
enabling them to observe the behavior of a system under
different conditions.
Limitations of Simulation

• Probabilistic simulation results are approximations, rather


than optimal solutions.
• Good simulations can be costly and time-consuming to
develop properly; they also can be time-consuming to run,
especially in cases in which a large number of trials are
indicated.
• A certain amount of expertise is required in order to
design a good simulation, and this may not be readily
available.
• Analytical techniques may be available that can provide
better answers to problems.
A GENERALIZED METHOD:
To generate a discrete random variable with the RAND()
function in a spreadsheet, two things are needed:
1. The ability to generate discrete uniform random
variables
2. The distribution of the discrete random variable
to be generated

To generate a continuous random variable, two things


are needed:
1. The ability to generate continuous uniform
random variables on the interval 0 to 1
2. The distribution (in the form of the cumulative
distribution function) of the random variable to
45
be generated
CAPITAL BUDGETING
PROBLEM

46
A CAPITAL BUDGETING EXAMPLE:
ADDING A NEW PRODUCT LINE
Airbus Industry is considering adding a new jet airplane
(model A3XX) to its product line. The following financial
information is available:
Startup Costs $150,000
Sales Price $ 35,000
Fixed Costs (per year) $ 15,000
Variable Costs (per year) 75% of revenues

Tax depreciation on the new equipment would be


$10,000 per year over the 4 year expected product life.
Salvage value of the equipment at the end of the 4 years
is estimated to be 0.
Airbus’ cost of capital is 10% and tax rate is 34%. 47
If demand is known, then a spreadsheet can be used to
calculate the net present value (NPV). For example,
assume that the demand for A3XXs is 10 units for each
of the next 4 years:

=C16 + C13

=NPV($D$3,C17:F17)+B17

=-$B$2 48
THE MODEL WITH RANDOM DEMAND
It is unlikely that demand will be the same every year. A
more realistic model would be one in which demand
each year is a sequence of random variables.
This model of demand is appropriate when there is a
constant base level of demand that is subject to random
fluctuations from year to year.
Sampling Demand with a Spreadsheet: Assume initially
that the demand in a year will be either 8, 9, 10, 11, or 12
units with each value being equally likely to occur.
This is an example of a discrete uniform distribution.
Now, use the formula =INT(8 + 5*RAND() ) to sample
from a discrete uniform distribution on the integers 8, 9,
10, 11, 12 .
Multiple trials can be performed by pressing the 49
recalculation key for the spreadsheet (e.g., F9).
Using this formula results in random demands.

=INT(8+5*RAND() )

Hitting the F9 key would result in a different sample of


demands, and possibly a different NPV.
The demands are random variables, therefore, the NPV 50
is also a random variable.
EVALUATING THE PROPOSAL
Two questions need to be answered about the NPV
distribution:

1. What is the mean or expected value of the NPV?

2. What is the probability that the NPV assumes a


negative value (making the proposal to add the
A3XX less attractive)?

To answer these questions, a simulation model must be


built. To run the simulation automatically and capture
the resulting NPV in a separate spreadsheet, use the
Data Table command.

51
The resulting analysis gives the estimated mean NPV
and standard deviation.

Downside Risk and Upside Risk: To get a better idea


about the range of possible NPVs that could occur, look
59
at the minimum and maximum NPVs.
In the resulting analysis, the Frequency (column B)
indicates the number of trials that fell into the bins
(categories) defined by column A.

The cumulative % column indicates the cumulative


percentage of observations that fall into each category
61
or bin.
The histogram gives a visual representation of the
distribution of NPVs. Note that it is somewhat bell
shaped.

62
How Reliable is the Simulation? Now the two questions
about the distribution can be answered:
1. What is the mean or expected value of the NPV?
In this trial, the mean is $12,100.

2. What is the probability that the NPV assumes a


negative value (making the proposal to add the
A3XX less attractive)?
In this trial, the probability is <15%.

The next questions to ask are:


1. How much confidence do we have in the answers
from the first trial?
2. Would we be more confident if we ran more trials?
63
For a 95% confidence interval, the formula is:
estimated mean + 1.96(standard deviation)
In this case, the standard deviation is the standard error
(the standard deviation divided by the square root of the
number of trials).
Based on this trial, the upper and lower confidence
limits are: =$E$4-1.96*$E$8/SQRT($E$16)

=$E$4+1.96*$E$8/SQRT($E$16)
So, we have 95% confidence that the true mean NPV is
64
somewhere between $9,679 and $14,521.
THE MODEL WITH RANDOM DEMAND
It is unlikely that demand will be the same every year. A
more realistic model would be one in which demand
each year is a sequence of random variables.
This model of demand is appropriate when there is a
constant base level of demand that is subject to random
fluctuations from year to year.
Sampling Demand with a Spreadsheet: Assume initially
that the demand in a year will be either 8, 9, 10, 11, or 12
units with each value being equally likely to occur.
This is an example of a discrete
uniform distribution.

65
OTHER DISTRIBUTIONS OF DEMAND
Originally, we started with equal mean demands of 10 for
each period (year). Then, we allowed for random
variation in mean demand (between 8 and 12 units) and
discrete distribution.

Now, assume the mean demand will stay the same over
the next four years, somewhere between 6 and 14 units a
year, with all values being equally likely.
This scenario can be modeled as a continuous, uniform
distribution between 6 and 14.

In addition, we can explore the impact of different


demand distributions on the NPV.
66
THANK YOU

67

You might also like