{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "slideshow": { "slide_type": "skip" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Populating the interactive namespace from numpy and matplotlib\n" ] } ], "source": [ "%pylab inline\n", "lecture = 9" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "#Lecture 9: Linear Programming and ALM: Cash-Flow Matching\n", "\n", "## Topics\n", "* I. Linear Programming Theory\n", "\n", " * Formulation\n", " * Duality\n", " * Solution Methods\n", " * Simplex Method\n", " * Primal-Dual Interior-Point Method " ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "fragment" } }, "source": [ "* II. Asset Liability Management: Cash-Flow Matching\n", "\n", " * Basic setup\n", " * Example\n", " * Nonlinear scenario\n", " * Stochastic liabilities\n", " \n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# I. Linear Programming Theory\n", "\n", "\n", "## Formulation\n", "\n", "\\begin{aligned}\n", "\\renewcommand{bx}{\\boldsymbol x}\n", "\\renewcommand{bs}{\\boldsymbol}\n", "\\min_{\\bx \\in \\mathbb{R}^n } \\;\\; &z = \\bs{c}^T \\bx\n", "\\\\\n", "s.t. \\;\\;\\bs{A}\\bx &\\geq \\bs{b};\\;\n", "x_j \\geq 0, \\;\\forall j\n", "\\end{aligned}\n", "\n", "\n", "* Simpler than any other optimization problem\n", "\n", "* With plenty of application (even in Finance)\n", "\n", "* Serve as a good starting point\n", "\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Duality\n", "\n", "Primal (P)\n", "\n", "\\begin{aligned}\n", "\\min_{\\bx \\in \\mathbb{R}^n } \\;\\; &z = \\bs{c}^T \\bx\n", "\\\\\n", "s.t. \\;\\;\\bs{A}\\bx \\geq \\bs{b};\\;\n", "& x_j \\geq 0, \\;\\forall j = \\overline{1, n}\n", "\\end{aligned}\n", "\n", "\n", "\n", "Dual (D)\n", "\n", "\\begin{aligned}\n", "\\max_{\\bs{y} \\in \\mathbb{R}^m } \\;\\; & z = \\bs{b}^T \\bs{y}\n", "\\\\\n", "s.t. \\;\\;\\bs{A}^T\\bs{y} \\leq \\bs{c}; \\;\\;\n", "& y_k \\geq 0, \\;\\; \\forall k = \\overline{1, m}\n", "\\end{aligned}\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Derivation\n", "\n", "Lagrangian:\n", "\n", "$$\n", "\\renewcommand{ml}{\\mathbb{\\mathcal L}}\n", "\\renewcommand{bA}{\\boldsymbol A}\n", "\\renewcommand{by}{\\boldsymbol y}\n", "\\renewcommand{bb}{\\boldsymbol b}\n", "\\renewcommand{bc}{\\boldsymbol c}\n", "\\renewcommand{bw}{\\boldsymbol w}\n", "\\begin{array}\n", "\\\\\n", "\\ml(\\bx, \\by, \\bw) & = & \\bc^T \\bx + \\by^T (\\bb-\\bA\\bx) - \\bw^T\\bx\n", "\\\\\n", "& = & \\by^T\\bb + (\\bc^T - \\by^T \\bA - \\bw^T)\\bx\n", "\\\\\n", "& & \\mbox{with} \\;\\; \\by \\geq \\bf{0}, \\;\\;\\; \\bw \\geq \\bf{0}\n", "\\end{array}\n", "$$\n", "\n", "Lagrangian dual function\n", "\n", "$$\n", "\\renewcommand{mD}{\\mathbb{\\mathcal D}}\n", "\\renewcommand{df}{\\hat{f}}\n", "\\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\n", "$$\n", "\n", "Obviously the last term is linear in $\\bx$, so the only scenario where the infimum can be reached is when the slop is zero:\n", "\n", "$$\n", "\\bc - \\bA^T \\by - \\bw = 0\n", "$$\n", "\n", "write-off the slack variable $\\bw$ will generate the dual problem (D).\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "### Duality Theorem:\n", "\n", " * If $\\bx$ is feasible for (P) and $\\bs{y}$ is feasible for (D), then $\\bs{c}^T \\bx \\geq \\bs{b}^T \\bs{y}$, \n", " and only at optimality the equality holds $\\bs{c}^T \\bx^* = \\bs{b}^T \\bs{y}^*$ .\n", "\n", "\n", "* 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.\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Solution Methods\n", "\n", "* **Simplex** (Dantzig 1947)\n", "\n", "* **Ellipsoid** (Kachian 1979, the first algorithm known to be in **polynomial time**)\n", "\n", "* **Interior Point** (Karmakar 1984, the first **practical** polynomial time algorithm)\n", " * Projection method (Karmakar 1984)\n", " * Affine Method (Dikin 1967)\n", " * Log-Barrier Method (many ...)\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "\n", "\n", "* **Interior Point** method has been extended to NLP problems, has been the focus of research for optimization in the last few decades.\n", "\n", "* Although asymptotically superior, there is no clear winner between Simplex and Interior Point for LP problems: very much depends on the problem\n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Simplex Methods\n", "\n", "* Optimal points must be at the intersections of constraints:\n", "\n", "