0% found this document useful (0 votes)
12 views25 pages

Monte Carlo Simulation

simulation

Uploaded by

Sidra Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views25 pages

Monte Carlo Simulation

simulation

Uploaded by

Sidra Yousaf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Systems Modelling & Simulation

Monte Carlo Simulation

Dr. Hakeem–Ur–Rehman
IQTM-PU 1
Outlines

▪ Introduction to Monte Carlo (MC) Simulation

▪ MC Simulation: Random Number Mapping Method

▪ MC Simulation of a Project

▪ MC Simulation of a Queuing System

▪ MC Simulation of an Inventory System

▪ Examples of MC Simulation to solve the mathematical problems

2
Different Kinds of Simulation
System Model

Deterministic Vs. Stochastic


Deterministic Is everything for sure or is there uncertainty? Stochastic

Static Vs. Dynamic


Static Dynamic Does time have a role in model? Static Dynamic
Monte Carlo
Simulation
Continuous Vs. Discrete Change
Continuous Discrete Can “state” change continuously, or only at Continuous Discrete
Continuous Discrete discrete points in time? Continuous Discrete
Simulation Event Simulation Event
Simulation Simulation

Most operational models: Stochastic, Dynamic, Discrete-change


3
Monte Carlo Simulation
▪ John Von Neumann and Stanislav Ulam – Developed this method (1949).

▪ The technique “Monte Carlo” derives its name from the city of Monte Carlo in the principality of
Monaco, France, famous for gambling and its casino.

▪ Gambling is the game of probability and random sampling and so is the Monte Carlo Method.

▪ Monte Carlo methods (or Monte Carlo experiments) are a broad class
of computational algorithms that rely on repeated random sampling to obtain numerical results.
(Based on random numbers)

▪ To reflect the relative frequencies of the random variables, the random number mapping method is
used

▪ “Monte Carlo is a method of approximating things using samples”

▪ Simulation-Optimization: Run simulation many times, each time with different parameters, to find
the best (optimal) values of parameters. 4
Monte Carlo Simulation…
Random Number Mapping Methods: Service Time
Probability
▪ Consider service time distribution shown here → (Minutes)
1 0.4
2 0.35
3 0.2
▪ To obtain a random service time, we need to map an 4 0.05
appropriate number of integers from 0 to 99 to each service
time, according to the probability
Service Time
▪ Assume that we have random integers ‘Uniformly Probability Mapping
(Minutes)
distributed’ in range ‘0 – 99’ 1 0.4 0-39
o Obtained using Excel formula 2 0.35 40-74
3 0.2 75-94
• “TRUNC(100*RAND()) ”
4 0.05 95-99
• “RANDBETWEEN(0,99)”

5
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Project:
▪ Consider a project with activities shown in the first table and Activity Description Predecessors
activity time distributions shown in the second table. Activity F A Excavate -
always takes 5 days.
B Lay foundation A
▪ What is the critical path and the expected project completion time if C Rough plumbing B, D
activity times are equal to expected (mean) activity times? D Frame A
▪ Perform 10 simulation experiments and compute the following: E Finish exterior D
o Expected duration of the project. F Install HVAC C, E
o Probability that the project exceeds 27 days.
o Probability that a path is critical, for each path

A B C D E
Days Prob. Days Prob. Days Prob. Days Prob. Days Prob.
4 0.4 8 0.4 2 0.5 4 0.8 2 0.5
8 0.4 10 0.2 4 0.5 9 0.2 10 0.5
11 0.2 12 0.4
6
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Project…:

7
10
3
5
6
5 Mean duration of the Activity:
𝑬 𝑿 = σ 𝑿𝑷(𝑿)

Critical Path: A → B → C → F
Project Duration = 25 Days

All Paths:
A → B → C → F (25 days)
A → D → C → F (20 Days)
A → D → E → F (23 Days)
7
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Project…:

Average Duration = (27+29+23+23+35+30+25+28+19+27/10) = 26.6 Days

What is the Probability that project duration will exceed from 27 days? → 4/10 = 40%
What is the Probability that path ‘ABCF’ is critical? ; ‘ADCF’ is critical? ; ‘ADEF’ is critical? 8
Monte Carlo Simulation: Simulation of a Project – Practice Question
Activity Predecessors
A -
▪ Consider a project with activities shown in the first table and activity time distributions
shown in the second table. B -
C A
▪ What is the critical path and the expected project completion time if activity times are
equal to expected (mean) activity times? D A
E A
▪ Perform 10 simulation experiments and compute the following: F B, C
o Expected duration of the project.
o Probability that the project exceeds 23 days. G B, C
o Probability that a path is critical, for each path H E, F
I E, F
J D, H
K G,I

A B C D E F G H I J K
Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr. Hrs Pr.
4 0.4 2 0.3 2 0.3 4 0.2 1 0.7 3 0.2 1 0.1 6 0.7 5 1 3 1 5 1
6 0.4 3 0.2 3 0.7 5 0.6 2 0.3 4 0.6 2 0.9 7 0.3
9 0.2 4 0.5 6 0.2 7 0.2
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System: A doctor’s office has one nurse and one doctor. Patients arrive randomly. Each patient first
goes through a check-up with the nurse and then proceeds for a full check-up by the doctor. Patients may have to wait before
being served by the nurse as well as before being served by the doctor. Service priority is first-in-first-out (FIFO). The service
time of the nurse is always 7 minutes, but the service time of the doctor is random. The distributions of the time between
arrivals and the service time of the doctor are given below:

Time between arrivals (Minutes) Probability Doctor’s Service time (Minutes) Probability
5 0.5 4 0.3
10 0.3 8 0.5
15 0.2 12 0.2

Constant Random
Random Service time Service time
(Inter-arrival time) Nurse Doctor
Patients (One) (One)
arrive Waiting Area Waiting Area

Determine the average time a patient spends in the doctor’s office from the arrival till leaving using simulation.
10
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System:
1. What is the average inter-arrival time?
2. What is the arrival rate?
3. What is the average Doctor’s Service time?
4. What is the Doctor’s service rate?
5. What is the average time a patient spends in the doctor’s office from the arrival
till leaving?
6. How many number of patients in the doctor’s office at any given time?

11
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System…
Time between
arrivals [min] Probability
What is the average inter-arrival time? → 𝑬 𝑿 = σ 𝑿𝑷(𝑿)
𝟏
5 0.5 Avg. inter-arrival time = 𝝀 = 0.5 5 + 0.3 10 + 0.2 15 = 8.5 𝑚𝑖𝑛
10 0.3 Arrival Rate = 𝜆 = 1 / (Avg. inter-arrival time)
= 0.1176 cust. /min.
15 0.2
= 7.059 cust. / hour
Doctor's service Doctor’s Service Time:
time [min] Probability What is the average Service time? → 𝑬 𝑿 = σ 𝑿𝑷(𝑿)
4 0.3 𝟏
Avg. Service time = 𝝁 = 0.3 4 + 0.5 8 + 0.2 12 = 7.6 𝑚𝑖𝑛
8 0.5
Service Rate = μ = 1 / (Avg. service time)
12 0.2 = 0.1316 cust. /min.
= 7.895 cust. / hour

Nurse’s Service Time:


𝟏
Avg. Service time = 𝝁 = 7 𝑚𝑖𝑛
Service Rate = μ = 1 / 7 = 0.1429 cust. /min. = 8.57 cust. / hour
12
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System…
Time between Mapping Doctor's service Mapping
arrivals [min] Probability 0-99 time [min] Probability 0-99
5 0.5 0-49 4 0.3 0-29
10 0.3 50-79 8 0.5 30-79
15 0.2 80-99 12 0.2 80-99

What is the average time a patient spends in the doctor’s office from the arrival till leaving?

Average time in the System = (11+17+15+15+19)ൗ5 = 15.4 𝑀𝑖𝑛. 13


Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System…
How many number of patients in the doctor’s office at any given time?

LITTLE’S LAW Inventory (I) = Flow Rate (R) * Flow Time (T)
Average Number of customers in the system = Arrival Rate X Average time in the System
= 0.1176 cust. /min X 15.4 min. = 1.81 Cust.
Monte Carlo Simulation:
Random Number Mapping Method
Simulation of a Queuing System…

Statistical Analysis of the Simulation Results:


Average time
Experiment in system n 10
(Min.) Mean 20.535
1 17.15 S.D. 6.652
2 37.25
3 17.1 Reject H0 Reject H0
4 18.7
5 17.65 .025 .025
6 16.8
7 21.25
8 15.15
-1.96 0 1.96 Z
9 17.95
10 26.35 Under 95% Confidence Interval → (16.412 , 24.658 )
Monte Carlo Simulation:
Inventory System – Example 1
Simulation of an Inventory System: Ali Appliance stocks and sells the KitchenChef electric mixer. Initially,
there are 25 units in the inventory. Each week a number of customers buy some units. The number of customers
and demand per customer have the following probability distributions:

Number of Customers Probability Demand per Customer Probability


0 0.10
1 0.10
1 0.30
2 0.15
2 0.25
3 0.20 3 0.40
4 0.15 4 0.35

Ali uses the following inventory policy: if at the end of the week inventory is R = 10 items or less and there is no
outstanding order, then order Q = 25 items. Holding cost $1 per unit per week. Order cost is $45 per order. Order
placed at the end of the week ‘n’ arrives at the beginning of a week ‘n+2’ (i.e. Lead time is 2 weeks). If Ali runs
out of units for which there is demand, they put them on backorder, i.e., the demand is satisfied once the next
order arrives. Backorder cost id $5 per unit per week.
Ali would like to determine the average weekly cost of inventory.
16
Monte Carlo Simulation:
Inventory System – Example 1…
Simulation of an Inventory System …
Number of Mapping
Probability Demand per Mapping Order 'Q' when inventory is less than or equal to R and there
Customers (0-99) Probability
Customers (0-99) is no outstanding order.
0 0.1 0-9
1 0.1 0-9 Q = 25, R =10
1 0.3 10-39
2 0.15 10-24 Ordering Cost = $45 per order
2 0.25 40-64
3 0.4 25-64 Holding Cost = $1 per unit per week
3 0.2 65-84
Backorder Cost = $5 per unit per week
4 0.15 85-99 4 0.35 65-99

15

Average Inventory Cost = (18+51+15+20+20)ൗ5 = $24.8 17


Monte Carlo Simulation:
Safety Stocks
▪ Safety or Buffer Stock
o Inventory level might be depleted at a slower or faster rate during lead time
o Buffer added to on hand inventory during lead time

▪ Service Level
o Probability that the inventory available during lead time will meet demand
A service level of 90 percent means that there is a 0.90 probability that demand will be met during the lead time, and the
probability that a stockout (An inventory shortage) will occur is 10 percent.
Inventory level

Q
Reorder Reorder point with
point, R a safety stock

Safety Stock
0
LT LT
Time 18
Reorder Point With Variable Demand

Probability of
meeting demand during
lead time = service level

Safety stock
zd L

dL R
Demand 19
Monte Carlo Simulation:
Inventory System – Example 2
Given Data is:
Demand Table Lead Time Table
Demand Probability # of Days Probability
0 0.03 1 0.2
1 0.05 2 0.6
2 0.13 3 0.15
3 0.25
4 0.05
4 0.22
5 0.2
6 0.12 Reorder Level 8
Order Quantity 20

Find the Service Level (%)


Service Level → Probability that the inventory available during lead time will meet demand

Using Monte-Carlo simulation, find order quantity (Q) and reorder point (R) those provide the highest service level.
i. Start with Q = 10 & R = 5; generate a simulation of the problem.
ii. Use Scenario Manager and try Q = 10, 15, & 20 whereas R = 5 and 8. Which is the Optimal Values of Q & R?

20
Monte Carlo Simulation: Inventory System – Example 3
A store sells a bike. Daily demand for the bike is relatively low but subject to some variability. Based on the past 300 days, the
demand follow the following probability distribution. Demand Probability
0 0.05
1 0.10
2 0.20
3 0.40
4 0.15
5 0.10

When an order is placed to replenish the inventory of bikes, the time between when the order is placed and when it is received
(i.e., the Lead time) is a stochastic (probabilistic) variable. Based on the previous 100 orders , it has been found that lead time
follows a discrete uniform distribution between One and three days. There are currently 7 bikes in stock and there are no orders
due.
It is estimated that the fixed cost of placing an order with the bike supplier is $20. The cost of holding a bike in stock is $0.02
per bike per day. Each time demand is not satisfied (i.e., Stockout), the customer buys the bike elsewhere, and store loses the
sale. It is estimated that the cost of a stockout is $8 per bike. Assume that the shop operates 25 days each month.

Using Monte-Carlo simulation, find order quantity (Q) and reorder point (R) those provide the lowest total cost.
i. Start with Q = 10 & R = 5; generate a simulation of the problem.
ii. Use Scenario Manager and try Q = 8, 10, 12 & 14 whereas R = 5 and 8. Which is the Optimal Values of Q & R?

21
Monte Carlo Simulation: Inventory System – Example 3
A store sells a bike. Daily demand for the bike is relatively low but subject to some variability. Based on the past 300 days, the
demand follow the following probability distribution. Demand Probability
0 0.05
1 0.10
2 0.20
3 0.40
4 0.15
5 0.10

When an order is placed to replenish the inventory of bikes, the time between when the order is placed and when it is received
(i.e., the Lead time) is a stochastic (probabilistic) variable. Based on the previous 100 orders , it has been found that lead time
follows a discrete uniform distribution between One and three days. There are currently 7 bikes in stock and there are no orders
due.
It is estimated that the fixed cost of placing an order with the bike supplier is $20. The cost of holding a bike in stock is $0.02
per bike per day. Each time demand is not satisfied (i.e., Stockout), the customer buys the bike elsewhere, and store loses the
sale. It is estimated that the cost of a stockout is $8 per bike. Assume that the shop operates 25 days each month.

Using Monte-Carlo simulation, find order quantity (Q) and reorder point (R) those provide the lowest total cost.
i. Start with Q = 10 & R = 5; generate a simulation of the problem.
ii. Use Scenario Manager and try Q = 8, 10, 12 & 14 whereas R = 5 and 8. Which is the Optimal Values of Q & R?

22
Monte Carlo Simulation: Project Selection – Financial Models

▪ PAYBACK PERIOD ▪ Decision Rule


o Measures the time the project will take to recover the o Payback = acceptable time limit, accept
project investment. o Payback > acceptable time limit, reject

▪ Net present value (NPV) Model ▪ Decision Rule


o Uses management’s minimum desired rate-of-return o Positive NPV: project meets minimum
(discount rate) to compute the present value of all net desired rate of return and is eligible for
further consideration.
cash inflows.
o Negative NPV: project is rejected.

23
Monte Carlo Simulation…
“Monte Carlo is a method of approximating things using samples”
▪ Example–1: Using Monte Carlo Simulation to Estimate ‘𝜋’

𝐴𝑟𝑒𝑎 𝑜𝑓 𝐶𝑖𝑟𝑐𝑙𝑒 = 𝜋𝑟 2
𝐴𝑟𝑒𝑎 𝑜𝑓 𝑆𝑞𝑢𝑎𝑟𝑒 = 4𝑟 2
𝑥2 + 𝑦2 = 𝑟2

𝜋𝑟 2
𝑃𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑡𝑦 𝑝𝑜𝑖𝑛𝑡 𝑖𝑛𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒 =
4𝑟 2

𝝅 = 4 ∗ 𝑃𝑟𝑜𝑏𝑎𝑏𝑖𝑙𝑡𝑦 𝑝𝑜𝑖𝑛𝑡 𝑖𝑛𝑠𝑖𝑑𝑒 𝑡ℎ𝑒 𝑐𝑖𝑟𝑐𝑙𝑒

5 5 2
▪ Example–2: Integrate ‫׬‬0 𝑥 & ‫׬‬0 𝑥
24
25

You might also like