Download as pdf or txt
Download as pdf or txt
You are on page 1of 46

LOG 307 - Optimisation and

Simulation for Decision-Making

January 2024

Zahraei and Ghosh, 2023


Zahraei and Ghosh, 2023
Last week

• Local and global optimal solutions in nonlinear programming problems.

• Nonlinear programming models for facility location decisions in supply chains.

• Diversification and intensification in designing metaheuristics.

• Travelling salesperson problems using the evolutionary algorithm in Excel Solver.

Zahraei and Ghosh, 2023 2


Study Unit 4 - Introduction to Simulation

Simulation Fundamentals
Simulation Tools

Zahraei and Ghosh, 2023


Zahraei and Ghosh, 2023
Study Unit Learning Outcomes

• Discuss the need for simulation to solve complex business problems.


• Examine how real-life problems are modelled by Monte Carlo
simulation.
• Solve complex problems using built-in Excel simulation tools.
• Analyse complex problems using Excel add-in @RISK.

4
Zahraei and Ghosh, 2023
Chapter 7
Simulation Fundamentals

Zahraei and Ghosh, 2023


Zahraei and Ghosh, 2023
What is Simulation?

“the process of designing a model of a real system and


conducting experiments with this model for the purpose of either
understanding the behavior of the system and/or evaluating
various strategies for the operation of the system.”

Source: Introduction to Simulation Using SIMAN

Zahraei and Ghosh, 2023 6


Applications of Simulation

✓ Manufacturing—scheduling, inventory
✓ Distribution and logistics
✓ Staffing personal - service operations (e.g., banks, fast food, theme parks, etc.)
✓ Health care—emergency, operating rooms
✓ Computer systems
✓ Telecommunications
✓ Military
✓ Public policy (e.g. emergency planning, courts, prisons, probation/parole etc.)

Zahraei and Ghosh, 2023 7


Simulation Model

✓ It is a computer model that imitates a real-life situation


✓ An entire system is converted into a model based on assumptions,
abstraction, and simplification
✓ It is much easier, faster, cheaper, and safer than studying (and modifying)
an existing system.
✓ It captures the uncertainty present in one or more input variables.
✓ We can see the changes in output variables with changing input variables.

Zahraei and Ghosh, 2023 8


Advantages of Simulation Models

✓ What-if scenarios

✓ Flexibility

✓ Low computing cost

✓ Advances in simulation software/add-ins

Zahraei and Ghosh, 2023 9


Types of Simulation Models

Monte Carlo simulation


✓ Used to model random systems

Process or discrete event simulation


✓ Used to model a system that changes at discrete points in time. In
some sense, it is a subset of Monte Carlo simulation.

Zahraei and Ghosh, 2023 10


Monte Carlo Simulation

✓ Key element is randomness


➢ Assume that some inputs are random variables
➢ Generate random variables from their probability distributions

✓ Simulation Modeling Process


i. Develop the basic model that “behaves like” the real problem, with a
special consideration of the random or probabilistic input variables.
ii. Conduct a series of computer runs (called iterations) to learn the
behavior of the simulation model.
iii. Compute the summary (output) statistics and make inferences about
the real problem

Zahraei and Ghosh, 2023 11


Spreadsheet Simulation Modeling

✓ Spreadsheet simulation modeling is quite similar to the other modeling


applications.
➢ You begin with input variables, and
➢ Then relate these with appropriate Excel formulas to produce
output variables of interest.

❑The main difference is that simulation uses at least one of the input
variable cells in a simulation model contains random numbers.

Zahraei and Ghosh, 2023 12


Probability Distributions for Input Variables

Discrete vs. Continuous


A probability distribution is A probability distribution is
discrete if it has a finite continuous if its possible values
number of possible values. are essentially some continuum

✓ Check the file Probability Distributions.xlsx on Canvas to help you


learn and explore various probability distribution.
Zahraei and Ghosh, 2023 13
Simulation with Excel

✓ Spreadsheet simulation models can be developed and analyzed with Excel’s


built-in tools without using add-ins.

▪ Simulation models are developed by creating random numbers based on the


random input variables.
❑A random number (RN) is a number that does not follow any pattern and can
not be predicted based on the present number.

➢ In Excel, the function RAND() generates a random number between 0 and 1.

Zahraei and Ghosh, 2023 14


Steps for Developing a Simulation Model with in-build Excel

i. Plan your model and translate it to a spreadsheet model


ii. Relate inputs variables (by generating random numbers) and other
parameters to the model’s output(s)
iii. Create scenarios/iterations by generating several random numbers and
compute the output(s)
iv. Determine summary statistics (e.g., mean, standard deviation etc.) for the
output(s)
v. Analyse the results based on Summary statistics and graphs of outputs
(similar to sensitivity analysis). May require to return to step 1
vi. Present the final results

Zahraei and Ghosh, 2023 15


Simulation with Excel - The Newsboy Problem

▪ A newsboy must decide how many newspapers (Q) to buy for the next day.

▪ He does not know the demand for the next day (D) but knows the possible
quantities and their respective probabilities (i.e., demand distribution).
▪ He buys each newspaper at unit cost (UC) and sells them at regular price (SP). If
he cannot sell all the newspapers by the end of the day, unsold papers can only be
sold at a lower value (SV).
❑ He needs to decide the best quantity to buy that maximises his profit.

✓ A simulation model can be used to understand the impact of order quantity on


profit when a discrete probability distribution generates demand.

Zahraei and Ghosh, 2023 16


The Newsboy Problem - Simulation Model
Q: Order size
D: Demand
UC: Unit Cost
Profit = Revenue – Cost SP: Selling Price
SV: Salvage Value
Cost = UC × Q
Revenue comes from two sources:
Revenue from Regular price
▪ If D > Q ➔ SP × Q
➔ In Excel, this can be modelled as SP*MIN(D, Q)
▪ If D ≤ Q ➔ SP × D

Revenue from Reduced price


▪ If D > Q ➔ SV × 0
➔ In Excel, this can be modelled as SV*MAX(Q – D, 0)
▪ If D ≤ Q ➔ SV ×(Q – D)

Profit = SP*MIN(D, Q) + SV*MAX(Q - D, 0) – (UC × Q)


Zahraei and Ghosh, 2023 17
The Newsboy Problem - Simulation Model

Demand Distribution

✓ The probabilities of possible demand for newspapers the next day are generally
derived from the historical newspaper sales data in the previous months.

✓ A random number is generated based on this distribution to create a potential


demand.

✓ This generated demand is used to develop a simulation model to compute the


profit (the output for this problem) of selling newspapers.

Zahraei and Ghosh, 2023 18


Example 4.1. Simulation with Excel - The Newsboy Problem:
How Many Chicken Rice to Make in Grandma’s Kitchen
✓ Chicken Rice is the hot selling item for Grandma’s Kitchen, but the demand fluctuates a
lot, and Grandma is not sure what is the best quantity to make each day.

From historical data, demand for ✓ Each Chicken Rice dish sells for $6.90 and costs
chicken rice is estimated as: $4.90 to make. Dishes that are not sold at the end of
Demand/day Probability of demand
the day are sold at a at a reduced price of $2.90.
180 0.05
200 0.10
220 0.20 ✓ How many chicken rice dishes Grandma’s Kitchen
240 0.30 should prepare for the next day?
260 0.20
280 0.10
300 0.05

✓ Aim is to use built-in Excel tools to simulate profit for several order
quantities and ultimately choose the“best” order quantity.
Zahraei and Ghosh, 2023 19
Excel Reminder - VLOOKUP

Use VLOOKUP when you need to find things in a table or a range by row.

the column number in


What you want where you want the range containing
to look up to look for it the value to return
Zahraei and Ghosh, 2023 20
Example 4.1. Simulation with Excel - Grandma’s Kitchen
The first step is to develop the simulation model on Excel, based on the profit
function given by Profit = Revenue – Cost.
✓ We need to know the demand for chicken rice (out of the seven possible
demands) to calculate the revenue.
❑ Use RAND() function to generate a RN. (e.g., RN = 0.5628)
❑ Use VLOOKUP function to selects the demand based on the generated RN.
Demand Probability
Prob between
180 0.05
➢ For instance, RN = 0.5628 falls 0 0.05
200 0.10 0.05 0.15
within the fourth segment (0.35 to 220 0.20 0.15 0.35
0.65) ➔ D = 240. 240 0.30 0.35 0.65
260 0.20 0.65 0.85
280 0.1 0.85 0.95
300 0.05 0.95 1
Zahraei and Ghosh, 2023 21
Example 4.1. Simulation with Excel - Grandma’s Kitchen
Develop the simulation model on Excel:

Let’s start with


Q = 240

SP*MIN(D,Q) SV*MAX(Q - D,0) UC × Q Zahraei and Ghosh, 2023 22


Example 4.1. Simulation with Excel - Grandma’s Kitchen
Simulation of Grandma's Kitchen

Given Demand distribution


UC $4.90 Prob between Demand Probability
SP $6.90 0 0.05 180 0.05
SV $2.90 0.05 0.15 200 0.10
0.15 0.35 220 0.20
Decision variable 0.35 0.65 240 0.30
Q 240 0.65 0.85 260 0.20
0.85 0.95 280 0.1
0.95 1.00 300 0.05 For Q = 240
Simulation
Summary measures for simulation
Revenue Average profit $435.52
ReplicationRandom #Demand (D) Cost Profit
Regular Price Reduced Price Stdev of profit $68.71
1 0.7384 260 $1,656 $0 $1,176 $480 Minimum profit $240.00
2 0.5616 240 $1,656 $0 $1,176 $480 Maximum profit $480.00
Simulate for
1000 replications 3 0.4891 240 $1,656 $0 $1,176 $480
998 0.0230 180 $1,242 $174 $1,176 $240
999 0.8405 260 $1,656 $0 $1,176 $480
100 0.8812 280 $1,656 $0 $1,176 $480 ✓ Need to simulate profit for
various order quantities
Zahraei and Ghosh, 2023 23
Example 4.1. Simulation with Excel - Grandma’s Kitchen
Simulate Profit for Various Order Quantities

✓ Built-in excel tools cannot be used to determine the order quantity (Q) that
achieves maximum profit.

I. We can use different values of Q by changing the Q value in the


simulation model.

II. Another easier way is to use Data Table in Excel to determine the average
profits for different Q values.

➢ Data Table takes different values of a variable from the selected cells, carries
out the entire calculations, and presents results for each variable value.

Zahraei and Ghosh, 2023 24


Example 4.1. Simulation with Excel - Grandma’s Kitchen
Simulate profit for various order quantities

* Under What-if Analysis


within data Tab

✓ You may press F9 and see whether the


bar above 240 continues to be the
highest. (It usually is, but not always.)
Zahraei and Ghosh, 2023 25
Activity 4.1. Building a Simulation Model with Excel Built-in Functions

Suppose you own a car and purchased auto insurance. This insurance has a $1000
deductible, so that if you have an accident and the damage is less than $1000, you pay
for it out of your pocket. However, if the damage is greater than $1000, you pay the first
$1000 and the insurance pays the rest. In the current year there is probability 0.025 that
you will have an accident. If you have an accident, the damage amount is normally
distributed with mean $3000 and standard deviation $750.

Build a simulation model using Excel built-in functions to determine the amount of
money you have to pay for damages if there is an accident. Run 1000 iterations.
a) Find out the average, standard deviation, and maximum and minimum amount to pay.
b) Change the deductible amount as $500, $1000, $1500, and $2000 and determine the
same statistics. (You may use a data table for this problem.)

Hint: Use NORMINV(RAND(),µ,σ) to generate random number from a normal distribution with mean
and standard deviation of µ and σ, respectively.
Zahraei and Ghosh, 2023
Zahraei and Ghosh, 2023 26
Chapter 8
Simulation Tools

Zahraei and Ghosh, 2023


Zahraei and Ghosh, 2023
Introduction to @RISK

Advantages of add-in

✓ Gives easy access to many probability distribution that can be used


in the simulation models.

✓ Allows to perform simulations much more easily than is possible with


Excel alone.

Zahraei and Ghosh, 2023 28


@RISK Features

✓ Can designate any cell or range of cells in the simulation model as


output cells.
✓ Several statistics can be computed for this output cell.
✓ @RISK takes care of tedious bookkeeping operations for you.
✓ @RISK has a special function, RISKSIMTABLE, that allows you to run
the same simulation several times, using a different value of some key
input variable each time.

Zahraei and Ghosh, 2023 29


Steps for Developing a Simulation Model with @Risk

i. Plan your model and translate it into a spreadsheet model.


ii. Relate inputs variables (by generating by @RISK functions) and other
parameters to the model’s output(s).
iii. Define @Risk outputs.
iv. Run @Risk with the simulation settings required.
v. Determine summary statistics (e.g., mean, standard deviation etc.) for
the output(s) using build-in @RISK functions.
vi. Analyse results.
vii. Present results.

Zahraei and Ghosh, 2023 30


Generating Random Distributions

▪ The random demand can be generated using @RISK functions like


RISKDISCRETE, RISKNORMAL, RISKTRIANG etc.
▪ Some useful @Risk distributions
✓ RiskNormal(mean, std.dev.)
✓ RiskUniform(min, max) (Continuous)
✓ RiskTriang(min, likeliest, max)
✓ RiskBinomial(n,p)
▪ We typically highlight cells with random input with green
❑See @Risk help for more details on @Risk functions

Zahraei and Ghosh, 2023 31


@Risk Outputs
Defining an @Risk output:

Select Output from @Risk


ribbon and Define

or

Right click and choose Add


Output from @Risk menu

✓ Outputs values will be calculated when the simulation is run, for each run
✓ Different summary measures can be computed by @RISK functions (e.g.,
RISKMEAN, RISKSTDDEV, RISKMAX etc.)

Zahraei and Ghosh, 2023 32


Running the simulation by @Risk

Insert the simulation settings and click simulation

✓ Number of iterations
✓ 10000 is the maximal allowed in the student’s version
✓ Number of simulation
✓ 1 (unless wishes to run for several different decisions)
✓ Start Simulation

Zahraei and Ghosh, 2023 33


Example 4.2. Simulation with @Risk
How Many Chicken Rice to Make in Grandma’s Kitchen

✓ Recall the Grandma’s Kitchen problem in Example 4.1.

Demand/day Probability of demand


180 0.05
200 0.10 UC = $4.90
220 0.20 SP = $6.90
240 0.30 SV = $2.90
260 0.20
280 0.10
300 0.05

✓ Use @Risk to simulate the profit and find out how many chicken rice
dishes should Grandma’s Kitchen prepare for the next day.

Zahraei and Ghosh, 2023 34


Example 4.2. Simulation with @Risk
Building the Model on Excel

=RiskDiscrete(D4:D10,E4:E10) =@RiskOutput("Profit")+C13+D13-E13

Zahraei and Ghosh, 2023 35


Example 4.2. Simulation with @Risk
Running the Simulation

Summary

Browse Results
Zahraei and Ghosh, 2023 36
Example 4.2. Simulation with @Risk
Summary Measures of Profit

=RiskMean(F13)
=RiskStdDev (F13)

= @RiskMin(F13)

=@RiskMax(F13)
Zahraei and Ghosh, 2023 37
Order Quantity with Maximum Profit using @RISK

✓ Simulation model can run several times, with a different order quantity
✓ However, this has two drawbacks.
➢ it takes a lot of time and work.
➢ each time you run the simulation; you get a different set of random
demands.

✓ The RISKSIMTABLE function in @RISK enables you to obtain a fair


comparison quickly and easily.

Zahraei and Ghosh, 2023 38


Order Quantity with Maximum Profit using @RISK
RISKSIMTABLE function

=RiskSimtable(D13:I13)

=RiskMean(Profit,G20)

Zahraei and Ghosh, 2023 39


Discussion of the Simulation Results

✓ The strength of @RISK is that it keeps track of the outputs and shows
corresponding results as graphs or tables
✓ @RISK provides several options for displaying results
*You are encouraged to explore the possibilities.
❑ But the goal is to
✓see how outputs vary as random inputs vary
✓generate reports that tell the story most effectively.

Zahraei and Ghosh, 2023 40


Activity 4.2. Case 10.1 Ski Jacket Production

Refer to Case 10.1 Ski Jacket Production (page number 650 of the customised
textbook). Assume demand for ski packets follow a normal distribution or
triangular distribution Answer the following:

a) Based on the estimated demands, what are the probability distribution


parameters?
b) What is the best production quantity? The production quantity varies between
8000 and 14000 and can only be a multiple of 1000.

Zahraei and Ghosh, 2023


Zahraei and Ghosh, 2023 41
Simulation Model with More than One Random Variables

✓ There is another new source of uncertainty – supply of ingredients


✓ The maximum number, the supplier can supply for ingredients equivalent to the
number of meals follows a triangular distribution with parameters 125 (minimum),
200 (most likely), and 250 (maximum).
✓ That can be modelled by RISKTRIANG function.

Zahraei and Ghosh, 2023 42


Simulation Model with More than One Random Variables

=ROUND(RiskTriang(H4,H5,H6),0)

=MIN(C14,B9)

✓ We can use RISKSIMTABLE function


in @RISK to obtain the order quantity
with Maximum Profit

Zahraei and Ghosh, 2023 43


Summary of key Excel terms

Zahraei and Ghosh, 2023 44


Summary
• Simulation is the process of designing a model of a real system and conducting
experiments, either to understand the behaviour of the system or to improve it.
• There are different types of simulations, but we concentrated mainly on Monte Carlo
simulations where the output variables are functions of some random inputs.
• A simulation model can be developed by build-in Excel functions or some Excel add-ins.
• A Newsboy problem is considered and is solved by build-in Excel functions and Excel add-
in @RISK
• @RISK has several benefits over build-in Excel functions as it can store the results of the
simulation and present the results in graphs or charts
• The uncertainty in more than one input variables and correlation between the input
variables are also considered and modelled.

Zahraei and Ghosh, 2023 45


THANK YOU!

Zahraei and Ghosh, 2023 46


Zahraei and Ghosh, 2023

You might also like