Optimization under uncertainty: modeling and solution...

32
Dynamic programming Numerical dynamic programming Approximate dynamic programming Optimization under uncertainty: modeling and solution methods Paolo Brandimarte Dipartimento di Scienze Matematiche Politecnico di Torino e-mail: [email protected] URL: http://staff.polito.it/paolo.brandimarte Lecture 8: Stochastic dynamic programming P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Transcript of Optimization under uncertainty: modeling and solution...

Page 1: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Optimization under uncertainty:modeling and solution methods

Paolo BrandimarteDipartimento di Scienze Matematiche

Politecnico di Torino

e-mail: [email protected]: http://staff.polito.it/paolo.brandimarte

Lecture 8: Stochastic dynamic programming

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 2: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

REFERENCES

D.P. Bertsekas. Dynamic Programming and Optimal Control (Vols. I & II). Athena Scientific, 2005/2012.

P. Brandimarte. Numerical Methods for Finance and Economics: A Matlab-Based Introduction, (2nd ed.).Wiley, 2006.

P. Brandimarte. Handbook in Monte Carlo Simulation: Applications in Financial Engineering, RiskManagement, and Economics. Wiley, late 2013.

L. Busoniu, R. Babuška, B. De Schutter, D. Ernst. Reinforcement learning and Dynamic Programming UsingFunction Approximations. CRC Press, 2010

K.L. Judd. Numerical Methods in Economics. MIT Press, 1998.

F.A. Longstaff, E.S. Schwartz. Valuing American Options by Simulation: a Simple Least-Squares Approach.The Review of Financial Studies, 14 (2001) 113-147.

M.J. Miranda, P.L. Fackler. Applied Computational Economics and Finance. MIT Press, 2002.

W.B. Powell. Approximate Dynamic Programming: Solving the Curses of Dimensionality, (2nd ed.). Wiley,2011.

R.S. Sutton, A.G. Barto. Reinforcement learning. MIT Press, 1998.

I also recommend the Web page on computational stochastic optimization, maintained by Warren Powell ofPrinceton University: http://www.castlelab.princeton.edu/cso.htm

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 3: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

OUTLINE

1 DYNAMIC PROGRAMMING

2 NUMERICAL DYNAMIC PROGRAMMING

3 APPROXIMATE DYNAMIC PROGRAMMING

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 4: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

DYNAMIC PROGRAMMING

Dynamic programming is arguably the most powerful optimization strategyavailable.

In principle, it can be used to deal with:

discrete and continuous time models;

finite and infinite time horizons;

continuous and discrete state variables;

continuous and discrete decision variables;

deterministic and stochastic problems.

There is a huge literature on Markov Decision Processes, i.e., stochastic DPwith discrete state and discrete decisions, featuring significant links withArtificial Intelligence and Machine Learning. Here we illustrate only stochasticDP in discrete time with continuous state variables.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 5: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

SDP IN DISCRETE TIME, CONTINUOUS STATE

The starting point of a DP approach is a dynamic model based on a statetransition function:

st+1 = gt(st , xt , εt+1), (1)

where st is the state at time t , xt is the decision made after observing thestate, and εt+1 is a random disturbance occurring after we have made ourdecision.

The time horizon can be finite, in which case we have to make decisions att = 0, 1, . . . ,T , or infinite. In the latter case, it is typical to consider stationarystate transition functions, i.e., g does not depend on time.

When we make decision xt in state st , we incur an immediate cost or rewardft(st , xt). In finite-horizon problems, it is also possible to assign a value/costFT+1(sT+1) to the terminal state.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 6: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

OPTIMAL POLICIES

In a stochastic dynamic decision problem we cannot anticipate optimaldecisions x∗t . The decisions are a stochastic process depending on therealization of the disturbances and the resulting state trajectory.

In SDP we look for an optimal policy in feedback form, i.e., a mapping fromstate to decisions

xt = Aπ(st). (2)The mapping must be admissible, in the sense that we may have to complywith constraints on decisions and state variables.Let Π be the set of admissible policies. We want to solve the problems

maxπ∈Π

E

"TX

t=0

βt ft(st , xt) + βT+1FT+1(sT+1)

#(3)

or

maxπ∈Π

E

"∞Xt=0

βt f (st , xt)

#(4)

with discount factor β ∈ (0, 1] (β < 1 is needed in the latter case).

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 7: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

THE BELLMAN EQUATION: FINITE HORIZON

Problems (3) and (4) are intractable in general, but we may take advantage ofthe Markovian structure of the problem in order to decompose it with respectto time, obtaining a sequence of single period subproblems.

By “Markovian structure” we mean the structure of the state transitionequation (1) and the assumption of intertemporal independence of thedisturbance terms.

We refrain from giving a rigorous treatment, but the intuition behind DP isfairly easy to grasp. Let us define the value function Vt(st), for timet = 0, 1, . . . ,T , which is the optimal value obtained by applying an optimalpolicy starting from state st at time t .

Then, the following Bellman equation allows us to find the set of valuefunctions:

Vt(st) = maxxt∈X (st )

{ft(st , xt) + βE[Vt+1 (gt(st , xt , εt+1)) | st , xt ]} (5)

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 8: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

THE BELLMAN EQUATION: FINITE HORIZON

Eq. (5) is a recursive functional equation: if we knew the value functionVt+1(st+1), we could solve a set of one-step optimization problems in order tofind the value function Vt(st) for each st .

This requires unfolding the recursion backward from the last time period. If aterminal state value FT+1(sT+1) is given, then clearly we start from theterminal condition VT+1(sT+1) = FT+1(sT+1).

The first problem we have to solve is:

VT (sT ) = maxxT∈X (sT )

{fT (sT , xT ) + βE[VT+1 (gT (sT , xT , εT+1))]} (6)

for all values of the state variable sT in order to find the value function VT (sT ).

Given VT we step backwards and find VT−1:

VT−1(sT−1) = maxxT−1∈X (sT−1)

{fT−1(sT−1, xT−1) + βE[VT (gT−1(sT−1, xT−1, εT ))]}

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 9: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

THE BELLMAN EQUATION: FINITE HORIZON

We proceed recursively and finally find the value function V1:

V1(s1) = maxx1∈X (s1)

{f1(s1, x1) + βE[V2 (g1(s1, x1, ε2))]} (7)

Given V1 we find the optimal decision now, x∗0 , for the given initial state s0:

maxx0∈X (s0)

{f0(s0, x0) + βE[V1 (g0(s0, x0, ε1))]} (8)

It is also important to notice that the knowledge of the value functions allowsus to derive and apply the optimal policy in feedback form:

starting from the initial state s0 and based on V1(s), we solve anoptimization problem to obtain the optimal decision x∗0 ;

we apply x∗0 and, given the realization ε1, we end up in the next state s1;

there, given V2(s), we find x∗1 , and so on.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 10: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

THE BELLMAN EQUATION: INFINITE HORIZON

In the case of an infinite horizon, we usually suppress time dependence fromthe immediate contribution function f and the state transition function g.

In this case the Bellman equation essentially calls for the determination of atime-independent value function as a fixed point:

V (s) = maxx∈X (s)

{f (s, x) + βE[V (g(s, x, ε))]} (9)

In this case, too, we skip issues related to existence and uniqueness of thevalue function, and take for granted that by finding the value function we dosolve the original dynamic optimization problem (for a more rigoroustreatment see, e.g., Bertsekas).

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 11: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

Dynamic programmingSDP in discrete time, continuous stateThe Bellman equationThe three curses of dimensionality

THE THREE CURSES OF DIMENSIONALITY

The DP principle, although extremely appealing, suffers from severecomputational difficulties.

Solving the Bellman equation with finite time horizon, discrete and finite stateand action spaces, and a known matrix of transition probabilities is fairly easy.

However, when we deal with more complicated problems we have to facethree curses of dimensionality:

1 when the state space is multidimensional, the value function is a difficultobject to manage (more so, when the state space is continuous and weneed some form of discretization);

2 when the disturbance is a multidimensional random variable, theexpectation in the recursive equations is tough to compute;

3 the single-step optimization problem itself may have to cope with manydecision variables and possibly difficult constraints.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 12: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

The finite horizon caseThe infinite horizon case: collocation method

THE FINITE HORIZON CASE

In the continuous state case, we have to apply some form of discretization.One possibility is to discretize the state space using a grid. Given anapproximation bVt+1(s) for states on the grid, we may use, say, interpolationwith cubic splines to obtain values outside the grid.

Another form of discretization we need is sampling, in order to approximatethe expectation with respect to the disturbance term εt+1. We may generatescenarios with values εs

t+1 and probability πs (see Lecture 5).

Then, given the approximation bVt+1(s), we use numerical optimizationmethods to solve

bVt(st) = maxxt∈X (st )

(ft(st , xt) + β

SXs=1

πs bVt+1`gt(st , xt , ε

st+1)

´)

yielding the value function at time t for states st on the grid.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 13: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

The finite horizon caseThe infinite horizon case: collocation method

THE INFINITE HORIZON CASE: COLLOCATION METHOD

The infinite horizon case can be dealt with by projecting the value function ona linear space spanned by a set of basis functions and using the collocationmethod.

The collocation method requires choosing a set of basis functions toapproximate the value function:

V (s) ≈nX

j=1

cjφj(s).

Cubic splines could be a choice, but there are alternatives.

Given collocation nodes s1, . . . , sn, the Bellman equation for each state si

reads:

nXj=1

cjφj(si) = maxx∈X (si )

8<:f (si , x) + β E

24 nXj=1

cjφj (g(si , x, ε))

359=; (10)

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 14: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

The finite horizon caseThe infinite horizon case: collocation method

THE INFINITE HORIZON CASE: COLLOCATION METHOD

Eqs. (10) are a set of nonlinear equations in the unknown coefficients cj :

Φc = ν(c),

where Φ is the collocation matrix with elements Φij = φj(si), and thecollocation function ν(c) is a vector function with components:

νi(c) = maxx∈X (si )

8<:f (si , x) + β E

24 nXj=1

cjφj (g(si , x, ε))

359=; .

Newton’s method for nonlinear equations yields the iteration scheme:

c← c− [Φ−Θ(c)]−1 [Φc− ν(c)] ,

where the Jacobian matrix Θ(c) may be computed by the envelope theorem,

θij(c) =∂νi

∂cj(c) = β E[φj (g(si , xi , ε))] ,

and xi is the optimal decision for the optimization problem we solve to get thecollocation function value νi(c).

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 15: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

The finite horizon caseThe infinite horizon case: collocation method

THE INFINITE HORIZON CASE: COLLOCATION METHOD

In practice, conditional expectation is approximated by quadrature formulae.Assume weights (probabilities) and nodes (discretized shock values) aregiven by πs and εs, respectively, s = 1, . . . ,S.

Then we solve the following optimization problem to evaluate the collocationfunction:

νi(c) = maxx∈X (si )

8<:f (si , x) + βSX

s=1

nXj=1

πscjφj`g(si , x, εs)

´9=;with Jacobian

θij(c) = βSX

s=1

πsφj`g(si , xi , ε

s)´.

See (Judd, 1998) or (Miranda and Fackler, 2002) for additional information oncomputational DP in economics, or (Busoniu et al., 2010) for engineeringapplications.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 16: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

ADP: LEARNING BY MONTE CARLO METHODS

Numerical DP allows to use a powerful principle to a set of stochasticproblems with limited dimensionality.

With respect to stochastic programming, we have the advantage of gettingthe solution in (implicit) feedback form; the disadvantage is that we have toimpose some constraints on the structure of the disturbance terms.

However, large-scale problems cannot be tackled by standard discretization,and we must somehow resort to Monte Carlo methods.

A fundamental insight is that we really need only a decent approximation ofthe value function to find good, possibly near optimal policies.

We may use Monte Carlo methods and reinforcement learning to find suchan approximation.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 17: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

ADP: LEARNING BY MONTE CARLO METHODS

A comprehensive reference for ADP is (Powell, 2011), where several variantsof learning algorithms are described.

There are a few features distinguishing ADP from the numerical approachespreviously described:

1 we try to learn the expected value function directly, using optimalityequations based on post-decision state variables;

2 typical learning algorithms use forward passes, rather than backwardrecursion;

3 we may use batch or recursive learning algorithms, based on statisticalestimation.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 18: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

OPTIMALITY EQUATIONS AROUND THE POST-DECISION

STATE VARIABLES

The typical history of a stochastic decision process is:

(s0, x0, ε1, s1, x1, ε2, . . . , st−1, xt−1, εt , . . .)

Let us introduce a post-decision state variable sxt , which represents the state

of the system after our decision x, but before the realization of thedisturbance.

The state evolution is now:`s0, x0, sx

0, ε1, s1, x1, sx1, ε2, . . . , st−1, xt−1, sx

t−1, εt , . . .´

The exact definition of sxt depends on the context. As an example, it could be

the inventory state after we replenish, but before we satisfy demand.

Rather than writing optimality equations around Vt(st), we may use V xt (sx

t ),the value of being in state sx

t just after the decision.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 19: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

OPTIMALITY EQUATIONS AROUND THE POST-DECISION

STATE VARIABLES

We have

V xt−1(s

xt−1) = E

ˆVt(st) | sx

t−1˜

(11)

Vt(st) = maxxt

`ft(st , xt) + βV x

t (sxt )

˜(12)

V xt (sx

t ) = EˆVt+1(st+1) | sx

(13)

Clearly, we obtain the standard Bellman equation by plugging (13) into (12):

Vt(st) = maxxt

[ft(st , xt) + βE[Vt+1(st+1)])

But if we substitute (12) into (11) we find

V xt−1(s

xt−1) = E

max

xt

ˆft(st , xt) + βV x

t (sxt )

˜ff(14)

Big advantage: we have to solve a deterministic optimization problem.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 20: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

AMERICAN OPTION PRICING BY MONTE CARLO

We illustrate Monte Carlo-based DP with a simple example: pricing anAmerican-style put option on a non-dividend paying stock share.

Let S(t) be the price of a stock share. A possible continuous-time model ofprices is Geometric Brownian Motion (GBM), described by the stochasticdifferential equation:

dS(t) = µS(t) dt + σS(t) dW (t),

where µ is a drift, σ is a volatility, and W (t) is a standard Wiener process.

Using tools from stochastic calculus (Ito’s lemma), we may discretize thedifferential equation and simulate the process:

Sj = Sj−1 exp„

µ− σ2

2

«δt + σ

√δtεj

ffwhere Sj ≡ S(j · δt) for some discretization time step δt , and variables εj ,j = 1, . . . ,T , are a sequence of independent standard normals.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 21: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

AMERICAN OPTION PRICING BY MONTE CARLO

A put option on a stock share gives the right to sell a the underlying asset ata given strike price K fixed at t = 0.

Clearly, the option is exercised only if it is “in the money”, i.e., when theintrinsic value of the option K − S(t) is non-negative. The option payoff ismax{0,K − S(t)}.

European-style options can only be exercised at maturity t = T ;American-style options can be exercised at any time t ∈ [0,T ] beforeexpiration.

Using no arbitrage arguments, it can be shown that options should be pricedby taking the expected value of the payoff under a risk neutral measure. Inthe GBM case, this boils down to replacing the drift µ by the (continuouslycompounded) risk-free rate r .

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 22: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

AMERICAN OPTION PRICING BY MONTE CARLO

Pricing an American-style option entails solving an optimal stopping problem:when the option is in the money, we have to decide if we exerciseimmediately, earning the intrinsic value, or wait for better opportunities.

This is a dynamic stochastic optimization problem that can be tackled bydynamic programming, since GBM is a Markov process.

The state is (in principle) continuous, but the set of decisions is quite simple:either we exercise or we continue.

Nevertheless, pricing high-dimensional American options is a tough problem.We illustrate an ADP approach proposed in (Longstaff and Schwartz, 2001),based on the approximation of the value function by linear regression.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 23: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

AMERICAN OPTION PRICING BY MONTE CARLO

Using simple Monte Carlo, we generate sample paths(S0,S1, . . . ,Sj , . . . ,SN), where T · δt = N is the option expiration.

Let Ij(Sj) = max{K − Sj , 0} be the payoff from the immediate exercise of theoption at time j , and Vj(Sj) be the value of the option at time j when state isSj .

The value of the option is the maximum between the immediate payoff andthe continuation value. But the value of the continuation is the discountedexpected value of the option value at time j + 1, under the risk neutralmeasure Q:

EQj

he−r·δtVj+1(Sj+1)

˛Sj

iThe dynamic programming recursion for the value function Vj(Sj) is

Vj(Sj) = maxn

Ij(Sj) , EQj

he−r·δtVj+1(Sj+1)

˛Sj

io. (15)

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 24: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

APPROXIMATION BY LINEAR REGRESSION

We are going to approximate the conditional expectation inside (15) directlyas a function of Sj , using linear regression and a set of basis functionsψk (Sj), k = 1, . . . , L:

EQj

he−r·δtVj+1(Sj+1)

˛Sj

i≈

LXk=1

αkjSk−1j .

We use the same set of basis function for each time instant, but the weightsin the linear combination do depend on time.

The simplest choice we can think of is regressing the conditional expectationagainst a basis of monomials: ψ1(S) = 1, ψ2(S) = S, ψ3(S) = S2, etc. Theapproximation is nonlinear in Sj , but it is linear in terms of the weights.

Also note that:the approach corresponds to DP with post-decision state variables;linear regression on functions of Sj−1 ensures nonanticipativity of theresulting policy.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 25: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

THE BACKWARD RECURSION

In order to illustrate the method, we should start from the last time period.Assume we have generated N sample paths, and let us denote by Sji theprice at time j on sample path i = 1, . . . ,N.

When j = M, i.e., at expiration, the value function is trivially:

VM(SMi) = max{K − SMi , 0}

for each sample path i . These values can be used, in a sense, as theY -values in a linear regression, where the X values are the prices at timej = M − 1.

More precisely, we consider the regression model:

e−r·δt max{K − SMi , 0} =LX

k=1

αk,M−1Sk−1M−1,i + ei , i = 1, . . . ,N,

where ei is the residual for each sample path and weights αk,M−1 areobtained by ordinary least squares.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 26: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

THE MONEYNESS CRITERION

In the original paper it is suggested to include only the subset of samplepaths for which we have a decision to make at time j = M −1, i.e., the samplepaths in which the option is in the money at time j = M − 1 (the authors referto the idea as “moneyness criterion,” and its advantage is debated).

Denoting this subset by IM−1 and assuming L = 3, we solve the followingleast squares problem:

minX

i∈IM−1

e2i

s.t. α1,M−1 + α2,M−1SM−1,i + α3,M−1S2M−1,i + ei

= e−r·δt max{K − SMi , 0}, i ∈ IM−1. (16)

The output of this problem is a set of weights, which allow us to approximatethe continuation value. Note that the weights are linked to the time period,and not to sample paths. Using the same approximation for each samplepath in IM−1, we may decide if we exercise or not.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 27: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

Assume that we must price an American put with strike price K = 1.1 andthat eight sample paths have been sampled.

Path j = 0 j = 1 j = 2 j = 31 1.00 1.09 1.08 1.342 1.00 1.16 1.26 1.543 1.00 1.22 1.07 1.034 1.00 0.93 0.97 0.925 1.00 1.11 1.56 1.526 1.00 0.76 0.77 0.907 1.00 0.92 0.84 1.018 1.00 0.88 1.22 1.34

Path j = 1 j = 2 j = 31 - - .002 - - .003 - - .074 - - .185 - - .006 - - .207 - - .098 - - .00

For each sample path, we also have a set of cash flows at expiration; cashflows are positive where the option is in the money.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 28: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

Cash flows are discounted back to time j = 2 and used for the first linearregression. Assuming a risk free rate of 6% per period, the discount factor ise−0.06 = 0.94176.The data for the regression are given in the table below: X corresponds tocurrent underlying asset price and Y corresponds to discounted cash flows inthe future.

Path Y X1 .00 × .94176 1.082 - -3 .07 × .94176 1.074 .18 × .94176 0.975 - -6 .20 × .94176 0.777 .09 × .94176 0.848 - -

Only the sample paths in which the option is in the money at time j = 2 areused. The following approximation is obtained:

E[Y | X ] ≈ −1.070 + 2.983X − 1.813X 2.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 29: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

Now we may compare at time j = 2 the intrinsic value and the continuationvalue.

Path Exercise Continue1 .02 .03692 - -3 .03 .04614 .13 .11765 - -6 .33 .15207 .26 .15658 - -

Path j = 1 j = 2 j = 31 - .00 .002 - .00 .003 - .00 .074 - .13 .005 - .00 .006 - .33 .007 - .26 .008 - .00 .00

Given the exercise decisions, we update the cash flow matrix.Note that the exercise decision does not exploit knowledge of the future.Consider sample path 4: we exercise, making $0.13; on that sample path, wewould regret our decision, because we could make $0.18 at time j = 3.We should also note that on some paths we exercise at time j = 2, and this isreflected by the updated cash flow matrix in the table.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 30: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

To carry out the regression, we must consider the cash flows on each path,resulting from early exercise decisions. If we are at time j , for each samplepath i there is an exercise time j∗e (set conventionally to M + 1 if the optionwill never be exercised in the future).Then the regression problem (16) should be rewritten, for the generic timeperiod j , as:

minXi∈Ij

e2i

s.t. α1j + α2jSji + α3jS2ji + ei (17)

=

(e−r(j∗e −j) δt max{K − Sj∗e ,i , 0} if j∗e ≤ M0 if j∗e = M + 1

i ∈ Ij .

Since there can be at most one exercise time for each path, it may be thecase that after comparing the intrinsic value with the continuation value on apath, the exercise time j∗e is reset to a previous period.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 31: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

Stepping back to time j = 1, we have the following regression data:

Path Y X1 .00 × .88692 1.092 - -3 - -4 .13 × .94176 0.935 - -6 .33 × .94176 0.767 .26 × .94176 0.928 .00 × .88692 0.88

The discount factor e−2·0.06 = 0.88692 is applied on paths 1 and 8. Since thecash flow there is zero, the discount factor is irrelevant, but note that we arediscounting cash flows from time period j = 3.Least squares yield the approximation:

E[Y | X ] ≈ 2.038− 3.335X + 1.356X 2.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty

Page 32: Optimization under uncertainty: modeling and solution methodscalvino.polito.it/~probstat/Brandimarte_Lect08.pdf · Numerical Methods for Finance and Economics: A Matlab-Based Introduction,

Dynamic programmingNumerical dynamic programming

Approximate dynamic programming

ADP: Learning by Monte Carlo methodsBellman equation with post-decision state variableRegression based dynamic programming

A NUMERICAL EXAMPLE

Based on this approximation of the continuation value, we obtain thefollowing exercise decisions:

Path Exercise Continue1 .01 .01392 - -3 - -4 .17 .10925 - -6 .34 .28667 .18 .11758 .22 .1533

Path j = 1 j = 2 j = 31 .00 .00 .002 .00 .00 .003 .00 .00 .074 .17 .00 .005 .00 .00 .006 .34 .00 .007 .18 .00 .008 .22 .00 .00

Discounting all cash flows back to time j = 0 and averaging over the eightsample paths, we get an estimate of the continuation value of $0.1144, whichis larger than the intrinsic value $0.1; hence, the option should not beexercised immediately.

P. Brandimarte – Dip. di Scienze Matematiche Optimization Under Uncertainty