Simulation Modelling
Simulation Modelling
Simulation Modelling
Simulation Modeling
IIMT3636
2022/23 Semester I
The University of Hong Kong
Instructor: Dr. Liao WANG
2
Introduction
• In practice, we often make decisions under risk for very
complicated problems.
▫ Too many random variables involved
▫ Too many or even infinitely many possible states
▫ Objective functions are highly nonlinear
▫ Cannot be explicitly solved
Daily Demand 0 1 2 3 4 5
Probability 0.05 0.10 0.20 0.30 0.20 0.15
7
1
𝐹 𝑋𝑖
Follows
uniform 𝐹 𝑋
distribution
on [0, 1] 𝑋
0
𝑋𝑖
52 06 50 88 53 30 10 47 99 37
37 63 28 02 74 35 24 03 29 60
82 57 68 28 05 94 03 11 27 79
69 02 36 49 71 99 32 10 75 21
98 94 90 36 06 78 23 67 89 85
96 52 62 87 49 56 59 23 78 71
33 69 27 21 11 60 95 89 68 48
50 33 50 95 13 44 34 62 64 39
88 32 18 50 62 57 34 56 62 31
90 30 36 24 69 82 51 74 30 35
15
In-Class Exercise
• If we only have a table of random numbers and a z-table, how to
simulate the price of a stock, for which the daily return rate follows a
normal distribution with a mean of 10% and a standard deviation of
5%?
A Digital Option
• A digital option works on some stock (e.g. AAPL, IBM,
etc.) or some stock index (e.g. S&P500)
• Suppose its life time is 1 year: one year from now, it
expires.
• On the expiry date, we look at the stock price. If it
exceeds a pre-determined level, $280, called “strike”, the
option pays out $1; otherwise, it pays nothing (and
expires worthless).
• Today, we buy this option for $0.37. The current stock
price is $267, and its annual return follows
𝑁 10%, 15% .
• What is the expected net payoff from this investment?
17
A Digital Option
Strike = $280, option price = $0.37, current stock price =
$267. Stock return follows Normal distribution with mean
10% and std 15%.
A Digital Option
19
𝐷1
𝐷2
𝐷3 Order
Quantity ROP
𝐷4 Order
Quantity
𝐷5
𝐷6 Time
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (Day)
Lead Lead
Time Time
23
Start
Begin day
of simulation
diagram, or flowchart, is Is
demand greater Yes Record
number of
helpful in the logical than beginning
inventory lost sales
?
coding procedures. No
Compute ending inventory Record ending
= Beginning inventory inventory = 0
– Demand
Is Has
ending inventory Yes order been No Place
less than reorder placed that hasn’t order
point? arrived yet
No Have Yes ? Select random
No enough days number to
of this order policy generate lead
been simulated time
?
Yes
Compute average ending inventory,
average lost sales, average number of End
orders placed, and corresponding costs
24
Daily order cost = $10 per order x 0.3 order per day = $3
Daily holding cost = $0.03 per unit per day x 4.1 units per day = $0.12
Daily stockout cost = $8 per lost sale x 0.2 lost sales per day = $1.60
Total daily
inventory cost = Daily order cost + Daily holding cost
+ Daily stockout cost = $4.72
27
Café du Donut
• The Cafébuys donuts each day for $40 per carton of 20 dozen
donuts. Any cartons not sold are thrown away at the end of
the day. If a carton is sold, the total revenue is $60.
Café du Donut
• What are the average profits of ordering 6 and 7 cartons per day,
respectively?
6 Cartons Per Day 7 Cartons Per Day
DAILY SALES PROBABILITY CUMULATIVE
Day R.N. Demand Sales Volume Profit Sales Volume Profit
(CARTONS) PROBABILITY
1 0.29 6 6 $120 6 $80
4 0.05 0.05
2 0.32 6 6 $120 6 $80
5 0.15 0.2
3 0.56 8 6 $120 7 $140
4 0.72 8 6 6 0.15 $120 0.35 7 $140
5 0.82 9 7 6 0.20 $120 0.55 7 $140
… … … 8 … 0.25 … 0.8 … …
97 0.10 5 9 5 0.10 $60 0.9 5 $20
98 0.04 4 10 4 0.10 $0 1.0 4 $(40)
99 0.36 7 6
Total 1.00 $120 7 $140
100 0.64 8 6 $120 7 $140
Average: 5.75 $105 6.41 $104.6
30
NUMBER NUMBER
DELAYED RANDOM DELAYED RANDOM
FROM NUMBER OF TOTAL TO NUMBER FROM TOTAL TO NUMBER
PREVIOUS RANDOM NIGHTLY BE FOR TEAM NUMBER PREVIOUS BE FOR TEAM NUMBER
DAY DAY NUMBER ARRIVALS UNLOADED 1 UNLOADED DAY RELOADED 2 RELOADED
1 — … … … … … … … …
36
JIMMY SMITH'S SERVICE RATE PROBABILITY CUMULATIVE PROBABILITY RANDOM NUMBER INTERVAL
0 0.02 0.02 01 to 2
1 0.05 0.1 3 to 10
2 0.1 0.2 11 to 20
3 0.2 0.4 21 to 40
4 0.26 0.66 41 to 66
5 0.2 0.89 67 to 89
6 0.17 1 90 to 00
38
1 0 20 1 1 88 1
2 0 98 5 5 80 4
3 1 41 2 3 1 0
4 3 25 1 4 56 3
5 1 60 2 3 36 2
6 1 45 2 3 42 3
7 0 61 2 2 25 2
8 0 55 2 2 21 2
9 0 40 1 1 37 1
10 0 19 1 1 27 1
11 0 11 0 0 26 0
12 0 74 3 3 85 3
13 0 12 0 0 35 0
14 0 37 1 1 82 1
15 0 31 1 1 21 1
16 0 22 1 1 46 1
Average 0.375
Reid's Average 0.375*50 + 15
Cost =33.75
39
Failed Machines
Server
Failure Repaired
Working Machines
41
No Enough
breakdowns
simulated?
Yes
Compute downtime and comparative End
costs data
45
The estimated
breakdown cost of
the system is
Three Hills Power Company $75*44/(10+24)=$97
per hour
TIME REPAIR- NUMBER OF
TIME PERSON IS FREE R.N. FOR REPAIR TIME HOURS
BREAKDOWN R.N. FOR BETWEEN TIME OF TO BEGIN THIS REPAIR TIME REPAIR MACHINE
NUMBER BREAKDOWNS BREAKDOWNS BREAKDOWN REPAIR TIME REQUIRED ENDS DOWN
1 57 2 02:00 02:00 07 1 03:00 1
2 17 1.5 03:30 03:30 60 2 05:30 2
3 36 2 05:30 05:30 77 2 07:30 2
4 72 2.5 08:00 08:00 49 2 10:00 2
5 85 3 11:00 11:00 76 2 13:00 2
6 31 2 13:00 13:00 95 3 16:00 3
7 44 2 15:00 16:00 51 2 18:00 3
8 30 2 17:00 18:00 16 1 19:00 2
9 26 1.5 18:30 19:00 14 1 20:00 1.5
10 09 1 19:30 20:00 85 3 23:00 3.5
11 49 2 21:30 23:00 59 2 01:00 3.5
12 13 1.5 23:00 01:00 85 3 04:00 5
13 33 2 01:00 04:00 40 2 06:00 5
14 89 3 04:00 06:00 42 2 08:00 4
15 13 1.5 05:30 08:00 52 2 10:00 4.5
Total 44
46
200 350
300
0
Frequency
250
10000 11000 12000 13000 14000 15000
-200 200
-400 150
100
-600
50
-800
0
-1000 -500 0 500 1000 1500 2000 2500 More
Profit ($)
-1200
53
More Applications …
• Simulation and Financial Planning
▫ Cash flows, stock prices, etc.
• Simulation and Marketing
▫ Customer retention, market share evolution, etc.
• Simulation and Sports
▫ Basketball, baseball, etc.
• Simulation and Artificial Intelligence
▫ AlphaGo (Monte Carlo Tree Search)
54