Fundamentals of Simulation in Ms Excel / Monte Carlo Simulation
Fundamentals of Simulation in Ms Excel / Monte Carlo Simulation
1
FUNDAMENTALS OF SIMULATION IN MS EXCEL (1/6)
2
FUNDAMENTALS OF SIMULATION IN MS EXCEL (2/6)
3
FUNDAMENTALS OF SIMULATION IN MS EXCEL (3/6)
4
FUNDAMENTALS OF SIMULATION IN MS EXCEL (4/6)
7
MONTE CARLO SIMULATION (1/2)
8
MONTE CARLO SIMULATION (2/2)
9
RANDOM NUMBER GENERATION in MS EXCEL
10
=RAND(), =RANDBETWEEN()
11
Application.Calculation
=xlManual
Application.Calculation
=xlAutomatic
12
=RAND(), =IF(RAND()<=0.5,1,0)
• Coin Tossing:
• A coin (0.5 probability) is tossed 10 times.
• It is a Monte-Carlo simulation because there is no event
or simulation time.
• Example 2.1CoinToss.xls:
• There are 4 solutions.
• Solution#1A and Solution#1B use =RAND(),
• Solution#2A and Solution#2B use Rnd01() (VBA code)
13
VBA Functions
• Random service time simulation:
• On average service times at a call center occure as
3mins, 6mins or 10mins.
• The percentage of these calls are 30%, 45% or 25%.
• Simulate calls for 25 calls.
14
VBA Functions
• Total probability is 1.
• Lets say random numbers are determined as:
0.9871, 0.026, 0.0008, 0.2128, 0.8586
• What are the service times???
15
VBA Functions
Example2.2 ServiceTimes.xls:
• VBA function: DiscreteEmp().
• =IF(Rnd01()<=0.30, 3, IF(Rnd01()<=0.75,
6), 10) ???
=DisceretEmp($D$7:$D$9, $B$7:$B$9)
16
VBA Functions
Random interarrival time simulations:
Lets say interarrival time between two consecutive arrivals are 1,
2, 3, and 4 with equal probability for the previous example
(Uniform).
• Example2.3 ArrivalTimes.xls:
• In this example, even VBA in the previous example could be
used, a macro for discrete uniform distribution is developed:
DiscreteUniform().
17
Simulation Steps in MS Excel (1/4)
The structure of each table is different, because it is problem structure
sensitive. However, the column of the tables can be generated as
follows:
Before developing the table, first determine the characteristics of each
of the inputs to the simulation. Quite often, these are modeled as
probability distributions, either continuous or discrete.
Each column in the table is one of the following:
• An activity time associated with model input
• Any other random variable defined by a model input (for
instance: probability of heads or tails in coin tossing game,
interarrival times)
• A system state (FI: state of the server – busy, idle )
• An event, or the clock time of an event
• A model output (FI: waiting time of each customer time in the
line)
• A model response - performance measures (FI: overall, average
waiting time)
18
Simulation Steps in MS Excel (2/4)
Usually, the following steps are followed to run a
simulation model manually or in excel:
20
Simulation Steps in MS Excel (4/4)
Step 6: Initialize the table by filling in the data for
repetition 1. For each repetition i, generate a value for each
of the p inputs, and evaluate the function, calculating a
value of the response Yi.
21
Monte-Carlo Simulation in MS Excel (1/9)
• In the table the sales data of a laptop for 100 weeks is
provided. (Sales price is $4300).
22
Monte-Carlo Simulation in MS Excel (2/9)
23
Monte-Carlo Simulation in MS Excel (3/9)
• State variable of the system is weekly demand. Step 2
• The demand for n=15 weeks (i=1, 2,…, 15) is
xij ( j = 1) is going to be determined via a simulation study.
• The probability of demand is shown as a roulette table
below:
24
Monte-Carlo Simulation in MS Excel (4/9)
• The random number for each demand can be converted
to a table as:
25
Monte-Carlo Simulation in MS Excel (5/9)
Step 3
26
Monte-Carlo Simulation in MS Excel (6/9)
Step 5
27
Monte-Carlo Simulation in MS Excel (7/9)
Step 6
Step 7
• Average demand=31/15=2.07 piece/week
• Average revenue=$133,300/15 = $8,886.67/week
28
Monte-Carlo Simulation in MS Excel (8/9)
29
Monte-Carlo Simulation in MS Excel (9/9)
Use Freeze
option under
View button
30
Scenario 1: Weekly 1 production (shortage cost
is $500 and inventory cost is $50)
31
Scenario 2: Weekly 2 production(shortage cost
is $500 and inventory cost is $50)
32
See you next lecture ☺
33