You are on page 1of 49

MMGT6012

Business Tools for Management

TOPIC 10: Simulation Modelling


Dr. Matthew Beck
ITLS, Business School

The University of Sydney Page 1


10. Simulation Modelling

We attempt to create copy of an environment:


– Experiment in that pseudo-environment to gather data about different
actions before we implement that behaviour in the real world

Applied experiments fundamental to all sciences:


– Testing of medicine on laboratory animals where the animal responses
simulate human responses
– Driving automobiles on test tracks where the test track simulates the
environment the auto will face
– Training airline pilots in actual cabins with simulated out-of-the-window
displays under simulated conditions

The University of Sydney Page 2


10. Simulation Modelling

What is Simulation?

The University of Sydney Page 3


10. Simulation Modelling

What is Simulation?

Our modelling is done in a computer environment:


– Creating and analyzing a digital prototype
– Predict its performance in the real world

Simulation differs to optimisation:


– Fundamental difference lies in the role of decision variables

Consider the following example:


– An airline wants to know how best to assign cabin staff across all the flights
on a particular day so that it minimises labour costs, subject to satisfying
minimum service times and safe working hours

The University of Sydney Page 4


10. Simulation Modelling

What is Simulation?

In Optimisation Modelling:
– Model parameters are fixed
– We know all numbers of passengers
– We know all flight times
– We know exactly how long it takes to serve each passenger

Because values are fixed we can get an optimal solution:


– Best way to assign cabin staff
– Optimised total cost (objective function)
– How much slack in the constraints

The University of Sydney Page 5


10. Simulation Modelling

What is Simulation?

In Simulation Modelling:
– Model parameters are uncertain
– A range of different passenger numbers is possible
– Flight times may differ to schedule for a variety of reasons
– Service time per passenger may have some variance around the average

We cannot calculate a single optimal solution:


– There are too many possible combinations of outcomes

The University of Sydney Page 6


10. Simulation Modelling

What is Simulation?

We provide a potential solution and simulate performance:


– One possible allocation of staff
– Get one possible set of passenger numbers
– Get one possible set of flight times
– Get one possible set of service times

Identify different performance measures of interest:


– Total costs of labour
– Total time for how long passengers took to be served
– Total time staff are working for

The University of Sydney Page 7


10. Simulation Modelling

What is Simulation?

Assess how that potential solution performs for that one outcome:
– Repeat the process many times so we see how it performs in many different
set of potential outcomes

Look at the overall distribution of how that solution performs:


– Average costs of labour
– Average time for how long passengers took to be served
– Average time staff are working for

The University of Sydney Page 8


10. Simulation Modelling

What is Simulation?

We see average outcomes:


– But we can also calculate variability around that average
– Best case outcomes
– Worst case outcomes

Judge the sensitivity to the system by changing inputs:


– What happens when we add two more staff to the model
– What happens if passenger numbers increase by 10%

The University of Sydney Page 9


10. Simulation Modelling

What is Simulation?

Optimisation Model
– Decision variables are outputs
– Model provides a set of values for the decision variables that maximises (or
minimises) the value of the objective function

Simulation Model:
– Decision variables are inputs
– The model evaluates the objective function for a particular set of values

The University of Sydney Page 10


10. Simulation Modelling

Probability Distributions

In optimisation models we provide fixed values:


– A single number for every input into the model

In simulation models we provide a distribution of values:


– A range of possible outcomes with different probabilities for each outcome

There are two types of variables:


– Categorical: Where a limited number of events can occur
– Continuous: An almost infinite number of possible values could occur

The University of Sydney Page 11


10. Simulation Modelling

Probability Distributions

We represent uncertainty by assuming different probabilities

A coin toss is a categorical outcome:


– Only two possible outcomes
– Heads or Tails

A discrete distribution:
– Limited number of discrete outcomes
– A uniform distribution (each outcome has the same chance of occurring)

The University of Sydney Page 12


10. Simulation Modelling

Probability Distributions

If we toss a coin twice:

What combinations of results are possible?


– Head then Head
– Head then Tail
– Tail then Head
– Tail then Tail

(1) (2)
The University of Sydney Page 13
10. Simulation Modelling

Probability Distributions

What is the probability of getting the following number of tails:


Number of Tails Number of Comb. Probability
0
1
2

The University of Sydney Page 14


10. Simulation Modelling

Cumulative Probability Distributions

What is the probability of getting results within a certain range:


– What is the probability that temperature will be 25-30oC

What is the probability of getting X or <X number of tails:

Number of Tails Probability Cumulative Prob.


0
1
2

The University of Sydney Page 15


10. Simulation Modelling

Probability Distributions

We use the properties of distributions to simulate uncertainty:


– Discrete: Limited number of discrete (categorical) outcomes
– Uniform: Each outcome (cont. or cat.) has the same chance of occurring
– Normal: Follows the property of the Normal (68%, 95%, 99% etc)
– Log-Normal: Follows the log of the Normal (useful if X must be more than 0)
– Triangular: Used when you have limited information (min, max, most likely)

The University of Sydney Page 16


10. Simulation Modelling

Monte Carlo Simulations

We introduce uncertainty to they model via Monte Carlo:

1. Generate a random probability

2. Use that probability to draw from a distribution

3. Use the outcome of the draw as a simulated value

Monte Carlo is part of simulation not a type of simulation model

The University of Sydney Page 17


10. Simulation Modelling

Example of Monte Carlo (1)

A manager of a computer store is interested in better forecasting


revenue from a particular type of laptop:
– Sells between 0 and 4 laptops every week
– Each laptop retails for $4300
– Uses last 100 weeks of sales history to generate probability distribution

This is an abstraction of reality:


– We only have one uncertain variable
– Once we can generate one uncertainty it is easy to add many more
– The sales of different products that contribute to overall revenue

The University of Sydney Page 18


10. Simulation Modelling

Example of Monte Carlo (1)

Sales data over the last 100 weeks suggests this distribution:

PCs Demanded/week Frequency of Probability of


Demand Demand, P(x)
Zero 20
One 40
Two 20
Three 10
Four 10
TOTAL 100

The University of Sydney Page 19


10. Simulation Modelling

Example of Monte Carlo (1)

Each probability could be converted to the area of a pie:


Four
10% Zero
20%
Three
10%

Two
20%

One
40%

Think of a roulette wheel:


– When we spin the wheel we don’t know what we will get
– But different outcomes have a different probability of occurring

The University of Sydney Page 20


10. Simulation Modelling

Example of Monte Carlo (1)

Now think of numbers around


the outside of the wheel
instead…

There are 20 numbers


assigned to the result of zero
computers:
– Reflects the 20% chance of this
result occurring

The University of Sydney Page 21


10. Simulation Modelling

Example of Monte Carlo (1)

Now suppose the manager spins the wheel and gets 39:

39 is in the range of numbers assigned to a result of one laptop

The University of Sydney Page 22


10. Simulation Modelling

Example of Monte Carlo (1)

The University of Sydney Page 23


10. Simulation Modelling

Example of Monte Carlo (1)

The University of Sydney Page 24


10. Simulation Modelling

Example of Monte Carlo (1)

The University of Sydney Page 25


10. Simulation Modelling

Example of Monte Carlo (2)

Matt would like to simulate his score on a hole of golf (Par 3) :


– Based on scores from previous rounds he has the following data

Score # Times Probability of Cumulative Range of


Score Probability Random #’s
Hole in One 2
Birdie 7
Par 25
Bogey 11
Double Bogey 3
Triple Bogey 2

The University of Sydney Page 26


10. Simulation Modelling

Example of Monte Carlo (2)

The University of Sydney Page 27


10. Simulation Modelling

Example of Monte Carlo (2)

From the random number table on previous slide:


– Using the first row as the random number draw
– Simulate the score for 10 different attempts at the hole

Week 1 2 3 4 5 6 7 8 9 10

Random #

Sim. Score

The University of Sydney Page 28


10. Simulation Modelling

Monte Carlo in Excel

At the end of this topic there are slides for your own benefit:
– We are not explaining these formulas in great detail in the lecture

Please read them and practice them in Excel:


– Note that the Excel for Transport and Logistics Guide goes through each
formula in detail, with worked examples

There is also a very detailed example in the Workbook!

The University of Sydney Page 29


10. Simulation Modelling

Monte Carlo in Excel

1. Setup the distribution from which to draw:

I set it up like this so the vlookup formula works


The University of Sydney Page 30
10. Simulation Modelling

Monte Carlo in Excel

2. Setup the random draws and link to the distribution:

The University of Sydney Page 31


10. Simulation Modelling

Monte Carlo in Excel

3. Setup the tabulation of results:

The University of Sydney Page 32


10. Simulation Modelling

Monte Carlo in Excel

4. Insert a chart to visualise results:

The University of Sydney Page 33


10. Simulation Modelling

The Role of Iterations

More iterations (repeated simulations) of a model result in:


– Convergence of unknown variables to their expected value
– Wider interaction of variables across range of possible values
– Better analysis of outlying, low probability events

We only simulate golf scores for ten attempts:


– What if we wanted to increase the number of trial days?

The University of Sydney Page 34


10. Simulation Modelling

The Role of Iterations

You can just create a longer column of potential scores:

I just copy and pasted the random draw down 1000 rows
The University of Sydney Page 35
10. Simulation Modelling

The Role of Iterations

You can create a macro:

The University of Sydney Page 36


10. Simulation Modelling

Macro Master Command

Sub Simulation()
Max_It = Range(“F11").Value
For Iteration = 1 To Max_It
Range(“F12").Value = Iteration
Next Iteration
End Sub

The University of Sydney Page 37


10. Simulation Modelling

Totalling the Iterations

We have added formulas in range B12:C17:


– These only tabulate the results of the single iteration in J2:J12

We need to collate the results for the 1000 iterations!


– Fortunately we can simply “Record New Macro”.

This means we don’t have to know the specific code, but we do


have to have an idea of what we want to do.

The University of Sydney Page 38


10. Simulation Modelling

Recording a Macro

We want to record a Macro that copies the individual results:


– Adds them together so we get all the results

– Name the Macro


– Select J2:J12 and copy this range
– Right click on B21 and select paste special
– Choose the Value and Add options
– Stop recording the Macro

The University of Sydney Page 39


10. Simulation Modelling

Recording a Macro

We want to record a Macro that copies the individual results:


– Adds them together so we get all the results

– Name the Macro (Score)


– Select J2:J12 and copy this range
– Right click on B21 and select paste special
– Choose the Value and Add options
– Stop recording the Macro

The University of Sydney Page 40


10. Simulation Modelling

Adjust Master Macro

Sub Simulation()
Max_It = Range(“F11").Value
For Iteration = 1 To Max_It
Score
Range(“F12").Value = Iteration
Next Iteration
End Sub

The University of Sydney Page 41


10. Simulation Modelling

Recording a Macro

Now record Macro resets the simulation for every new run:
– Name the Macro (Reset)
– Select B21:B26 and press delete
– Stop recording the Macro

The University of Sydney Page 42


10. Simulation Modelling

Adjust Master Macro

Sub Simulation()
Reset
Max_It = Range(“F11").Value
For Iteration = 1 To Max_It
Score
Range(“F12").Value = Iteration
Next Iteration
End Sub

The University of Sydney Page 43


Useful Excel Formulae

– Locking a cell reference:

– Copying and pasting formulas in Excel will result in the


equations being changed.

– If you want to avoid this you need to lock the cell reference.
– Change it from a relative to an absolute cell reference.

– To lock a cell reference so that it does not adjust when you


copy it, all you need to do is add dollar signs to the cell
reference
– $A1 = Always reference column A.
– A$1 = Always reference row 1.
– $A$1 = Always reference column A, row 1.

The University of Sydney Page 44


Useful Excel Formulae

– Generating random numbers:

– =Rand()
– Generates a random number between 0 and 1.

– =RandBetween(X,Y)
– Generates a random number between X and Y.
– =RandBetween(1,100)
– Generates random numbers between 1 and 100.

The University of Sydney Page 45


Useful Excel Formulae

– Multiplying large amounts of information:

– Use the SUMPRODUCT command:

=sumproduct(A1:A10,B1:B10)
=28001
=(A1*B1)+(A2*B2)+(A3*B3)+…+(10*B10)

The University of Sydney Page 46


Useful Excel Formulae

– Logic test, or selecting between options:

– =if(logical test, value if true, value if false)


– Logical test – The question we want to ask. Is the value in Column A
larger than the value in Column B?
– Value if true – what do we want displayed if the answer to our question
is “true”? In this example, let’s say we want the answer to be “yes”
– Value if false – what do we want displayed if the answer is “false”? In
this example, let’s say we want “no”.

– How do we build an IF statement?


– =IF(A2>B2,"yes","no")

The University of Sydney Page 47


Useful Excel Formulae

– Counting cells that meet a certain criteria:

– =COUNTIF(range, criteria)
– In Excel, the CountIf function counts the number of cells in a range, that
meets a given criteria.
– range is the range of cells that you want to count based on the criteria.
– criteria is used to determine which cells to count and how to count them.

The University of Sydney Page 48


Useful Excel Formulae

– Looking for data and reporting findings back

Value to If you find that value, report the


look for value in this column of data

=VLOOKUP($F2,$A$2:$B$8,2,TRUE)

Look for that value in these True = Find the lowest boundary
rows and columns False = Find the exact match

The University of Sydney Page 49

You might also like