Numerical Methods for Valuation and Optimal Operation of Natural Gas Storage
Erik Magnus G. Følstad
Master of Science in Physics and Mathematics Supervisor: Espen Robstad Jakobsen, MATH
Department of Mathematical Sciences Submission date: March 2015
Norwegian University of Science and Technology
Abstract
The thesis describes different approaches for solving numerically a PDE model for the valuation and optimal operation of natural gas storage, characterized as a Hamilton Jacobi Bellman (HJB) equation. The HJB equation is derived by for- mulating the given natural gas storage problem as a stochastic control problem and then applying the dynamic programming principle. We present three separate numerical methods for solving the HJB equation, namely a standard upwind finite difference method, and two new methods characterized as: (i) a semi-Lagrangian time stepping method combined with a one dimensional finite element method, and (ii) a two dimensional finite element method combined with finite difference dis- cretization in time. The upwind finite difference method is shown to be consistent, stable and monotone. These properties guarantee that the numerical solution con- verge to the viscosity solution of the HJB equation, [19]. Numerical results suggest that the two new methods converge to the same solution as the finite difference method for a given test case.
Sammendrag
Denne oppgaven beskriver ulike numeriske metoder for ˚a løse en PDE modell for verdisetting og optimal styring av naturgasslagring, gitt som en Hamilton Jacobi Bellman (HJB) likning. Likningen er utledet ved ˚a først formulere problemstillin- gen som et stokastisk kontrollproblem og deretter benytte dynamisk programmer- ingsprinsippet. Vi presenterer tre ulike metoder for ˚a løse denne likningen, nærmere bestemt en standard oppvind differanse metode, og to nye metoder beskrevet som:
(i) en semi-Lagrangian tids-diskretiseringsmetode kombinert med endelig element metode i en romlig retning, og (ii) en endelig elementmetode i to romlige retninger kombinert med endelig differanse i tid. Det blir vist at differansemetoden er konsis- tent, stabil og monoton, hvilket impliserer at den numeriske løsningen konvergerer til viskositetsløsningen av HJB likningen, [19]. Numeriske resultater tyder p˚a at de to nye metodene konvergerer mot samme løsning som differansemetoden for et gitt test-problem.
Contents
1 Introduction 9
1.1 Previous Work . . . 9
1.2 The purpose of this thesis . . . 9
1.3 Contribution . . . 10
1.4 Outline . . . 10
2 Background 11 2.1 Stochastic control theory . . . 11
2.2 Dynamic Programming Principle and the Hamilton Jacobi Bellman Equation . . . 12
2.3 Derivation of the Natural Gas Storage Model . . . 13
2.4 Important assumptions about the NGS model . . . 17
2.4.1 Boundary . . . 17
2.4.2 Bang-bang controls . . . 19
3 A Monotone Finite Difference Scheme 21 3.1 Grid . . . 21
3.2 The upwinding technique . . . 22
3.3 Numerical scheme . . . 23
3.3.1 Boundary . . . 23
3.4 Monotonicity . . . 24
3.5 Stability . . . 26
3.6 Consistency . . . 28
3.7 Implementation . . . 29
4 The Finite Element method (1D) 33 4.1 Weak Formulation . . . 33
4.2 Approximation . . . 34
4.3 Stabilization . . . 36
4.4 Matrix Formulation . . . 36
4.5 Implementation . . . 37
4.5.1 Computation of integrals . . . 37
4.5.2 Assembly of matrices . . . 38
5 A Semi-Lagrange Finite Element Method 39
5.1 Linearization . . . 40
5.2 Derivation of the numerical scheme . . . 41
5.3 Implementation . . . 43
6 A Finite Element Method (2D) 47 6.1 Weak formulation . . . 49
6.2 Approximation . . . 50
6.3 Stabilization . . . 51
6.4 Time Discretization . . . 52
6.5 Solving the Optimization problem . . . 52
6.6 Numerical computation of integrals . . . 53
6.6.1 Mapping from the triangular reference element . . . 54
6.6.2 Transformation of integrals . . . 55
6.7 Implementation . . . 56
7 Numerical Results 59 7.1 A “realistic” test case . . . 59
7.2 Testing the convergence rate . . . 60
7.2.1 FE method . . . 61
7.2.2 FE-Semi-Lagrangian . . . 62
7.3 Verification of convergence to the viscosity solution . . . 63
8 Conclusion 67 8.1 Summary . . . 67
8.2 Challenges . . . 68
8.3 Future Work . . . 68
List of Figures
4.1 Node placement on a generic elementKi= [xi, xi+1]∈ Th, for linear, quadratic and cubic elements. Nodes displayed as black dots. . . 35 6.1 P1, P2 and P3 triangular elements with nodes (degrees of freedom)
displayed in black. . . 50 6.2 Mapping ˆF(ˆx,y) := (g(ˆˆ x,y), h(ˆˆ x,y))ˆ > from the reference element ˆK
(left) to a physical elementK (right). . . 54 7.1 Numerical solution of the value function and the optimal control
policy evaluated atτ = 1. The discretization parameters are ∆x= xmax/20,∆y=ymax/20 and ∆τ=T /200. . . 65 7.2 Numerical solution of the value function after 10 time steps, with
h= 0.04 and ∆τ = 0.0156. When we remove the edge stabilization, spurious oscillations are observed in the solution. The oscillations starts inx= 0, where there is least diffusion. Similar observation are made withP1elements. We found that the stabilization parameters γ= 0.02 andγ= 0.5 worked well forP1 andP2 elements respectively. 66
List of Tables
4.1 Gauss quadrature rules for the reference interval (−1,1). . . 37 6.1 Gauss quadrature rules for the reference triangle. . . 54 7.1 Verification of the convergence rate ˆβ = 2 for the p1-FE method.
withα= 0.7071. The stabilization parameter isγ= 0.5 . . . 62 7.2 Verification of the convergence rate ˆβ = 3 for the p2-FE method.
withα= 0.7937. The stabilization parameter isγ= 0.02 . . . 62 7.3 Verification of the convergence rateβ = 2 for thep1-SLFE method
withα= 0.7071. No edge stabilization is used (γ= 0). . . 63 7.4 Verification of the convergence rateβ = 3 for thep2-SLFE method
withα= 0.7937. No edge stabilization is used (γ= 0). . . 63 7.5 Verification of convergence to the viscosity solution for theP1-SLFE
method; ˜vk and ˆvk represent the solutions of theP1-SLFE-method and the finite difference method, respectively. No edge stabilization is used (γ= 0). . . 64 7.6 Verification of convergence to the viscosity solution for theP2-SLFE
method; ˜vk and ˆvk represent the solutions of theP2-SLFE-method and the finite difference method, respectively. No edge stabilization is used (γ= 0). . . 64 7.7 Verification of convergence to the viscosity solution for the P1-FE
method; ˜vk and ˆvk represent the solutions of theP1-FE-method and the finite difference method, respectively. The stabilization param- eter isγ= 0.5. . . 64 7.8 Verification of convergence to the viscosity solution for the P2-FE
method; ˜vk and ˆvkrepresent the solutions of the FE-method and the finite difference method, respectively. The stabilization parameter isγ= 0.02. . . 64
Chapter 1
Introduction
The real option of storing natural gas in the presence of uncertain gas prices is im- portant in planning-models for the production of natural gas and allows industries to exploit spot market variations and seasonal trends, [15]. As we will demonstrate, the real option of storing natural gas can be modeled as a stochastic control prob- lem from which a Hamilton Jacobi Bellman (HJB) equation is derived. This thesis is concerned with the numerical solution of such models.
1.1 Previous Work
Thompson et al. [14] derive a natural gas storage model in the form of a HJB equa- tion and propose a fully explicit finite difference scheme. Because of the hyperbolic nature of the HJB equation, the need for stabilization techniques to prevent numer- ical oscillations are addressed. Thompson et al. suggest a min-mod slope limiting method to cope with this problem.
Forsyth and Chen [19] present an implicit semi-Lagrange time stepping scheme combined with a finite difference method for the natural gas problem and show that the scheme converges to the viscosity solution of the HJB equation by proving that the scheme is consistent, stable and monotone. The semi-Lagrange time stepping method is widely used in the field of numerical weather predictions [13] and is known to be stabilizing for convection dominated problems.
1.2 The purpose of this thesis
• Provide modeling background and derive the HJB equation for the natural gas storage problem.
• Study numerical methods for solving the given HJB equation and propose new methods.
• Implement the methods in MATLAB and conduct numerical experiments.
1.3 Contribution
After providing a modeling background for the HJB equation, we study an upwind finite difference method which is shown to be consistent, stable and monotone provided a linear CFL-condition. Then two new methods for this problem are introduced:
(i) A semi-Lagrangian time stepping method in one spatial direction combined with a finite element method in the other spatial direction. The method is inspired from [19]. Another method that combines semi-Lagrangian time stepping with finite elements is given in [18], however, in [18] finite elements and semi-Lagrangian time stepping are applied in the same spatial direction.
(ii) A two dimensional finite element method combined with a finite difference discretization in time. To cope with the issue of spurious oscillations we have implemented the edge stabilization technique as given by Burman and Hansbo [4].
1.4 Outline
Chapter 2 Some basic ideas from the field of stochastic control theory are in- troduced. These ideas are applied in section 2.3 to derive a model for the valuation and optimal operation of a natural gas storage facility in the form of a Hamilton Jacobi Bellman equation.
Chapter 3 An upwind finite difference scheme is described and analyzed. The scheme is shown to be consistent, stable and monotone provided a linear CFL-condition.
Chapter 4 This chapter is to intended as a brief introduction to the finite element method which will be used in the chapter 5.
Chapter 5 A semi-Lagrange time stepping combined with a finite element method is presented. A fully implicit scheme is achieved via a linearization technique.
Chapter 6 We present a finite element method coupled with finite finite difference time stepping. Edge stabilization [4] is implemented to prevent numerical oscillations.
Chapter 7 Numerical experiments are conducted with a standard test case in the literature.
Chapter 8 We summarize the work and give some concluding remarks.
Chapter 2
Background
2.1 Stochastic control theory
Many real life phenomena, in which the random nature of certain quantities plays a significant role, can be successfully modeled as a stochastic differential equation (SDE). For instance, in finance, stochastic differential equations can be used to describe the evolution of stock prices or commodity prices [12].
In the field of Stochastic control theory, one studies how the state of a sys- tem, given as the solution of a system of SDE’s, is influenced by some controlled parameter. The objective is typically to maximize (or minimize) some functional that depends on the the state of the system by choosing the optimal value for the controlled parameter. As described in [9, p. 27], a stochastic control problem is characterized by the following features;
• State of the system: We consider a systemX= (X1, X2. . . , Xn) satisfying a system of SDE’s. The state of the system at any times≥0 is given byX(s).
• Control: The systemXis influenced by a controlled processα:s→A⊂R. The value ofαat timesmust be chosen by using only available information at times. In addition,αmust satisfy certain constraints to beadmissible.
• Performance criterion: The objective is to maximize (or minimize) some functional P(X, α) over all admissible controls. Hence, a stochastic control problem can be defined as finding an optimal controlα∗, such thatP(X, α∗) is maximized (or minimized).
Lett, T ∈R, such that 0≤t < T. Let f :Rn×A→Rn be a given function and letArepresent the set of admissible control functions
A={α: [t, T]→A|α(·) admissible}.
The dynamics of the state X of the system is dependent on the control process
α(·)∈ Aand is given by the SDE
dX(s) =f(X(s), α(s), s)ds+σ(X(s), s)dW(s), t < s < T (2.1)
X(t) =x, (2.2)
where dW(s) represents the standard increment of an n-dimensional Brownian motion and σis assumed to be a known deterministic function. The point (x, t) is referred to as the initial state of the system.
A generic performance functional can be stated as P[α(·)]x,t= E
"
Z T t
r(X(s), α(s), s)ds
X(t) =x
#
, ∀α∈ A. (2.3)
where ris some given function that typically represents cash flow or the instanta- neous rate of change in some other desirable quantity that accumulates over the time horizon [0, T]. The requirements for a functionα:T →Rto be admissible is problem dependent, e.g.Acan depend on the initial state of the system.
In this work, we will consider the following stochastic optimal control problem;
For all initial states (x, t)∈Ω×[0, T], findα∗∈ A such that P[α∗(·)]x,t= sup
α∈A
P[α(·)]x,t, (2.4)
with Ω ⊂ Rn representing all possible values for x. The value function v : Ω× [0, T]→Ris as
v(x, t) = sup
α∈A
P[α∗(·)]x,t, ∀(x, t)∈Ω×[0, T]. (2.5) Under certain assumptions, one can show viadynamic programming that the value function satisfies the Hamilton Jacobi Bellman equation, which will be introduced in the next section.
2.2 Dynamic Programming Principle and the Hamilton Jacobi Bellman Equation
Bellman’s principle of optimality, also referred to as the dynamic programming principle, see [2, p. 83], is stated as
Dynamic Programming Principle. An optimal policy has the property that whatever the initial state and initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision.
With respect to the optimal control problem (2.4) defined in the previous sec- tion, the dynamic programming principle can be formulated mathematically as
v(x, t) = sup
α∈A
E
"
Z t+δt t
(r(X(s), α(s), s) +v(Xα(t+δt), t+δt))ds
#
, (2.6)
where Xα(t+δt) represents the state of the system X at time t+δt and the subscript α indicates that we have applied the control α(·) in the time interval [t, t+δt].
It can be shown that the value functionvsatisfies the Hamilton Jacobi Bellman equation, stated as
−∂v
∂t(x, t)−sup
a∈A
[Lav(x, t) +r(x, a, t)] = 0, (2.7) whereLa is an operator including partial derivatives up to second order depending on the control parametera∈A. Equation (2.7) is derived from problem (2.4) using the dynamic programming principle (2.6) and assuming that the value function is sufficiently smooth [9]. We shall heuristically derive an instance of the Hamilton Jacobi Equation in section 2.3 relating to the optimal control of a natural gas storage facility.
2.3 Derivation of the Natural Gas Storage Model
We derive the Hamilton Bellman Jacobi equation for the valuation and optimal operation of a gas storage facility, following Thompson et al. [14]. Similar models can also be derived for the valuation and optimal operation of a hydro electrical power plant [8], [5].
For the purposes of this model we think of a natural gas storage facility as being essentially a storage unit from which gas can be injected and withdrawn at any time. In order to maximize profits the operators of the facility wish to, roughly speaking, sell gas when the price is high and buy gas when the price is low. We introduce the following variables
• X - the price per unit of gas,
• Y - the amount of working gas in storage.
It is assumed that the facility can only be operated within a finite time horizon.
We lett denote the present time and we letT denote the end of the time horizon.
For any time s ∈[t, T], the price of unit gas and the amount of gas in storage is expressed as X(s) andY(s), respectively.
The policy chosen by the operators of the facility is represented by a control function α: [t, T] →R. That is, for each times ∈[t, T] the value of the control functionα(s) represents the volume rate of gas being sold. We use the convention that ifα >0, then gas is withdrawn from the facility and sold. On the other hand ifα <0, then gas is being bought and injected into storage. For a control function α(·) to beadmissible we require that
amin(Y(s))≤α(s)≤amax(Y(s)), ∀s∈[t, T],
whereaminandamaxare known functions ofY representing the maximal injection rate and the maximal withdrawal rate respectively. In the following we let
A(y) ={a∈R:amin(y)≤a≤amax(y)}, ,
and we let A(y) represent the collection of all admissible control functions given the initial level of gasY(t) =y.
We assume that there is a leakage of gas represented by a deterministic function λ, perhaps dependent on the control policy α and the amount of gas in storage.
The flow of gas out from storage, represented by the functionf, is given by f(Y(s), α(s), s) =λ(Y(s), α(s), s) +α(s) (2.8) We are using the sign convention that iff >0 then gas is flowing out from storage and if f <0 then gas is flowing into storage. Consequently, the rate of change in the amount of gas in storage is given by dYds =−f. Lety represent the amount of working gas presently in storage at timet. ThenY satisfies the following ODE, (in infinitesimal form) :
dY(s) =−f(Y(s), α(s), s)ds t < s < T
Y(t) =y. (2.9)
The price per unit of gasX is assumed to be a stochastic process satisfying an SDE of the form
dX(s) =µ(X(s), s)ds+σ(X(s), s)dW(s), t < s < T
X(t) =x, (2.10)
where W represents aWiener process.
DEFINITION. A real valued stochastic processW(t)is called a Wiener process, or Brownian motion, if
1. W(0) = 0
2. each sample path is continuous
3. W(t)isN(0, t), (W is normally distributed with mean 0 and variancet) 4. W has independent increments
Therevenueof the gas storage facility is defined as the present value of the sum of allcash flow over the whole contract period. The cash flow, denotedr, is equal to the value of the gas currently being bought or sold minus the value of the gas currently being lost, that is
r(X(s), Y(s), α(s), s) = α(s)−λ(Y(s), α(s), s)
X(s), ∀s∈[t, T]. (2.11) Thepresent value of this cash flow is assumed to be given by
e−ρ(s−t)(α(s)−λ(Y(s), α(s), s))X(s),
where ρ denotes therisk free interest rate [6, p. 115]. Consequently, the present value of the the sum of all cash flow over the whole contract period is equal to
Z T t
e−ρ(s−t)r(X(s), Y(s), α(s), s)ds.
The performance functional is given as P[α(·)]x,y,t= E
"
Z T t
e−ρ(s−t)r(X(s), Y(s), α(s), s)ds
X(t) =x, Y(t) =y
# ,
∀α∈ A(y), (2.12) which associates with each admissible control α ∈ A(y) an expected revenue P[α]x,y,t, given the initial stateX(t) =x, Y(t) =y.
Remark 2.1. Note that with respect to generic performance functional (2.3), the performance functional given by the previous equation has an extra discount factor e−ρ(s−t).
We are interested in the following stochastic control problem for each initial state (x, y, t):
findα∈ A(y): P[α∗(·)]x,y,t= sup
α∈A(y)
P[α(·)]x,y,t. (2.13) Recall that the value function is given as
v(x, y, t) = sup
α∈A(y)
P[α(·)]x,y,t, ∀(x, y, t)∈Ω×[0, T]. (2.14) We will now proceed to derive heuristically a partial differential equation for the value function v, following [9, p. 43], specifically we obtain the Hamilton Jacobi Bellman equation (2.7). We will be needing the following well known result from the theory of stochastic differential equations, as given in [6, p. 78].
ITO’S FORMULA. Let X= (X1, X2, . . . , Xn)represent an n-dimensional stochastic process such that
dXi=µi(X(s), s)ds+
n
X
j=1
Gij(X(s), s)dWj fori= 1, . . . , n.
with µi(X(s), s)∈L1(0, T)andGij(X(s), s)∈L2(0, T).
Ifu:Rn×[0, T]→R is continuous and the partial derivatives ∂u∂t,∂x∂u
i,∂x∂2u
i∂xj, (i, j= 1, . . . , n) exist and are continuous, then
d(u(X1, . . . , Xn, s)) = ∂u
∂tds+
n
X
i=1
∂u
∂xidXi+1 2
n
X
i,j=1
∂2u
∂xi∂xj
n
X
l=1
GilGjlds.
Suppose that that the operators of the gas storage facility applies the constant control policy α≡a∈ A(y) within the time interval [t, t+δt]. According to the
dynamic programming principle (2.6), the value function satisfies the inequality v(x, y, t)≥E
"
Z t+δt t
e−ρ(s−t)r(X, Y, a, s)ds+ e−δtv(X(t+δt), Y(t+δt), t+δt) ds
# . (2.15) Provided that the value functionv is a sufficiently smooth function ofx, y andt, Ito’s formula implies that
dv(X(s), Y(s), s) = ∂v
∂t +µ∂v
∂x + 1 2σ2∂2v
∂x2 −f ∂v
∂y
ds+σ∂v
∂xdW(s). (2.16) Remark 2.2. For notational convenience we have omitted to write out that the partial derivatives ∂v∂t,∂v∂x,∂∂x2v2, ∂v∂y appearing on the right hand side of the last equa- tion are evaluated at the point (X(s), Y(s), s), the functions µ,σ are evaluated at (X(s), s)andf is evaluated at(X(s), Y(s), a, s).
Inequality (2.15) can be rearranged as 0≥E
"
Z t+δt t
e−ρ(s−t)r ds+ e−ρδtδv−(1−e−ρδt)v
#
. (2.17)
with
δv:=v(X(t+δt), Y(t+δt), t+δt)−v(x, y, t).
From equation (2.16) we obtain δv=
Z t+δt t
dv= Z t+δt
t
∂v
∂t +µ∂v
∂x +1 2σ2∂2v
∂x2−f∂v
∂y
ds+ Z t+δt
t
σ∂v
∂xdW(s).
By substituting the expression for δv given by the previous equation into (2.17) and using that
E
"
Z t+δt t
σ∂v
∂xdW(s)
#
= 0, we obtain
0≥E Z t+δt
t
e−ρ(s−t)r ds + e−ρδt
Z t+δt t
∂v
∂t +µ∂v
∂x+1 2σ2∂2v
∂x2 −f∂v
∂y
ds−(1−e−ρδt)v
. Divide the previous inequality byδtand take the limit asδtgoes to zero. Assuming that lim
δt→0and E[·] are interchangeable, we get 0≥E
δt→0lim 1 δt
Z t+δt t
e−ρ(s−t)r ds + e−ρδt
Z t+δt t
∂v
∂t +µ∂v
∂x +1 2σ2∂2v
∂x2 −f∂v
∂y
ds−(1−e−ρδt)v
.
Via the mean-value theorem, the previous equation implies that 0≥
∂v
∂t +1 2σ2∂2v
∂x2 +µ∂v
∂x +ρv
(x, y, t) +r(x, y, a, t)−f(y, a, s)∂v
∂y(x, y, t).
(2.18) To obtain the last inequality we have also used the identity
lim
δt→0
1
δt(1−e−ρδt) =ρ.
Since (2.18) is true for any admissible a∈A(y), we have 0≥
∂v
∂t +1 2σ2∂2v
∂x2 +µ∂v
∂x −ρv
(x, y, t) + sup
a∈A(y)
r−f∂v
∂y
(x, y, a, t). (2.19) On the other hand, if the operators of the gas storage facility applies the optimal policy α∗ within the interval [t, t+δt], it can be shown trough similar arguments that
0 = ∂v
∂t +1 2σ2∂2v
∂x2 +µ∂v
∂x −ρv
(x, y, t) +r(x, y, a∗, t)−f(y, a∗, t)∂v
∂y(x, y, t), (2.20) with
a∗:=α∗(t).
Inequality (2.19) and equation (2.20) together imply that vshould satisfy 0 =
∂v
∂t +1 2σ2∂2v
∂x2 +µ∂v
∂x−ρv
(x, y, t) + sup
a∈A(y)
r(x, y, a, t)−f(y, a, t)∂v
∂y(x, y, t)
.
The previous equation is formulated backwards in time, via the change of variable τ =T −t, we get
∂v
∂τ −1 2σ2∂2v
∂x2 −µ∂v
∂x+ρv
(x, y, τ)
= sup
a∈A(y)
r(x, y, a, τ)−f(y, a, τ)∂v
∂y(x, y, t)
. (2.21)
2.4 Important assumptions about the NGS model
2.4.1 Boundary
In reality there is no upper bound on the price variablex. However, in our numerical solution of (2.21) we can only consider a finite price range, so let xmax represent
the maximal allowed price. The gas inventory variable y has an upper bound, represented by ymax, equal to the maximum storage capacity. In this work we consider solving equation (2.21) on the domain [0, xmax]×[0, ymax]×[0, T] and we refer to
Ω = [0, xmax]×[0, ymax],
as thespatial domain. For convenience we assume through out this work that the coefficients of (2.21) are scaled such that the spatial domain is equal to the unit square, that is
xmax=ymax= 1.
The gas price process is assumed to be mean reverting. Let µ0 > 0 and let
¯
x∈(0,1). A simple example of a mean reverting stochastic process is stated dX(s) =µ0(X(s)−x)¯ ds+σ(X(s), s)dW(s),
which corresponds to setting
µ(X(s), s) =µ0(X(s)−x),¯
in equation (2.10). The process is called mean reverting because the gas price is constantly drawn to the mean reversion level ¯x∈(0,1) which corresponds to the long term average market price. When the price process is mean reverting, we have the following conditions on the boundariesx= 0 andx= 1
µ|x=0≥0,
µ|x=1≤0. (2.22)
For the gas inventory process it is safe to assume that gas can only be pumped into storage if the current level of gas is less than the maximum capacity. On the other hand, gas can only be pumped out of the facility if there is any gas left in inventory. This reasoning leads to the conditions
f|y=0≤0
f|y=1≥0, (2.23)
where we recall thatf represents the flow of gas out from storage, (2.8). Negative values forf corresponds to gas being pumped in to storage and positive values for f corresponds to gas being released.
In [14] and [19] it is argued without any real justification that
∂2v
∂x2 →0 as x→xmax. (2.24)
However, the boundary x = xmax := 1 is assumed to be “far away” from the realistic price range, so this condition might not have a big impact on the solution.
Condition (2.24) implies that the term σ2∂∂x2v2 in equation (2.21) goes to zero as
x→1. As suggested by [5] this can be implemented by replacing σ with ˆσsuch that
ˆ
σ(x) =σ(x), ifx∈[0,1−],
ˆ
σ(x) = 0, ifx∈[1−,1],
where represents some small number. We will simply assume that σ → 0 as x→xmax. It is also assumed that σ→0 asx→0. Consequently, equation (2.21) is nearly hyperbolic close to the boundaries x= 0 and x= 1, (because the term σ2∂∂x2v2 vanishes), and boundary conditions needs only be prescribed at the inflow part of the boundariesx= 0 andx= 1. However, condition (2.22) imply that the boundaries x= 0 and x= 1 are outflow boundaries. That is, the flow field given as
f = (µ,−f)>,
always points inwards to the domain. Hence, no boundary conditions are needed for equation (2.21) at x ∈ {0,1}. Because the diffusive term in (2.21) has no component in the y-direction and the boundaries y = 0 and y = 1 are outflow boundaries by condition (2.23), no boundary conditions are needed at y∈ {0,1}.
For simplicity we will apply the initial condition v(x, y,0) = 0, as suggested in [14]. Some alternative initial conditions are discussed in [19].
2.4.2 Bang-bang controls
The model can be split into two equations as follows a∗= arg sup
a∈A(y)
r(x, y, a∗, τ)−f(y, a∗, τ)∂v
∂y(x, y, t)
(2.25)
∂v
∂τ = 1
2σ2∂2v
∂x2 +µ∂v
∂x−ρv
(x, y, τ)−f(y, a∗, τ)∂v
∂y(x, y, t) +r(x, y, a∗, τ) (2.26) In [19] and [14] the chosen model for the gas leakageλis of the form
λ(a) =
0 ifa≥0 k ifa <0 . With this choice ofλ, we get
r(x, a) = (a−λ(a))x, f(a) = (a+λ(a)),
so the feedback controla∗can be found by solving two linear sub-problems, corre- sponding toa≥0 anda <0 respectively, given as
a∗1= arg sup
a∈A(y)
ax−a∂v
∂y(x, y, t)
, a≥0
a∗2= arg sup
a∈A(y)
(a−k)x−(a+k)∂v
∂y(x, y, t)
a <0
and then choose the best of these computed solutions:
a∗= arg sup{(a∗1−λ(a∗1))x−(a∗1+λ(a∗1)),(a∗2−λ(a∗2))x−(a∗2+λ(a∗2))}
Since both sub-problems are linear inait is easy to verify that the optimal control only takes on values from the finite set{amin(y),0, amax(y)}. Hence, the optimiza- tion problem is solved by simply comparing the possible values of the expression r(x, a)−f(a)∂v∂y fora∈ {amin(y),0, amax(y)}. That is,
a∗(x, y, τ) = arg sup
a∈{amin,0,amax}
((a−λ(a))x−(a+λ(a)).
The controls are said to be of bang-bang type.
Chapter 3
A Monotone Finite Difference Scheme
We present a first order semi implicit finite difference scheme for solving equation (2.21). In the spatial discretization we employ the standard first order upwinding technique, as described in [10, p. 284]. The time discretization is implicit in the price direction (x-direction) and explicit in the inventory direction (y-direction), leading to a linear CFL-condition.
Even if the following method is only first order accurate it has other desirable properties. The scheme is l∞-stable, consistent and monotone. As noted in [19], these properties ensures that the numerical scheme converges to theviscosity solu- tionof (2.21), which is the appropriate solution for stochastic control problems [9].
In addition, the finite difference method is generally easy to implement and vec- torization of the method in MATLAB is straight forward.
We refer to [16] for an upwind finite volume method for the Hamilton Jacobi Bellman equation.
3.1 Grid
Let (xi)Ii=1, (yj)Jj=1 and (τn)Nn=0, be sets ofgrid points such that
0 =x1< x1<· · ·< xI−1< xI =xmax:= 1, (3.1) 0 =y1< y1<· · ·< yJ−1< yJ=ymax:= 1, (3.2) and
0 =τ0< τ1<· · ·< τN−1< τN =T, (3.3) Fro simplicity, we assume that the grid points are uniformly spaced, that is
∆x=xi+1−xi, i= 1, . . . , I,
∆y=yj+1−yj, j= 1, . . . , J, and
∆τ=τn+1−τn, n= 0, . . . , N.
for some ∆x >0, ∆y >0 and ∆τ >0.
3.2 The upwinding technique
In order to introduce the upwind method, consider the following linear convection diffusion equation
−σ∂2v
∂x2 +b(x)∂v
∂x = 0. (3.4)
Let ˜v represent the numerical approximation ofv to be defined. According to the first order upwind method, the approximation ˜vxof the convective termvxis given by the following rule:
˜
vx= ˜v(x)−˜v(x−∆x)
∆x ,ifb >0,
˜
vx= ˜v(x+ ∆x)−v(x)˜
∆x ,ifb <0.
(3.5)
Let
vi:= ˜v(xi), fori= 1, . . . , I, define the operators (·)+ and (·)− such that
a+= max(a,0), a−= min(a,0), ∀a∈R, and let the difference operators D+x and D−x be given as
D+x˜v(x) = 1
∆x(˜v(x+ ∆x)−v(x)),˜ D−x˜v(x) = 1
∆x(˜v(x)−v(x˜ −∆x)).
By using the standard central difference approach to approximate the diffusive term in equation (3.4) and the upwind method, given by (3.5), to approximate the convective terms, we end up with the following numerical scheme:
−σD+x(D−xvi) +b(xi)+D−xvi+b(xi)−D+xvi= 0, i= 1. . . , I−1.
Remark 3.1. We observe that
D+x(D−xvi) = vi+1−2vi+vi−1
∆x2 .
3.3 Numerical scheme
In the previous section we introduced the upwind method for a one dimensional linear convection diffusion equation. We will now proceed to apply the method on equation (2.21), which we restate here for convenience:
∂v
∂τ −1 2σ2∂2v
∂x2−µ∂v
∂x +ρv
(x, y, τ) = sup
a∈A(y)
r(x, y, a, τ)−f(y, a, τ)∂v
∂y(x, y, t)
. (3.6) We assume, for simplicity, thatσandµonly depend onx. In what follows, we will use the notation
µi=µ(xi), σi=σ(xi), and
fjn+1(a) =f(yj, τn+1, a), rijn+1(a) =r(xi, yj, τn+1, a).
Let the difference operators D+y and D−y be defined such that
D+yv(x, y, τ) =v(x, y+ ∆y, τ)−v(x, y, τ), D−yv(x, y, τ) =v(x)−v(x, y−∆y, τ).
By following the same discretization procedure as in the previous section for each direction x,y andτ, we obtain from equation (3.6) the numerical scheme:
vn+1i,j −vi,jn
∆τ −σiD+x(D−xvn+1i,i )−µ+iD+xvi,jn+1−µ−i D−xvn+1i,j = max
a∈A(yj)
rnij(a)−fjn(a)+D−vi,jn −fjn(a)−D+yvi,jn , (3.7) fori= 0, . . . , I,j= 0, . . . , J andn= 0, . . . , N−1.
Remark 3.2. We have treated the convective term f∂v∂y and the term r(x, y, a, τ) in equation (3.6) explicitly, that is, in equation (3.7), these terms are evaluated at τ =τn instead of τ=τn+1.
Remark 3.3. As we will show in the next subsection, no boundary conditions are needed for (3.7), provided thatσ(0) =σ(1) = 0,µ(0)≥0,µ(1)≤0,f|y=0 ≤0and f|y=1≥0.
3.3.1 Boundary
At the boundaries x= 1 and x= 0, we apply the conditions
σ1= 0, σI = 0,
(recall section 2.4.1), and it is assumed that
µ1≥0, µI ≤0,
so for i= 1 andi=I, respectively, the scheme given by (3.7) reads vn+11,j −vn1,j
∆τ −µ+1D+xv1,jn+1= max
a∈A(yj) r1,jn (a)−fjn(a)+D−v1,jn −fjn(a)−D+yvn1,j , (3.8) and
vI,jn+1−vI,jn
∆τ −µ−0D−xvI,jn+1= max
a∈A(yj)
rI,jn (a)−fjn(a)+D−vI,jn −fjn(a)−D+yvnI,j . (3.9) At the boundaries y= 0 andy= 1, it is assumed that
f0n(a)≤0, fJn(a)≥0, so for j= 0 andj=J, the scheme (3.7) reads
vi,1n+1−vi,0n
∆τ −σiD+x(D−xvi,1n+1)−µ+i D+xvn+1i,1 −µ−i D−xvn+1i,1
= max
a∈A(yj) rni,1(a)−fjn(a)D+yvi,1n (3.10) and
vi,Jn+1−vni,J
∆τ −σiD+x(D−xvi,Jn+1)−µ+i D+xvn+1i,J −µ−i D−xvi,Jn+1
= max
a∈A(yj)
rni,J(a)−fjn(a)D−yvi,Jn (3.11)
3.4 Monotonicity
In this section we will show that, provided a linear CFL-condition (3.13), the numerical scheme (3.7) ismonotone. That is, ifuandvare solutions of (3.7), then v0≥u0 =⇒ vn≥un ∀n >0, (3.12) provided that
∆τkfk∞≤∆y. (3.13)
Remark 3.4. The inequalities in (3.12) are to be intended component vice.
The proof is by induction, suppose thatvn≥un and choosei∗, j∗ such that (i∗, j∗) = arg min
i,j (vi,jn+1−un+1i,j ). (3.14) The numerical scheme (3.7) can be rewritten as
vn+1i,j −∆τ(σiD+x(D−xvi) +µ+i D+xvi+µ−i D−xvi) =vi,jn + ˜H(vni,j), (3.15) with
H(v˜ ni,j) = max
a∈A(yj) rijn(a)−fjn(a)+D−vni,j−fjn(a)−D+yvi,jn .
By writing out all the terms in equation (3.15), we get vi,jn+1−∆τ σivi+1,jn+1 −2vi,jn+1+vn+1i−1,j
∆x2 +µ+i vi+1,jn+1 −vn+1i,j
∆x +µ−i vn+1i,j −vi−1,jn+1
∆x
!
=vi,jn + ˜H(vi,jn ), which can be rewritten as
vi,jn+1 ∆τ
∆x ∆x
∆τ +2σi
∆x+µ+i −µ−i
−vi+1,jn+1 ∆τ
∆x σi
∆x+µ+i
−vn+1i−1,j ∆τ
∆x σi
∆x−µ−i
=vni,j+ ˜H(vi,jn ).
(3.16) By rearranging the terms in the last equation, we get
vn+1i,j =c1 vi,jn +c2vi+1,jn+1 +c3vn+1i−1,j
+c1H(vni,j) (3.17) with
c1=
∆x
∆τ
∆x
∆τ +2σ∆xi +µ+i −µ−i , c2= ∆τ
∆x σi
∆x+µ+i
, c3=∆τ
∆x σi
∆x−µ−i , (3.18) and it can be easily checked that c1, c2 andc2 are non-negative. We observe that H(v˜ ni,j) can be written as
H(v˜ i,jn ) = max
rnij(a)− 1
∆y
vi,jn |fjn(a)|+vni,j−1fjn(a)+−vi,j+1n fjn(a)−
,
hence
H(v˜ ni,j)−H(u˜ ni,j)≥min
H(v˜ i,jn )−H(u˜ ni,j)
≥ 1
∆y min
−(vi,jn −uni,j)|fjn(a)|+ (vi,jn −uni,j−1)fjn(a)+
−(vi,j+1n −uni,j+1)fjn(a)−
. (3.19)
From the previous inequality and the fact that vn≥un, we get H(v˜ ni,j)−H(u˜ ni,j)≥ − 1
∆y(vni,j−uni,j)|fjn|∞, (3.20) with
|fjn|∞:= max
a (fjn(a)).
From equation (3.17) and inequality (3.20), it follows that
vi,jn+1−un+1i,j =c1 vi,jn −uni,j+c2(vn+1i+1,j−un+1i+1,j) +c3(vi−1,jn+1 −un+1i−1,j) +c1∆τ(H(vi,jn )−H(vi,jn ))
≥c1 vi,jn −uni,j+c2(vn+1i+1,j−un+1i+1,j) +c3(vi−1,jn+1 −un+1i−1,j)
−c1∆τ
∆y(vni,j−uni,j)kfjnk∞
=c1 c2(vi+1,jn+1 −un+1i+1,j) +c3(vn+1i−1,j−un+1i−1,j) +c1(vi,jn −uni,j)(1−∆τ
∆ykfjnk∞), so provided that
∆τkfjnk∞≤∆y, (3.21)
the following inequality holds
vi,jn+1−un+1i,j ≥c1c2(vi+1,jn+1 −un+1i+1,j) +c1c3(vi−1,jn+1 −un+1i−1,j).
The previous inequality together with (3.14) implies that
vin+1∗,j∗−un+1i∗,j∗ ≥c1c2(vn+1i∗,j∗−un+1i∗,j∗) +c1c3(vin+1∗,j∗−un+1i∗,j∗), which can be rearranged into
(1−c1(c2+c3))vn+1i∗,j∗ ≥(1−c1(c2+c3))un+1i∗,j∗. From the definition of c1, c2 andc3, given by (3.18), it follows that
(1−c1(c2+c3))>0, this concludes the proof.
3.5 Stability
Let v represent a solution of (3.7). Provided that the CFL-condition (3.13) is satisfied, there existsC >0, independent of ∆x,∆y and ∆τ, such that
kvnk∞≤C kv0k∞+krk∞
, ∀n >0. (3.22)
The proof is by induction. Let (i, j) = arg max
i,j (vni,j), equation (3.16) implies that
vn+1i,j ≤vni,j+ ∆τH(v˜ ni,j).
By writing out the term ˜H(vni,j) in the last inequality, we get vn+1i,j ≤vni,j+ ∆τmax
a
rnij(a)− 1
∆y
vi,jn |fjn(a)|+vni,j−1fjn(a)+−vi,j+1n fjn(a)−
=vni,j+ ∆τ rijn(a∗)−∆τ
∆y
vi,jn |fjn(a∗)|+vi,j−1n fjn(a∗)+−vni,j+1fjn(a∗)−
=vni,j(1−∆τ
∆y|fjn(a∗)|) + ∆τ vni,j−1fjn(a∗)+−vni,j+1fjn(a∗)−
+ ∆τ rijn(a∗).
(3.23) Suppose that (3.13) is satisfied, since fjn(a∗)+ ≥0, −fjn(a∗)− ≥ 0 and we have choseni, j such thatvi,jn+1= max
i,j vn+1i,j , inequality (3.23) implies that max
i,j (vn+1i,j )≤∆τ
kfnk∞max
i,j (vi,jn ) +krnk∞
.
By choosing (i, j) = arg min
i,j (vi,jn ) it follows by similar arguments that min
i,j (vn+1i,j )≥∆τ
kfnk∞min
i,j (vi,jn ) +krnk∞
.
The last two inequalities together implies that
kvn+1k∞≤∆τ(kfnk∞|vn|∞+krnk∞)
≤∆y|vn|∞+ ∆τkrnk∞,
where we have used (3.13) to obtain the last inequality. From the last inequality it follows that
kvn+1k∞≤∆y(∆ykvn−1k∞+ ∆τkrn−1k∞) + ∆τkτnk∞
= ∆y2kvn−1k∞+ ∆y∆τkrn−1k∞+ ∆τkrnk∞
≤∆yk+1kv0k∞+
n
X
k=0
∆yk∆τkrn−kk, since ∆y≤ymax:= 1, the last inequality implies that
kvn+1k∞≤C kv0k∞+krk∞ , withC= max(T,1). This concludes the proof.
3.6 Consistency
We prove that the scheme given by (3.7) is consistent, provided that the exact solution of (3.6), denotedv(x, y, τ), is sufficiently smooth.
Suppose thatv is second order differentiable inx, first order differentiable iny andτ, then Taylor’s theorem implies that
∂v
∂τ(xi, yj, τn) = vi,jn −vn−1i,j
∆τ +O(∆τ), ∂2v
∂x2(xi, yj, τn) = D+x(D−xvi,jn ) +O(∆x2),
∂v
∂x(xi, yj, τn) = D−xvni,j+O(∆x), ∂v
∂x(xi, yj, τn) = D+xvi,jn +O(∆x),
∂v
∂y(xi, yj, τn) = D+yvni,j+O(∆y), ∂v
∂y(xi, yj, τn) = D−yvi,jn +O(∆y).
(3.24) Let the functional H(·) be defined such that
H(v)(x, y, τ) = sup
a∈A(y)
r(x, y, a, τ)−f(y, a, τ)∂v
∂y(x, y, t)
.
Becausev satisfies the equation ∂v
∂τ −1 2σ2∂2v
∂x2 −µ∂v
∂x+ρv
(x, y, τ)−H(v)(x, y, τ) = 0,
there holds Z τn+1
τn
∂v
∂τ −1 2σ2∂2v
∂x2 −µ∂v
∂x +ρv
(x, y, τ)dτ− Z τn+1
τn
H(v)(x, y, τ)dτ = 0.
By approximating the two integrals in the last equation with the right end point rule and the left endpoint rule, respectively, we get
v(x, y, τn+1)−v(x, y, τn+1)−∆τ 1
2σ2∂2v
∂x2+µ∂v
∂x −ρv
(x, y, τn+1)
−∆τH(v)(x, y, τn) =O(∆τ2), which can be rewritten as
v(x, y, τn+1)−v(x, y, τn+1)
∆τ −
1 2σ2∂2v
∂x2 +µ∂v
∂x−ρv
(x, y, τn+1)
−H(v)(x, y, τn) =O(∆τ).
From the previous equation and (3.24), it follows that en+1i,j :=
v(xi, yj, τn+1)−v(xi, yj, τn+1)
∆τ −
1 2σ2∂2v
∂x2 +µ∂v
∂x−ρv
(xi, yj, τn+1)
−H(v)(xi, yj, τn)
−
vi,jn+1−vni,j
∆τ −σiD+x(D−xvi,in+1)−µ+i D+xvn+1i,j
−µ−i D−xvn+1i,j −H(v˜ ni,j)
= ˜H(vi,jn )−H(v)(xi, yj, τn) +O(∆x+ ∆τ).
We have
H(v˜ ni,j)−H(v)(xi, yj, τn) ≤max
a∈Aj
H(v˜ ni,j)−H(v)(xi, yj, τn)H
≤max
a∈Aj
−fjn(a)+D−vi,jn −fjn(a)−D+vni,j +fjn(a)∂v
∂y(xi, yj, τn)
= max
a∈Aj
|fjn(a)|O(∆y)
=O(∆y).
This concludes the proof.
3.7 Implementation
The numerical scheme given by (3.7) can be rewritten in matrix form as follows 1
∆τ(vn+1−vn) + Avn+1=rn+ Cnvn, n= 0, . . . , N−1, (3.25) where v0 is a given initial solution. Before we define the vectorsvn+1,vn and rn and the matrices A and Cn, appearing in the last equation, let
m=I·J, and define the functionξ(x, y, τ), such that
ξi,jn = arg sup rijn(a)−fjn(a)+D−vni,j−fjn(a)−D+yvi,jn
. (3.26)
In equation (3.25) we have introduced the solution vector vn ∈ Rm, for n = 0, . . . , N, given as
vn= (v1,1n , . . . vI,1n , v1,2n , . . . vI,2n , . . . , v1,Jn . . . vnI,J)>, the vectorrn∈Rm, forn= 0, . . . , N, given as
rn= (r∗,n1,1, . . . rI,1∗,n, r∗,n1,2, . . . rI,2∗,n, . . . , r∗,n1,J. . . r∗,nI,J)>, r∗,ni,j =r(xi, yj, ξi,jn , τn),