Simulation Modeling Workshop
Simulation Modeling Workshop
Deterministic
Stochastic
Mathematical Model
Deterministic
Stochastic
A Monte Carlo simulation model is a model that uses random numbers to simulate
behavior of a situation. Using either a known probability distribution (such as uniform,
exponential, or normal) or an empirical probability distribution, a modeler assigns a behavior to a
specific range of random numbers. The behavior returned from the random number generated is
then used in analyzing the problem. For example, if a modeler is simulating the tossing of a fair
coin using a uniform random number generator that gives numbers in the range 0 x < 1, he or
she may assign all numbers less than 0.5 to be a "head" while numbers from 0.5 to 1 are "tails".
We simplify the important part in figure 2.
good and bad random number generators, and the tests that can be made on them. More and more
is being learned about what makes up a "true" random number generator and what does not. At
the undergraduate level, this is not necessary provided the students have access to either random
numbers or a good algorithm for generating pseudo-random numbers.
Additionally, most computer languages now use good pseudo-random number generators
(although this has not always been the case - the old RANDU generator distributed by IBM was
statistically unsound). These good generators use the recursive sequence Xi ( aXi 1 c ) mod m
where a, c, and m determine the statistical quality of the generator. Since we do not discuss the
testing of random number generators in our course, we "trust" the generators provided by our
software packages. Serious study of simulation must, of course, include a study of random
number generators since a bad generator will provide output from which a modeler may make
poor conclusions.
EXCEL has several choices to generate random numbers.
RAND
Returns an evenly distributed random real number greater than or equal to 0 and less
than 1. A new random real number is returned every time the worksheet is calculated.
Syntax
RAND( )
Remarks
If you want to use RAND to generate a random number but don't want the
numbers to change every time the cell is calculated, you can enter =RAND() in
the formula bar, and then press F9 to change the formula to a random number.
Example
RANDBETWEEN
s a random integer number between the numbers you specify. A
new random integer number is returned every time the worksheet is
calculated.
Return
Syntax
RANDBETWEEN(bottom,top)
Bottom is the smallest integer RANDBETWEEN will return.
Top is the largest integer RANDBETWEEN will return.
Example
1.
A
Formula
1 =RANDBETWEEN(1,1
2 00)
3 =RANDBETWEEN(1,1)
B
Description (Result)
Random number between 1 and 100
(varies)
Random number between -1 and 1
(varies)
This article was adapted from Microsoft Excel Data Analysis and Business Modeling by Wayne L.
Winston. Visit Microsoft Learning to learn more about this book.
This classroom-style book was developed from a series of presentations by Wayne Winston, a
well known statistician and business professor who specializes in creative, practical
applications of Excel. So be prepared you may need to put your thinking cap on.
In this article
Who uses Monte Carlo simulation?
What happens when I enter =RAND() in a cell?
How can I simulate values of a discrete random variable?
How can I simulate values of a normal random variable?
How should a greeting card company determine how many cards to produce?
The impact of risk on our decision
Confidence interval for mean profit
Problems
Sample files You can download the sample files that relate to excerpts from Microsoft Excel Data Analysis
and Business Modeling from Microsoft Office Online. This article uses the files RandDemo.xls,
Discretesim.xls, NormalSim.xls, and Valentine.xls.
We would like to be able to accurately estimate the probabilities of uncertain events. For example, what is
the probability that a new products cash flows will have a positive net present value (NPV)? What is the
riskiness of our investment portfolio? Monte Carlo simulation enables us to model situations that present
uncertainty and play them out thousands of times on a computer.
Note The name Monte Carlo simulation comes from the fact that during the 1930s and 1940s, many
computer simulations were performed to estimate the probability that the chain reaction needed for the atom
bomb would work successfully. The physicists involved in this work were big fans of gambling, so they gave
the simulations the code name Monte Carlo.
Note When you open the file RandDemo.xls, you will not see the same random numbers shown in the
previous figure. The RAND function always recalculates the numbers it generates when a spreadsheet is
opened or new information is entered in the spreadsheet.
I copied from cell C3 to C4:C402 the formula =RAND(). I named the range C3:C402 Data. Then, in column
F, I tracked the average of the 400 random numbers (cell F2) and used the COUNTIF function to determine
the fractions that are between 0 and .25, .25 and .50, .50 and .75 and .75 and 1. When you press the F9
key, the random numbers are recalculated. Notice that the average of the 400 numbers is always near .5
and that around 25 percent of the results are in each interval of .25. These results are consistent with the
definition of a random number. Also note that the values generated by RAND in different cells are
independent. For example, if the random number generated in cell C3 is a large number (say .99), this tells
us nothing about the values of the other random numbers generated.
Probability
10,000
.10
20,000
.35
40,000
.3
60,000
.25
How can we have Excel play out, or simulate, this demand for calendars many times? The trick is to
associate each possible value of the RAND function with a possible demand for calendars. The following
assignment ensures that a demand of 10,000 will occur 10 percent of the time, and so on.
Deman
d
10,000
20,000
40,000
60,000
To see a simulation of demand, look at the file Discretesim.xls, shown in the following figure.
The key to our simulation is to use a random number to key a lookup from the table range F2:G5 (named
lookup). Random numbers greater than or equal to 0 and less than .10 will yield a demand of 10,000;
random numbers greater than or equal to .10 and less than .45 will yield a demand of 20,000; random
numbers greater than or equal to .45 and less than .75 will yield a demand of 40,000; and random numbers
greater than or equal to .75 will yield a demand of 60,000. I generated 400 random numbers by copying from
C3 to C4:C402 the formula RAND(). Then I generated 400 trials or iterations of calendar demand by copying
from B3 to B4:B402 the formula VLOOKUP(C3,lookup,2). This formula ensures that any random number
less than .10 generates a demand of 10,000; any random number between .10 and .45 generates a demand
of 20,000, and so on. In the cell range F8:F11, I used the COUNTIF function to determine the fraction of our
400 iterations yielding each demand. Note that whenever you press F9 to recalculate the random numbers,
the simulated probabilities are close to our assumed demand probabilities.
Lets suppose we want to simulate 400 trials or iterations for a normal random variable with a mean of
40,000 and a standard deviation of 10,000. (I entered these values in cells E1 and E2 and named these
cells mean and sigma, respectively.) Copying the formula =RAND() from C4 to C5:C403 generates 400
different random numbers. Copying from B4 to B5:B403 the formula NORMINV(C4,mean,sigma) generates
400 different trial values from a normal random variable with a mean of 40,000 and a standard deviation of
10,000. When we press the F9 key to recalculate the random numbers, the mean remains close to 40,000
and the standard deviation close to 10,000.
Essentially, for a random number x, the formula NORMINV(p, mu , sigma) generates the pth percentile of a
normal random variable with a mean mu and a standard deviation sigma. For example, the random
number .8466 in cell C13 generates in cell B13 approximately the 85th percentile of a normal random
variable with a mean of 40,000 and a standard deviation of 10,000.
Probability
d
10,000
.10
20,000
.35
40,000
.3
60,000
.25
The greeting card sells for $4.00, and the variable cost of producing each card is $1.50. Leftover cards must
be disposed of at a cost of $0.20 per card. How many cards should be printed?
Basically, we simulate each possible production quantity (10,000, 20,000, 40,000 or 60,000) many times
(say, 1,000 iterations). Then we determine which order quantity yields the maximum average profit over the
1,000 iterations. You can find the work for this section in the file Valentine.xls, shown in the following figure.
Ive assigned the range names in cells B1:B11 to cells C1:C11. Ive assigned the cell range G3:H6 the name
lookup. Our sales price and cost parameters are entered in cells C4:C6.
I then enter a trial production quantity (40,000 in this example) in cell C1. Next I create a random number in
cell C2 with the formula =RAND(). As previously described, I simulate demand for the card in cell C3 with
the formula VLOOKUP(rand,lookup,2). (In the VLOOKUP formula, rand is the cell name assigned to cell C3,
not the RAND function.)
The number of units sold is the smaller of our production quantity and demand. In cell C8, I compute our
revenue with the formula MIN(produced,demand)*unit_price. In cell C9, I compute total production cost with
the formula produced*unit_prod_cost.
If we produce more cards than are demanded, the number of units left over equals production minus
demand; otherwise no units are left over. We compute our disposal cost in cell C10 with the formula
unit_disp_cost*IF(produced>demand,produced-demand,0). Finally, in cell C11, we compute our profit as
revenue-total_var_cost-total_disposing_cost.
We would like an efficient way to press F9 many (say 1,000 times) for each production quantity and tally up
our expected profit for each production quantity. This situation is one in which a two-way data table comes to
our rescue. The data table I used in this example is shown in the following figure.
In the cell range A16:A1015, I entered the numbers 1-1000 (corresponding to our 1,000 trials). One easy
way to create these values is to enter a 1 in cell A16, select the cell, and then, on the Edit menu, click Fill
Series. In the Series dialog box, shown in the following figure, enter a step value of 1 and a stop value of
1000. Under Series in, click Columns, and then click OK. The numbers 1 through 1000 will be entered
automatically in column A, starting in cell A16.
Next we enter our possible production quantities (10,000, 20,000, 40,000, 60,000) in cells B15:E15. We
want to calculate profit for each trial number (1 through 1,000) and each production quantity. We refer to the
formula for profit (calculated in cell C11) in the upper left cell of our data table (A15) by entering =C11.
We are now ready to trick Excel into simulating 1,000 iterations of demand for each production quantity.
Select the table range (A15:E1014), and then click Table on the Data menu. To set up a two-way data table,
we select any blank cell (we chose cell I14) as our column input cell and choose our production quantity (cell
C1) as the row input cell. When you click OK, Excel simulates 1,000 demand values for each order quantity.
To illustrate why this works, consider the values placed by the data table in the cell range C16:C1015. For
each of these cells, Excel will use a value of 20,000 in cell C1. In C16, the column input cell value of 1 is
placed in a blank cell and the random number in cell C2 recalculates. The corresponding profit is then
recorded in cell C16. Then the column cell input value of 2 is placed in a blank cell, and the random number
in C2 again recalculates. The corresponding profit is entered in cell C17.
By copying from cell B13 to C13:E13 the formula AVERAGE(B16:B1015), we compute average simulated
profit for each production quantity. By copying the formula STDEV (B16:B1015) from cell B14 to C14:E14,
we compute the standard deviation of our simulated profits for each order quantity. Each time we press F9,
1,000 iterations of demand are simulated for each order quantity. Producing 40,000 cards always yields the
largest expected profit. Therefore, it appears as if producing 40,000 cards is the proper decision.
In cell J11, I computed the lower limit for the 95 percent confidence interval on mean profit when 40,000
calendars are produced with the formula D13-1.96*D14/SQRT(1000). In cell J12, I computed the upper limit
for our 95 percent confidence interval with the formula D13+1.96*D14/SQRT(1000). These calculations are
shown in the following figure.
We are 95 percent sure that our mean profit when 40,000 calendars are ordered is between $53,860 and
$59,934.
Problems
1.
A GMC dealer believes that demand for 2005 Envoys will be normally distributed with a mean of
200 and standard deviation of 30. His cost of receiving an Envoy is $25,000, and he sells an Envoy for
$40,000. Half of all leftover Envoys can be sold for $30,000. He is considering ordering 200, 220, 240,
260, 280, or 300 Envoys. How many should he order?
2.
A small supermarket is trying to determine how many copies of People magazine they should
order each week. They believe their demand for People is governed by the following discrete random
variable.
Deman
d
3.
Probability
15
.10
20
.20
25
.30
30
.25
35
.15
The supermarket pays $1.00 for each copy of People and sells each copy for $1.95. They can
return each unsold copy of People for $0.50. How many copies of People should the store order?
SIMULATION EXAMPLES
Lets consider the following one of the follwoing deterministic examples.
We will present algorithms for their models as well as produce output to analyze. These
algorithms are critical to the understanding of simulation as a mathematical modeling tool.
Here is a generic framework for an algorithm. This framework includes Inputs, Outputs, and the
steps required to achieve the desired output.
Deterministic Example
Consider the area under the curve: y x 3 from 0 x 2 . A graphical illustration is
provided in Figure 3.
The algorithm for determining the area under a nonnegative curve between [a,b] is described in
figure 4.
INPUT
OUTPUT
The approximate area under the curve, f(x) over the interval [a,b]
Step 4.
Calculate f(xi)
Step 5.
Step 6.
counter
N
Stop
We begin with an easy function, such as y x 3 , over the interval [0, 2]. We can easily
integrate the function and find the answer.
2
x dx 4
3
Now they are ready to approximate the area by Monte Carlo simulation. The simulation only
approximates the solution. We increase the number of trials attempting to get closer to the value.
We present the results in Table 1. Recall, we introduced the randomness into the procedure with
the Monte Carlo simulation area algorithm. We provide graphical output as well so that the
algorithm may be seen as a process. In our graphical output, each generated coordinate (xi,yi) is a
point on the graph. Points are randomly generated in our intervals [a,b] for x and [0,M] for y. The
curve for the function, f(x), is overlayed with the points.
Percent Error
12%
3.2%
8%
2.64%
3.4%
We need to stress that in modeling deterministic behavior with stochastic features, we have
introduced the randomness into the problem (not nature). Although more runs is better, it is not
true that the as we increase the number of trials, N, the solution becomes closer to reality. It
is generally true that more runs is better than a small number of runs (16% was the worst by
almost an order of magnitude and that occurred at N=100).
We modify the algorithm to compute the area under the curve for the function e x cos( x ) x
over the interval [0,1.4]. We provide the complete step-by-step algorithm, your formulas, and the
final output for runs of 50, 100,500, and 1000 trials.
1.4
(x2 )
cos( x ) x dx
Generally, though not uniformly, the percent errors become smaller as the number of
points, N< is increased.
Exercises
1. Use Monte Carlo simulation to approximate the area under the curve, f(x) =
x .
2
2
2. Use Monte Carlo simulation to approximate the area under the curve, f(x) =
1
3
x .
2
2
3. Use Monte Carlo simulation to approximate the area under the curve, f(x) =
.
2
Rolling a fair die adds the additional process of multiple assignments (6 for a six sided die). The
probability will be the
Number of occurrences of each number/ total number of trails
INPUT: Number of rolls
Output: Probability of getting a {1,2,3,4,5,6}
Step 1 Initialize all counters (Counter1 through Counter 6) to 0
Step 2 For i=1,2n do steps 3 and 4
Step 3. Obtain a random number j from Integers (1,6)
Step 4 Increment the counter for the value of j so
Counter j = Counter j + 1
Step 5. Calculate the probability of each roll {1,2,3,4,5,6} by
Counter j / n
Step 6 Output probabilities
Step 7 Stop
The expected probability is 1/6 or 0.1667. We note that as the number of trials increases
the closer our probabilities are to the expected long run values. We use the
randbewteen(1,6) function in excel. It returns a random integer between 1 and 6 based on
equally likely probabilities.
Projects
1. BLACKJACK: Construct and perform a Monte Carlo simulation of Blackjack (also called
``21''). The rules of Blackjack are as follows:
Most casinos use six or eight decks of cards when playing this game to inhibit ``card counters.''
You will use two decks of cards in your simulation (104 cards total). There are only two players,
you and the dealer. Each player receives two cards to begin play. The cards are worth their face
value for 2-10, 10 for face cards (Jack, Queen, and King), and either 1 or 11 points for Aces. The
object of the game is to obtain a total as close to 21 as possible WITHOUT GOING OVER
(called ``busted'') so that your total is more than the dealer's. If the first two cards total 21 (Ace10 or Ace-face card), this is called ``blackjack'' and is an automatic winner (unless both you and
the dealer have blackjack, in which case it is a tie, or ``push,'' and your bet remains on the table).
Winning via blackjack pays you 3 to 2, or 1.5 to 1 (a 1-dollar bet reaps \$1.50 and you don't lose
the 1 dollar you bet).
If neither you nor the dealer has blackjack, you (the player) can take as many cards as you want,
one at a time, to try to get as close to 21 as possible. If you go over 21, you lose, and the game
ends. Once you are satisfied with your score, you ``stand.'' The dealer then draws cards according
to the following rules:
The dealer stands on 17, 18, 19, 20, or 21. The dealer must draw a card if the total is 16 or
less. The dealer always counts aces as 11 unless it causes him or her to bust, in which case it
is counted as a one. For example, an ace-six combo for the dealer is 17, not 7 (the dealer has
no option) and the dealer must stand on 17. However, if the dealer has an Ace-four (for 15)
and draws a King, then the new total is 15, because the Ace reverts to its value of 1 (so as
not to go over 21.) The dealer would then draw another card.
If the dealer goes over 21, you win (even your bet money; you gain \$1 for every \$1 you bet). If
the dealer's total exceeds your total, you lose all the money you bet. If the dealer's total equals
your total, it is a ``push'' (no money exchanges hands; you don't lose your bet, but neither do you
gain any money).
What makes the game exciting in a casino, is that the dealer's original two cards are one up, one
down, so you do not know the dealer's total and must ``play the odds'' based upon the one card
showing. You do not need to incorporate this twist into your simulation for this project. Here's
what you are required to do:
Run through 12 sets of 2 decks playing the game. You have an unlimited bankroll (don't you
wish!) and bet $2 on each hand. Each time the 2 decks run out, the hand in play continues
with 2 fresh decks (104 cards). At that point record your standing (plus or minus X dollars).
Then start again at 0 for the next deck. So your output will be the 12 results from playing
each of the 12 decks, which you can then average or total to determine your overall
performance.
What about YOUR strategy? That's up to you! But here's the catch...you will assume that
you can see NEITHER of the dealer's cards (so you have no idea what cards the dealer has).
Choose a strategy to play, and then play it throughout the entire simulation. (Blackjack
enthusiasts can consider implementing doubling down and splitting pairs into their
simulation, but this is not necessary.)
Provide your instructor with the simulation algorithm, computer code, and output results
from each of the 12 decks.
2. DARTS: Construct and perform a Monte Carlo Simulation of a darts game. The rules are:
Dart Board Area
Bulleye
Yellow Ring
Blue Ring
Red Ring
Whie Ring
Points
50
25
16
10
5
From the origin (the center of the bullseye) the radius of each ring is:
Ring
Bullseye
Yellow
Blue
Red
White
Thickness (in)
1
1.5
2.5
3
4
Make an assumption about the distribution of how the darts hit on the board. Then compare your
assumption to using appropriate areas. Write an algorithm, and code it in the computer language
of your choice. Run 1000 simulations to determine the mean score for throwing 5 darts. Also,
determine which ring has the highest expected value (point value times the probability of hitting
that ring).
3. CRAPS: Construct and perform a Monte Carlo Simulation of the popular casino game of craps.
The rules are as follows:
There are two basic bets in craps, PASS and DON'T PASS. In the PASS bet you wager that the
shooter (the person throwing the dice) will win; in the DON'T PASS bet, you wager that the
shooter will lose. We will play by the rule that on an initial roll of 12 (``boxcars''), both PASS and
DON'T PASS bets are losers. Both are ``even-money'' bets.
Roll a 7 or 11 on the first roll: Shooter WINS (PASS bets WIN and DON'T PASS bets lose). Roll
a 12 on the first roll: Shooter LOSES (``boxcars'', PASS AND DON'T PASS bets lose). Roll a 2
or 3 on the first roll: Shooter LOSES (PASS bets LOSE, DON'T PASS bets WIN). Roll
4,5,6,8,9,10 on the first roll: this becomes the ``point.'' The object then becomes to roll the
``point'' again before rolling a 7. The shooter continues to roll the dice until the point or a 7
appears. PASS bettors win if the shooter rolls the point again before rolling a 7. DON'T PASS
bettors win if the shooter rolls a 7 before rolling the point again.
Write an algorithm and code it in the computer language of your choice. Run the simulation to
estimate the probability of winning a PASS bet and the probability of winning a DON'T PASS
bet. Which is the better bet? As the number of trials increases, to what do the probabilities
converge?
4. HORSE RACE: Construct and perform a Monte Carlo Simulation of a horse race. You can be
creative here and use odds from the newspaper, or simulate the ``Mathematical Derby'' with
entries and odds below:
Entry
Eulers Folly
Leapin Leibnitz
Newton Lobell
Count Cauchy
Pumped Up Poisson
Loping LHopital
Steamin Stokes
Dancing Danzig
Odds
7-1
5-1
9-1
12-1
4-1
35-1
15-1
4-1
Construct and perform a Monte Carlo simulation of 1000 horse races. Which horse won
the most races? Which horse won the least races? Do these results surprise you? Provide the
tallies of how many races each horse won with your output.
5. ROULETTE: In American roulette, there are 38 spaces on the wheel, 0, 00, and 1 through 36.
Half the spaces numbered 1-36 are red, and half are black. The two spaces 0 and 00 are green.
Simulate the playing of 1000 games betting either red or black (which pay even money, 1:1).
Bet \$1 on each game and keep track of your earnings. What are THE earnings per game betting
red/black according to your simulation? 0What was your longest winning streak? Longest losing
streak?
Now simulate 1000 games betting green (pays 17:1, so if you win, you add \$17 to your kitty, and
if you lose, you lose \$1). What are your earnings per game betting green according to your
simulation? How does it differ from your earnings betting red/black? What was your longest
winning streak betting green? Longest losing streak? Which strategy do you recommend using,
and why?
6. THE PRICE IS RIGHT: On the popular TV game show ``The Price is Right,'' at the end
of each half hour, the three winning contestants face off in what is called the ``Showcase
Showdown.'' The game consists of spinning a large wheel with 20 spaces on which the
pointer can land, numbered from \$.05 to \$1.00 in 5 cent increments. The contestant who
has won the least amount of money at this point in the show spins first, followed by the one
who has won the next most, followed by the biggest winner for that half hour.
The objective of the game is to obtain as close to \$1.00 as possible without going over that
amount with a maximum of two spins. Naturally, if the first player does not go over, the other two
will use one or both spins in an attempt to overtake the leader.
But what of the person spinning first? If he or she is an expected value decision maker, how high
a value on the first spin does he or she need to not want a second spin? Remember, the person can
lose if
7. LET'S MAKE A DEAL: You are ``dressed to kill'' in your favorite costume and Monte
Hall, the host, picks you out of the audience. You are offered the choice of three wallets.
Two wallets contain a single \$50 bill, and the third contains a \$1000 bill. You choose
one of the wallets, 1, 2, or 3. Monte, who knows which wallet contains the \$1000, then
shows you one of the other two wallets, and this one is one of the two with \$50 inside.
Monte does this purposely, because he must have at least one wallet with \$50 inside. If
he has the \$1000 wallet, he shows you the \$50 one he holds. Otherwise, he just shows
you one of his two \$50 wallets. Monte then asks you if you want to trade your choice for
the one he's still holding. Should you trade?
Develop an algorithm and construct a computer simulation to support your answer.
Example:MissileAttack
An analyst plans a missile strike using F-15 aircraft. The F-15 hold a maximum of 8
missiles. It is vital to ensure success of this attack early in the battle. Each aircraft has a
probability of 0.5 of destroying the target, assuming it can get to the target through the air
defense systems and then acquire the attack. The probability that a single F-15 will
acquire a target is approximately 0.9. The target is protected by air-defense equipment
with a probability of stopping the F-15 from either arriving to the target or acquiring the
target of 0.40. How many F-15 are needed to have a successful mission assuming we
need a 99% success rate?
Algorithm: Missiles
INPUTS:
N = number of F-15s
M= number of missiles fired
P= probability the one F-15 can destroy the target
Q = probability the air-defense can disable the F-15
OUTPUT
S = probability of mission success
Step 1. Initialize S=0
Step 2 For I = 0 to M do
Step 3. P(i)=(1-(1-P)N-I
Step 4. B(i) = Binomial Distribution for (m,i,q)
Step 5. Compute S = S + P(i) * B(i)
Step 6 Output S
Step 7 Stop
We run the simulation letting the number of F-15 vary and calculate the probability of
success.
We find that at the number of F-15 = 7 gives a P(s) = .99122.
Actually any number of F-15 greater than 7 works. I would think the 10 F-15 yielding a
P(s) = 0.999957 would suffice. Any more would be overkill.
Example:GasolineInventorySimulation
Background:Youareaconsultanttoanownerofachainofgasolinestationsalonga
freeway.Theownerwantstomaximizetheirprofitsandmeetconsumerdemandfor
gasoline.Youdecidetolookatthefollowingproblem.
ProblemIdentificationStatement:Minimizetheaveragedailycostofdeliveringand
storingsufficientgasolineateachstationtomeetconsumerdemand.
Assumptions:Foraninitialmodel,youconsiderthatintheshortruntheaveragedaily
costisafunctionofdemandrate,storagecosts,anddeliverycosts.Youalsoassumethat
youneedamodelforthedemandrate.Youdecidethathistoricaldatewillassistyou.
Demand:
Numberofgallons
10001099
11001199
12001299
13001399
14001499
15001599
16001699
17001799
18001899
19001999
Totalnumberofdays=
NumberofOccurrences(days)
10
20
50
120
200
270
180
80
40
30
1000
ModelFormulation:Weconvertthenumberofdaysintoprobabilitiesbydividingbythe
totalandweusethemidpointoftheintervalofdemandforsimplification.
Demand:
Numberofgallons
1000
1150
1250
1350
1450
1550
1650
1750
1850
2000
Totalnumberofdays=
Probabilities
.010
.020
.050
.120
.200
.270
.180
.080
.040
.030
1.000
SincecumulativeprobabilitieswillbemoreusefulweconverttoaCDF.
Demand:
Numberofgallons
1000
1150
1250
1350
1450
1550
1650
1750
1850
2000
Probabilities
.010
.030
.080
.20
.4
.670
.850
.93
.97
1.0
Wewillusecubicsplines,seeChapter6,foradiscussionofcubicsplinestomodelthe
functionfordemand.
InventoryAlgorithm
INPUTS:Q=deliveryquantityingallons
T=timebetweendeliveriesindays
D=deliverycostindollarsperdelivery
S=storagecostsindollarspergallons
N=numberofdaysinthesimulation
OUTPUT:
C=averagedailycost
Step1.Initialize:InventoryI=0,andC=0
Step2.Beginthenextcyclewithadelivery
I=I+Q
C=C+D
Step3.Simulateeachdayofthecycle
Fori=1,2,,.Tdosteps46
Step4.Generateademand,qi.Usecubicsplinestogenerateademandbasedona
randomCDFvaluexi.
Step5.Updatetheinventory:I=Iqi
Step6.Calculatetheupdatedcost,C=C+s*IiftheInventoryispositive.Ifthe
inventoryis<0thensetI=0gotoStep7.
Step7.ReturntoStep2untilthesimulationcycleiscompleted.
Step8.Computetheaveragedailycost:C=C/n
Step9OutputC
Stop
Theaveragecostis$5753.04andtheinventoryonhandis199,862.4518gallons.
Exercises
1. ModifythemissileattackproblemiftheprobabilityofSwhereonly0.95andthe
probabilityofF15beingdeterredbyairdefensewere0.3.Determinethenumber
ofF15neededtocompletethemission.
2. WhatifinthemissileattackproblemtheF15weremodifiedtocarry10missiles?
WhatimpactdoesthathaveonthenumberofF15sneeded?
3. Performsomesensitivityanalysisonthegasolineinventoryproblemby
modifyingthedeliveryto11450gallonsperweek.Whatimpactdoesthishaveon
theaveragedailycost?
Projects
1. Tollbooths : Heavily-traveled toll roads such as the Garden State Parkway, Interstate 95,
possibly Interstate 73, and so forth, are multi-lane divided highways that are interrupted at
intervals by toll plazas. Because collecting tolls is usually unpopular, it is desirable to minimize
motorist annoyance by limiting the amount of traffic disruption caused by the toll plazas.
Commonly, a much larger number of tollbooths is provided than the number of travel lanes
entering the toll plaza. Upon entering the toll plaza, the flow of vehicles fans out to the larger
number of tollbooths, and when leaving the toll plaza, the flow of vehicles is required to squeeze
back down to a number of travel lanes equal to the number of travel lanes before the toll plaza.
Consequently, when traffic is heavy, congestion increases upon departure from the toll plaza.
When traffic is very heavy, congestion also builds at the entry to the toll plaza because of the time
required for each vehicle to pay the toll.
Construct a mathematical model to help you determine the optimal number of tollbooths to
deploy in a barrier-toll plaza. Explicitly, first consider the scenario where there is exactly one
tollbooth per incoming travel lane. Then consider multiple tollbooths per incoming lane. Under
what conditions is one tollbooth per lane more or less effective than the current practice? Note
that the definition of "optimal" is up to you to determine.
2. Build a simulation to model a baseball game. Use your two favorite teams or favorite
all-stars to play a regulation game.
3. Build a simulation to model the NBA basketball playoffs.
4. Build a simulation to model surgical and recovery rooms for the hospital.
5. Build a simulation to model the registrars scheduling changes for students or final
exam schedules.