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

Business Risk Management

Stochastic optimization
Introduction

Where does this fit in the


unit?
 We start a new section of the unit
 Previously we were looking at relatively simple decisions
with uncertainty (maximising expected utility in theory,
though actual decisions are likely to follow prospect
theory)
 This week we move to more complicated models for
example with changes happening over time, but we don’t
know in advance what will happen.
 With this framework it can be much harder to decide the
optimal choice – we need stochastic optimisation

1
What we will do

 We start by reviewing some basic concepts for


optimization methods
 We look at two stage stochastic optimization with
a continuous decision variable: “stochastic
optimization with recourse”
 We introduce a key technique: the generation of a
set of scenarios using Monte Carlo simulation
 We consider optimization problems where we
specify that there must be a high chance of
avoiding bad outcomes: use VaR constraints

Business Risk Management

Stochastic optimization
Fundamentals of optimization

2
Background on optimisation
 Three key components: decision variables; feasible set
and objective function
 What are the values for the decision variables x and y
that maximize the objective?
optimal contours of the
solution y objective
function are the
lines where there
Feasible are equal values
set X of the objective

How do we optimise?
 There are a great variety of methods. Most look at a set of
already visited points at which the objective function is
evaluated
 Then a ‘model’ is constructed to guess what the objective
function looks like
 This is used to guide the selection of a new point which we
hope is better than those so far looked at.
 The process is repeated: we call it “hill climbing”
 This is how the non-linear optimisation in Excel solver
works

3
A one-dimensional example

Unknown actual
function 1 − 𝑥 − 1

0 0.1 0.2 1.0

 Can be slow to converge

Constraints and local optima


 The feasible region is often defined by constraints, and
the maxima or minima may be at the boundary of the
feasible region (i.e. on a constraint)

local
minima

maximum

4
Local optima
 We may have multiple local optima without constraints

 If we maximize with hill climbing, where we end up


depends on where we start

A linear problem
 With a bounded feasible region a linear objective
ensures the optimum is at a boundary. Linear constraints
make the optimum at a corner
3

y
4x  y  6
2x  3y  8 2
maximum

4 y  5x  1 1 Objective
6x + 7y + 2

1 2 x 3

10

5
Business Risk Management

Stochastic optimization
Two stage problems

11

Optimising with uncertainty


 A common problem is the requirement to choose decision
variables with uncertainty about what will happen.
 We concentrate on optimisation problems with the
objective to maximize expected profit (or expected utility)
 We look at what happens when decisions take place at
different times and the uncertain events also take place
over time.
 For example a first stage decision is taken, then nature
takes its course (“the uncertainty is resolved”), then we
take another decision depending on what has happened.
 We will show how these problems can be formulated as
optimisation problems

12

6
Parthenon Oil Company
 The Parthenon Oil Company (POC) makes plans for
February and March. In February POC buys oil from the
market, delivers some to its customers right away and
puts the rest in storage for March
 In March the company can supply from storage or buy
from the market
 We need to decide x1, the amount to purchase in
February, and x2, the amount to purchase in March
 The decision depends on the price of oil in February and
March; the storage cost (say $5 per unit per month);
and the demand in each period. The price and demand in
March is uncertain (see the following table)

13

POC example (2)

Scenario Probability Oil cost $ Demand


Normal 1/3 160 1000
Cold 1/3 164 1200
Very cold 1/3 175 1400
 Notation: demand in March is d; cost in March is c
 Demand in February is 1000 barrels and the price is $160
 Since we purchase x1 in February the amount in storage at
the end of February is x1–1000, which Parthenon pays $5
per unit to store
 Subject to buying enough for March demand, we want to
minimize total costs: 160x1 + 5( x1–1000) + c x2

14

7
POC example (3)
 Constraints are
x1 ≥ 1000 (February demand is met)
x1 – 1000 + x2 ≥ d (March demand is met)
x2 ≥ 0 (cannot sell excess oil)
 Under scenario A (March is normal) it is optimal to take
x1 = 1000, x2 = 1000
 Under scenario B (March is cold) it is optimal to take
x1 = 1000, x2 = 1200
 Under scenario C (March is very cold) it is best to take
x1 = 2400, x2 = 0
 But we need to decide x1 before we know the scenario.
Should we take it as 1000 or 2400 or something else
(perhaps the average value 4400/3 ?)
15

POC example (4)


 Work with decisions that depend on the scenario x2A , x2B
and x2C . Use dA, dB, dC, cA, cB, cC, for demand and cost
variables
 Minimize expected costs:
160x1 + 5( x1–1000) + (cA x2A+cB x2B+cC x2C )/3
 subject to
x1 ≥ 1000
x1 – 1000 + x2A ≥ dA
x1 – 1000 + x2B ≥ dB Optimal solution has
x1 – 1000 + x2C ≥ dC x1 = 2000
x2A ≥ 0 , x2B ≥ 0, x2C ≥ 0

16

8
Recourse problems
 The POC example is a two-stage stochastic problem with
recourse
 At first stage we make a decision, say x
 Then a random event occurs, before the second stage
where we make another decision, y. Our decision on y
depends on both x and the random event
 At both stages costs are incurred (depending on our
decisions, with second stage costs also depending on the
random event)
 We want to choose x (and then y) to minimize the
expected costs

17

Structure in a diagram

First stage Second stage

Choose Cost from


y1 R1 y1
R1
Choose Random R2 Choose Cost from
x event y2 R2 y2
R3
Cost from x
Choose Cost from
y3 R3 y3

18

9
Solution options
 We set up an optimisation problem and solve using
general purpose software (like solver in Excel)
 One approach calculates the right second stage decision as
a function of the first stage choice; then we optimise for
the first stage choice (allowing for the probability of
different events)
 Another approach is to optimise over the second stage
choices at the same time as the first stage choice. This is
what we did in the spreadsheet with POC: it gives a larger
optimisation problem (more variables) but less analysis to
do.

19

Business Risk Management

Stochastic optimization
Monte Carlo simulation

20

10
Monte Carlo simulation
 Idea is to use a large number of scenarios to explore
possible behaviours. We need to be able to generate the
scenarios in a way which matches their actual likelihood
– so more likely scenarios are more likely to be
generated
 Set up a model with random components made explicit
and where each random element has a given distribution
 Use a (pseudo) random number generator – this will be
RAND() in Excel
 Then convert to the right distribution through the
inverse of the cumulative distribution function

21

Generating a distribution
 Find the cumulative distribution from the density.
f(x)

 Then invert it to get F -1 .


1

F(x) Random variable z


z uniform on [0,1]

0
F -1(z)
 The result F -1(z) has distribution given by f .
22

11
An example
 Suppose that the distribution has density
f ( x )  1.5  x
on the range 0  x  1

0 1

 What is the function to produce random samples from


this distribution, given a random number uniformly
distributed on (0,1) ?

23

Method
 Start by finding the CDF. If 𝑓(𝑥) = 1.5 − 𝑥 then
𝐹(𝑥) = 1.5𝑥 − 𝑥 /2 on the range (0,1).
 To find the inverse function write 𝑦 for 𝐹(𝑥) and then
rewrite to get 𝑥 in terms of 𝑦
 Here 𝑦 = 1.5𝑥 − 𝑥 /2
 So 𝑥 − 3𝑥 + 2𝑦 = 0
 This is a quadratic equation we can solve for 𝑥

 𝑥= (check values when 𝑦 = 0 and 𝑦 = 1)


 Excel formula becomes =(3-SQRT(9-8*RAND()))/2

24

12
Business Risk Management

Stochastic optimization
Value at Risk constraints

25

Reducing risk
 So far we have looked at maximising expected profit.
Maximising expected utility is similar
 But a stochastic optimisation framework with constraints
allows more complex objectives that take account of risk.
One option is to add a constraint that the objective should
never be worse than a certain value M
 This is an extra constraint for each scenario:
Objective evaluated for this scenario > M
 However with this approach there may be no feasible
solution

26

13
Value at Risk constraints
 Rather than ruling out bad behaviour it is sometimes
more natural just to make bad behaviour very rare
 Instead of saying that every scenario achieves a value no
worse than a value M, we could say that the probability
of being worse than M is very small (say less than 1%)
 With 500 equally likely scenarios this would be like
saying no more than 5 scenarios are worse than M
 We can say that M corresponds to the 99% Value at Risk
figure (or more precisely a loss of –M is the 99% Value at
Risk)

27

Portfolio with VaR


constraint (1)
 We want to maximise expected profit from a portfolio, but
also ensure that the probability of losing money is less than
0.5%. So VaR0.995 < 0. The table shows result of investing
$1000 in one of the stocks (returns are independent)
A B C
Mean profit 1000 600 1200
Standard dev. 400 200 600

 Consider investing in A and B only. Invest 1000wA in A and


1000wB in B with wA + wB = 1.
 Mean is 1000 wA  600 wB . Variance is 400 wA  200 wB
2 2 2 2

 Standard deviation is 400 2 wA 2  2002 wB 2

28

14
Portfolio with VaR
constraint (2)
 For a normal distribution: if mean > 2.5758 (st. dev) then
there is a less than 0.5% chance of a negative result.

0.005 probability
of being to the left
of the line

-4 -3 -2 -1 0 1 2 3 4

 So we require 1000wA  600wB  2.5758 4002 wA2  2002 wB 2


 Now 2.5758  400  1030.33 so this inequality doesn’t hold
when wA  1.

29

Portfolio with VaR


constraint (3)
 Divide through by wA and the constraint is:
1000  600( wB / wA )  2.5758 4002  2002 ( wB / wA )2
 Converts to the feasible region wB / wA  0.0511

wB Feasible
Contours of Optimal solution
region
the objective wA = 0.951,
1000 wA  600 wB wB = 0.049

wA 1

30

15
Portfolio with VaR
constraint (4)
 Now we allow all three stocks: A, B and C. The mean is
1000wA  600wB  1200(1  wA  wB )  1200  200wA  600wB
 Standard deviation 4002 wA2  2002 wB 2  6002 (1  wA  wB )2
1.0
Red lines show VaR constraint
wB
0.8
mean > 2.5758 (st. dev)
which defines an ellipse
Contours of the
objective (increasing
0.6
Feasible
towards origin) region
0.4

Optimal solution 0.2


wA = 0.2854,
wB = 0,
0.2 0.8 1.0
wC = 0.7146 0.4 0.6
wA
31

Summary

 Introduction to optimization
 Two stage stochastic optimization with recourse
 Warning: don’t use averages
 Monte Carlo simulation and generating random
variables from a given distribution
 Constraints based on Value at Risk

32

16

You might also like