Lecture 9: Linear Programming and ALM: Cash-Flow Matching

Topics

  • I. Linear Programming Theory

    • Formulation
    • Duality
    • Solution Methods
      • Simplex Method
      • Primal-Dual Interior-Point Method
  • II. Asset Liability Manamgement: Cash-Flow Matching

    • Basic setup
    • Example
    • Nonlinear scenario
    • Stochastic liabilities

I. Linear Programming Theory

Formulation

\begin{aligned} \renewcommand{bx}{\boldsymbol x} \renewcommand{bs}{\boldsymbol} \min_{\bx \in \mathbb{R}^n } \;\; &z = \bs{c}^T \bx \\ s.t. \;\;\bs{A}\bx &\geq \bs{b};\; x_j \geq 0, \;\forall j \end{aligned}

  • Simpler than any other optimization problem

  • With plenty of application (even in Finance)

  • Serve as a good starting point

Duality

Primal (P)

\begin{aligned} \min_{\bx \in \mathbb{R}^n } \;\; &z = \bs{c}^T \bx \\ s.t. \;\;\bs{A}\bx \geq \bs{b};\; & x_j \geq 0, \;\forall j = \overline{1, n} \end{aligned}

Dual (D)

\begin{aligned} \max_{\bs{y} \in \mathbb{R}^m } \;\; & z = \bs{b}^T \bs{y} \\ s.t. \;\;\bs{A}^T\bs{y} \leq \bs{c}; \;\; & y_k \geq 0, \;\; \forall k = \overline{1, m} \end{aligned}

Derivation

Lagrangian:

$$ \renewcommand{ml}{\mathbb{\mathcal L}} \renewcommand{bA}{\boldsymbol A} \renewcommand{by}{\boldsymbol y} \renewcommand{bb}{\boldsymbol b} \renewcommand{bc}{\boldsymbol c} \renewcommand{bw}{\boldsymbol w} \begin{array} \\ \ml(\bx, \by, \bw) & = & \bc^T \bx + \by^T (\bb-\bA\bx) - \bw^T\bx \\ & = & \by^T\bb + (\bc^T - \by^T \bA - \bw^T)\bx \\ & & \mbox{with} \;\; \by \geq \bf{0}, \;\;\; \bw \geq \bf{0} \end{array} $$

Lagrangian dual function

$$ \renewcommand{mD}{\mathbb{\mathcal D}} \renewcommand{df}{\hat{f}} \df(\by, \bw) = \inf_{\bx\in \mD}\; \ml(\bx, \by, \bw) =\by^T\bb + \inf_{\bx\in\mD} (\bc^T - \by^T \bA - \bw^T)\bx $$

Obviously the last term is linear in $\bx$, so the only scenario where the infimum can be reached is when the slop is zero:

$$ \bc - \bA^T \by - \bw = 0 $$

write-off the slack variable $\bw$ will generate the dual problem (D).

Duality Theorem:

  • If $\bx$ is feasible for (P) and $\bs{y}$ is feasible for (D), then $\bs{c}^T \bx \geq \bs{b}^T \bs{y}$, and only at optimality the equality holds $\bs{c}^T \bx^* = \bs{b}^T \bs{y}^*$ .
  • The quantity: $\bs{c}^T \bx - \bs{b}^T \bs{y}$ is called duality gap. This value is used commonly as the stopping criteria for Interior LP method.

Solution Methods

  • Simplex (Dantzig 1947)

  • Ellipsoid (Kachian 1979, the first algorithm known to be in polynomial time)

  • Interior Point (Karmakar 1984, the first practical polynomial time algorithm)

    • Projection method (Karmakar 1984)
    • Affine Method (Dikin 1967)
    • Log-Barrier Method (many ...)
  • Interior Point method has been extended to NLP problems, has been the focus of research for optimization in the last few decades.

  • Although asymptotically superior, there is no clear winner between Simplex and Interior Point for LP problems: very much depends on the problem

Simplex Methods

  • Optimal points must be at the intersections of constraints:

Algorithm (Simplex Method)

  • Input \begin{aligned} \\ \min_{\bx \in \mathbb{R}^n } \;\; z & = \bs{c}^T \bx \\ s.t. \;\; \bx \in \mathcal{P} & = \{\bx: \bs{A}\bx \leq \bs{b}, \bx \geq 0 \} \end{aligned}
  • Look at the polytope $\mathcal{P}$ as a graph $\mathcal{G} = (V,E)$ with $V$ as vertices and $E$ as edges.
  • Algorithm
    1. Find any vertex $\bs{v}$ in $\mathcal{P}$;
    2. While $\exists $ a neighbor $\bs{u}$ of $\bs{v}$ in $\mathcal{G}$ with $\bs{c}^T \bs{u} < \bs{c}^T \bs{v}$, set $\bs{v} = \bs{u}$;
    3. Output $\bs{v}$

Primal-dual Interior-point Method

  • For convenience, reformulate the LP problme into an equivalent form

Primal (P)

\begin{aligned} \min_{\bx \in \mathbb{R}^n } \;\; & \bs{c}^T \bx \\ s.t. \;\; \bs{A}\bx &= \bs{b}, \;\; \bx \geq \bf{0} \end{aligned}

Dual (D) \begin{aligned} \max_{\bs{y} \in \mathbb{R}^m } \;\; & \bs{b}^T \bs{y} \\ s.t. \;\; \bs{A}^T\bs{y} + \bs{s} & = \bs{c}, \;\; \bs{s} \geq \bf{0} \end{aligned}

  • And the optimality (KKT) conditions are

\begin{aligned} \bs{A}^T\bs{y} + \bs{s} &= \bs{c}, \\ \bs{A}\bx &= \bs{b}, \\ \bx\circ \bs{s} &= \bf{0}, \\ \bx \geq \bf{0}, \;\; \bs{s} &\geq \bf{0} \end{aligned}

The third complementary slackness condition relates to the duality gap.

Primal-dual interior-point methods find primal-dual solutions $(\bx^*, \by^*, \bs{s}^*)$ by applying variants of Newton's method to the first three KKT conditions above, and modifying search directions and step lengths, so that the last KKT condition is strictly satisfied at each iteration.

Rewrite the KKT conditions as: $$ \begin{matrix} \bs{F}(\bx,\by,\bs{s}) = \left[ \begin{matrix} \bs{A}^T\bs{y} + \bs{s} - \bs{c} \\ \bs{A}\bx - \bs{b} \\ \bs{X} \bs{S} \bs{e} \end{matrix} \right] = \bs{0} \end{matrix} $$

where $\bs{X}, \bs{S}$ are diagonal matrices, and $\bs{e}$ is the vector with all elements equal to 1.

And the search direction is generated by solving,

$$ \begin{matrix} \bs{F}'(\bx,\by,\bs{s}) \left[ \begin{matrix} \delta\bx \\ \delta\by \\ \delta\bs{s} \end{matrix} \right] = \bs{F}(\bx,\by,\bs{s}) \end{matrix} $$

Looking for iterates that are strictly feasible, this becomes

$$ \begin{matrix} \left[ \begin{matrix} 0 & \bs{A}^T & \bs{I} \\ \bs{A}^T & 0 & 0 \\ \bs{S} & 0 & \bs{X} \end{matrix} \right] \left[ \begin{matrix} \delta\bx \\ \delta\by \\ \delta\bs{s} \end{matrix} \right] = \left[ \begin{matrix} \bs{0} \\ \bs{0} \\ -\bs{X} \bs{S} \bs{e} \end{matrix} \right] \end{matrix} $$

In Interior-point method, the critical concept is the central path: instead of the third KKT condition, the path of iterative points satisfies,

$$ x_i s_i = \tau\gamma, \;\;\; i=1,2,\cdots, n $$

where $\tau\in [0,1] $ is the centering parameter and $\gamma = \frac{\bs{s}^T\bx}{n}$ is the duality gap parameter.

With this, the equation for search direction becomes

$$ \begin{matrix} \left[ \begin{matrix} 0 & \bs{A}^T & \bs{I} \\ \bs{A}^T & 0 & 0 \\ \bs{S} & 0 & \bs{X} \end{matrix} \right] \left[ \begin{matrix} \delta\bx \\ \delta\by \\ \delta\bs{s} \end{matrix} \right] = \left[ \begin{matrix} \bs{0} \\ \bs{0} \\ -\bs{X} \bs{S} \bs{e} + \tau\gamma \bs{e} \end{matrix} \right] \hspace{2in} (*) \end{matrix} $$

Algorithm (Primal-dual Interior-point method)

  1. Determine $(\bx^0, \by^0, \bs{s}^0)$ strictly feasible
  2. Set k = 0
  3. Do
    1. Set $\tau^k\in [0,1]$ and $\gamma^k = \frac{\bs{s}^T\bx}{n}$
    2. Solve (*) for $(\delta\bx^k, \delta\by^k, \delta\bs{s}^k)$
    3. Set $(\bx^{k+1}, \by^{k+1}, \bs{s}^{k+1}) = (\bx^k, \by^k, \bs{s}^k) + \alpha^k(\delta\bx^k, \delta\by^k, \delta\bs{s}^k)$ choosing $\alpha^k$ so that $(\bx^{k+1}, \bs{s}^{k+1}) \geq 0 $
    4. k = k + 1
  4. While $\gamma^k > \epsilon$
  • Software packages for LP
    • Most optimization packages will have the LP solver implemented, and most likely include both the Simplex and Interior method.
    • Scipy just released the first LP solver (in Simplex): Scipy version 0.15.1 (with Numpy version: 1.9.2)
    • Here is the code applying the Scipy LP optimizer to the example in the geometric view slide:
In [1]:
import numpy as np
from scipy.optimize import linprog

c = np.array([-2, -3])
A = [[1, -2], [2, 1], [0, 1]]
b = np.array([4,18,10])
res = linprog(c, A, b,
                options={ 'disp': True})

print("The solution from Scipy Simplex method:", res.x)
import scipy
print("The Scipy version:")
print(scipy.__version__)
print("The Numpy version:")
print(np.__version__)
Optimization terminated successfully.
         Current function value: -38.000000  
         Iterations: 2
The solution from Scipy Simplex method: [ 4. 10.]
The Scipy version:
1.1.0
The Numpy version:
1.14.3

II. Asset Liability Management: Cash-FLow Matching

  • Asset Liability Management (ALM) is the practice of managing a business so that decisions and actions taken with respect to assets and liabilities are coordinated. It's the sound manamegment of the finances to match the asset cash flows with its future liability cash flow needs and capital requirements.

  • ALM practice now considers a wide range of risks: liquidity, interest rate, equity, currency, legal, etc.

We will be considering the interest rate risk part of the ALM.

  • ALM usually takes the form of "immunization": matching the present value, duration and convexity of the liabilities and assets in the portfolio. This is typically done at each time bucket of the planning horizon.

  • Here, we will focus on the form of "dedication": choose an investment asset portfolio such that, for each period of the planning horizon, the investment cash flow will be sufficient to meet the projected liability cash flows.

Basic Setup for "Dedication"

Given:

  • $t_k, \;\; k = 1,\cdots, K $ are the time periods
  • $L_k, \;\; k = 1,\cdots, K $ are the future liability payment at time $t_k$

  • $P_j, \;\; j = 1,\cdots, N $ are the prices of $N$ investable assets

  • $C_{j, k}, \;\; j = 1,\cdots, N, \;\; k= 1, \cdots, K $ are the cash flows of asset $j$ at time period $t_k$

Assuming:

  • $x_j, \;\; j = 1,\cdots, N $ are the amount to be invested in asset $j$

The problem is to find the asset portfolio such that the total cost

$$ \sum_j x_j P_j $$

is minimized, while the projected liability cash flows are covered by the cash flows generated by the asset portfolio

$$ \sum_j x_j C_{j,k} \geq L_k \;\; k = 1,\cdots,K $$

and $x_j \geq 0$.

Example

  • A pension fund has estimated that for the next 8 years it has the following schedule of benefits to be paid (in $millions ):
Years 1 2 3 4 5 6 7 8
Benefits($millions) 12 18 20 20 16 15 18 20
  • The fund's investment advisors recommended the following set of bonds to invest:
Bonds 1 2 3 4 5 6 7 8 9 10
Price 102 99 101 98 98 104 100 101 102 94
Coupon(%) 5 6.5 5 3.5 4 9 6 8 9 7
Maturity(Years) 1 2 2 3 4 5 5 6 7 8
  • The bonds all have face values $\$100$, the coupons are annualized percentage.

  • Can you help find the least cost portfolio of bonds so that the pension fund can meet its future benefit payments?

LP formulation set up:

  • $L_k, k = 1,\cdots, 8 $ are the future benefits (liabilities) payment at year $k$
  • $P_i, i = 1,\cdots, 10 $ are the prices of bond $i$
  • $C_i, i = 1,\cdots, 10 $ are the coupons of bond $i$
  • $M_i, i = 1,\cdots, 10 $ are the maturity of bond $i$
  • We will assume the variables are:
    • $x_i, i = 1,\cdots, 10 $ are the amount of bond $i$ to be purchased
    • $s_k, k = 1,\cdots, 8 $ are the free cash at the end of year $k$

The LP problem can be formulated as:

$$ \min_{\bx} \left( \sum_i x_i P_i \right) $$

$$ \begin{aligned} \mbox{s.t.} & \sum_{i=1,\cdots,10} ({\bf 1}_{M_i\geq k}\cdot C_i(t) + {\bf 1}_{M_i=k}\cdot 100)\; x_i - s_k + s_{k-1}= L_k, \;\; k = 1,2,\cdots, 8 \\ & x_i \geq 0 \;\; i = 1,2,\cdots, 10; \;\;\; s_k \geq 0 \;\; k = 1,2,\cdots, 8 \end{aligned} $$

where we assume $s_0 = 0$.

In [2]:
p = np.array([102, 99, 101, 98, 98, 104, 100, 101, 102, 94, 0, 0, 0, 0, 0, 0, 0, 0])
b = np.array([12, 18, 20, 20, 16, 15, 18, 20])
A = [[100+5, 6.5, 5, 3.5, 4, 9, 6, 8, 9, 7, -1.0, 0, 0, 0, 0, 0, 0, 0], 
     [0, 100+6.5, 100+5, 3.5, 4, 9, 6, 8, 9, 7, 1.0, -1.0, 0, 0, 0, 0, 0, 0],  
     [0, 0, 0, 100+3.5, 4, 9, 6, 8, 9, 7, 0, 1.0, -1.0, 0, 0, 0, 0, 0],  
     [0, 0, 0, 0, 100+4, 9, 6, 8, 9, 7, 0, 0, 1.0, -1.0, 0, 0, 0, 0],  
     [0, 0, 0, 0, 0, 100+9, 100+6, 8, 9, 7, 0, 0, 0, 1.0, -1.0, 0, 0, 0],  
     [0, 0, 0, 0, 0, 0, 0, 100+8, 9, 7, 0, 0, 0, 0, 1.0, -1.0, 0, 0],  
     [0, 0, 0, 0, 0, 0, 0, 0, 100+9, 7, 0, 0, 0, 0, 0, 1.0, -1.0, 0],  
     [0, 0, 0, 0, 0, 0, 0, 0, 0, 100+7, 0, 0, 0, 0, 0, 0, 1.0, -1.0] ]

res = linprog(p, A_eq=A, b_eq=b,
                options={ 'disp': True})

print("The solution from Scipy Simplex method:\n", res.x)
Optimization terminated successfully.
         Current function value: 101.615025  
         Iterations: 9
The solution from Scipy Simplex method:
 [ 0.04860098  0.2588899   0.          0.          0.14785887  0.11377323
  0.          0.11401282  0.15313384  0.18691589  0.         14.78588715
  0.          0.          0.          0.          0.          0.        ]

Extensions of the Asset liability cash flow matching problem

The constraint condition can be turned into equality based by assuming the surplus free cash flow at each time period and consider them to be variables

  • $s_k, \;\; k = 1,\cdots, K $ are the amount of excess cash after paying the liability

With that, the constraints are now

$$ \sum_j x_j C_{j,k} - s_k = L_k, \;\; k = 1,\cdots,K $$ and $x_j \geq 0, \;\; s_k \geq 0$.

  • With these excess cash flows, it is then natural to assume that they will be re-invested, and the return is simply $r$, therefore the constraints becomes

$$ \sum_j x_j C_{j,k} - s_k + r * s_{k-1} = L_k, \;\; k = 1,\cdots,K $$ where we set $s_0 = 0$.

  • The setup can be made even more realistic by allowing the reinvestment return to be time period dependent: $r \rightarrow r_k$

  • In fact, if borrowing is allowed, the constraints $ s_k \geq 0$ for all time periods are unnecessary, except we probably want to keep the excess cash to be positive at the very last time period.

  • Which introduces another dimension: the borrowing rate and lending (re-investment) rate are typically different in real life.

  • In practice, these assumtions (or approximations) can certainly make a big difference in terms of the complexity and realistism of your model.

Undeterministic future liabilities and asset returns

  • Cash flow matching so far require the cash flows from the liabilities can be forcasted deterministcally

  • This is hardly the case: liabilites of Insurance companies are not fixed:

    • Policyholders can withdraw cash
    • Hurricane frequency and severity are highly unpridictable
    • Pension payments are hardly deterministic