Created
July 6, 2015 05:39
-
-
Save kenjisato/76e325f91a025a02284c to your computer and use it in GitHub Desktop.
2015 経済動学 講義資料 (2015-07-06)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"# Policy Iteration\n", | |
"\n", | |
"Stachurski (2008) Chapter 10" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": true, | |
"slideshow": { | |
"slide_type": "skip" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"%matplotlib inline" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": true, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"from scipy.interpolate import interp1d\n", | |
"import matplotlib.pyplot as plt" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"## ラムゼーモデル\n", | |
"\n", | |
"再掲" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"class Ramsey:\n", | |
" \"\"\"One-sector Ramsey model\"\"\"\n", | |
"\n", | |
" def __init__(self, A, α, ρ):\n", | |
" self.A, self.α, self.ρ = A, α, ρ\n", | |
"\n", | |
" def f(self, x):\n", | |
" \"\"\"Production function\"\"\"\n", | |
" return self.A * x ** self.α\n", | |
"\n", | |
" def U(self, x):\n", | |
" \"\"\"Utility from consumption\"\"\"\n", | |
" return np.log(x)\n", | |
" \n", | |
" def u(self, x, y):\n", | |
" \"\"\"Reduced form utility\"\"\"\n", | |
" return self.U(self.f(x) - y)\n", | |
"\n", | |
" def is_feasible(self, x, y):\n", | |
" \"\"\"Checks feasibility\"\"\"\n", | |
" return self.f(x) >= y" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"## 解析解\n", | |
"\n", | |
"再掲" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"def analytic_solutions(A, α, ρ):\n", | |
" c0 = (1.0 / (1.0 - α * ρ) / (1.0 - ρ) * np.log(A) +\n", | |
" α * ρ * np.log(α * ρ) / (1.0 - α * ρ) / (1.0 - ρ) +\n", | |
" np.log(1.0 - α * ρ) / (1.0 - ρ))\n", | |
" c1 = α / (1.0 - α * ρ) \n", | |
" \n", | |
" def value_func(x):\n", | |
" return c0 + c1 * np.log(x)\n", | |
" \n", | |
" def policy_func(x):\n", | |
" return ρ * c1 * A * x**α / (1.0 + ρ * c1) ## Fixed this line\n", | |
" \n", | |
" return value_func, policy_func" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"## 線形近似\n", | |
"\n", | |
"前回より実用的に ... " | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"class PLApprox: # Refactored this class\n", | |
" def __init__(self, a, b, N, upsample=10):\n", | |
" self.a, self.b, self.N = a, b, N\n", | |
" self.grids = np.linspace(a, b, upsample*N)\n", | |
" self.centers = np.linspace(a, b, N)\n", | |
" \n", | |
" def proj(self, f):\n", | |
" return np.array([f(c) for c in self.centers])\n", | |
" \n", | |
" def inj(self, a):\n", | |
" return interp1d(self.centers, a)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"# Policy Iteration" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"任意の $x \\in X$, に対して $(x, f(x)) \\in \\mathbb{D}$ を満たす関数 $f$ を policy function という. \n", | |
"\n", | |
"Policy function $f$ と十分大きな $T$ について, その policy function の value\n", | |
"\n", | |
"$$\n", | |
" v_f(x) = \\sum_{t=0}^\\infty \\rho^t u(f^t(x), f^{t+1}(x)) \n", | |
" \\approx \\sum_{t=0}^T \\rho^t u(f^t(x), f^{t+1}(x))\n", | |
"$$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"def value_of_policy(f, model, apx, T):\n", | |
" fc = apx.inj(f)\n", | |
" X = apx.centers\n", | |
" Y = fc(X)\n", | |
" vf = np.zeros_like(X)\n", | |
" for i in range(T):\n", | |
" vf += model.ρ**i * model.u(X, Y)\n", | |
" X, Y = Y, fc(Y)\n", | |
" return vf" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"Policy の更新則: $f\\to v_f \\to \\hat f$ \n", | |
"\n", | |
"$$\n", | |
" \\hat f (x) = \\arg\\max_y u(x, y) + \\rho v_f(y)\n", | |
"$$" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"def greedy(vf, model, apx):\n", | |
" vc = apx.inj(vf)\n", | |
" Y = apx.grids\n", | |
" fhat = np.empty_like(vf)\n", | |
" for i, x in enumerate(apx.centers):\n", | |
" X = np.ones_like(Y) * x\n", | |
" with np.errstate(invalid='ignore'):\n", | |
" maximand = np.where(model.is_feasible(X, Y),\n", | |
" model.u(X, Y) + model.ρ*vc(Y),\n", | |
" -np.inf)\n", | |
" fhat[i] = Y[np.argmax(maximand)]\n", | |
" return fhat" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"### Policy Iteration Algorithm\n", | |
"\n", | |
"\\begin{align}\n", | |
"\\begin{array}{cccccc}\n", | |
"f_0 & & f_1 & & f_2 & \\cdots & \\to & f^* \\\\\n", | |
"\\downarrow & \\nearrow & \\downarrow & \\nearrow & \\downarrow & & & \\\\\n", | |
"v_0 & & v_1 & & v_2 & \\cdots & \\to & v^* \\\\\n", | |
"\\end{array}\n", | |
"\\end{align}" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"いつものモデルで実験" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"A, α, ρ =1.1, 0.4, 0.9\n", | |
"ramsey = Ramsey(A, α, ρ)\n", | |
"apx = PLApprox(a=1e-3, b=5.0, N=500, upsample=100)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[<matplotlib.lines.Line2D at 0x1106df588>]" | |
] | |
}, | |
"execution_count": 9, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEACAYAAACnJV25AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHDNJREFUeJzt3Xl0VeW9//H3l3kmQCABAglDmFEEFFCGg/NAUVSqOFFt\n1Vat9opDS68l99dae2urrdOtYqtiLSpwURQRETgIiiAyhTGEMWHIAGQAEsjw3D9IkZ8GzLxP9vm8\n1spynz0937MXftaznvPsvc05h4iI+Ecdrws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" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"df = apx.proj(lambda x: 0.5 * ramsey.f(x))\n", | |
"\n", | |
"fhat = df\n", | |
"for _ in range(10):\n", | |
" vf = value_of_policy(fhat, ramsey, apx, T=100)\n", | |
" fhat = greedy(vf, ramsey, apx)\n", | |
"\n", | |
"for _ in range(3):\n", | |
" plt.plot(apx.centers, vf)\n", | |
" vf = value_of_policy(fhat, ramsey, apx, T=100)\n", | |
" fhat = greedy(vf, ramsey, apx)\n", | |
" \n", | |
"v, h = analytic_solutions(A, α, ρ)\n", | |
"plt.plot(apx.grids, v(apx.grids), ':')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"metadata": { | |
"collapsed": false, | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"[<matplotlib.lines.Line2D at 0x110131160>]" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
}, | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXIAAAEACAYAAACuzv3DAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd8VfX9x/HXJyEJYQkYhixBQcRtC4gDvMgwDgRFBdxW\nqbWgqNW6MfanbW1rxT1BnMUKyhKJMoIiqICAjICEPQRkb8j4/P5IqmkaMsg4ubnv5+ORB/fc873n\nfLgPfOfr95zv95i7IyIi4Ssq6AJERKRkFOQiImFOQS4iEuYU5CIiYU5BLiIS5hTkIiJhrtAgN7NE\nM1tiZsvM7P589ieY2UQzm2dmC83spjKpVERE8mUF3UduZtHAUqArsB6YBfRz99RcbZKAOHd/0MwS\ncto3cPeMsixcRESyFdYjbw+kufsqd08HRgA987T5EaiV87oWsFUhLiJSfqoUsr8xsDbX9jrgrDxt\nXgemmNkGoCZwdemVJyIihSmsR16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HqCYmYJZlY753U80A2YG2xVwXD3h9y9qbu3\nAPoCU9z9hqDrCoKZVTOzmjmvqwPdgcPe7VamQe7uGWTP+kwGFgMfROJdCf9hZv8CZgAnmNlaM4vk\nyVPnAtcBnXNur5prZolBFxWAY4ApOWPk3wDj3H1ywDVVFJE8NNsA+DLXv4vx7v7Z4RprQpCISJjT\no95ERMKcglxEJMwpyEVEwpyCXEQkzCnIRUTCnIJcRCTMKchFRMKcglxEJMz9P3UddRBfXju+AAAA\nAElFTkSuQmCC\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x110131128>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"plt.plot(apx.centers, fhat)\n", | |
"plt.plot(apx.centers, h(apx.centers))" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"## なぜ収束するのか?\n", | |
"\n", | |
"$$\n", | |
"f_{n+1}(x) = \\arg\\max_y u(x, y) + \\rho v_n(y)\n", | |
"$$\n", | |
"\n", | |
"に対応する作用素\n", | |
"\n", | |
"$$\n", | |
" T_{n+1} w (x) = u(x, f_{n+1}(x)) + \\rho w(f_{n+1}(x))\n", | |
"$$\n", | |
"\n", | |
"を定義. \n", | |
"\n", | |
"3つの性質に注意:\n", | |
"\n", | |
"$$\n", | |
" T_{n+1} v_n = v_{n+1}\n", | |
"$$\n", | |
"\n", | |
"$$\n", | |
" T_{n+1} v_n = Tv_n\n", | |
"$$\n", | |
"\n", | |
"$$\n", | |
" v \\le w \\Longrightarrow T_{n+1}v \\le T_{n+1}w\n", | |
"$$" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"### 価値の単調性\n", | |
"\n", | |
"\\begin{align}\n", | |
"v_n(x) &= u(x, f_n(x)) + \\rho v_n(f_n(x)) \\\\\n", | |
" &\\le u(x, f_{n+1}(x)) + \\rho v_n(f_{n+1}(x)) \\\\\n", | |
" &=: T_{n+1} v_n(x) \\\\\n", | |
" &\\le T_{n+1}^2 v_n(x) \\\\\n", | |
" &\\le \\cdots \\\\\n", | |
" &\\to v_{n+1}(x)\n", | |
"\\end{align}" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"slideshow": { | |
"slide_type": "slide" | |
} | |
}, | |
"source": [ | |
"### Bellman作用素 $T$ との関係\n", | |
"\n", | |
"\\begin{align}\n", | |
" T^n v_0 \\le v_n \\le v^*\n", | |
"\\end{align}\n", | |
"\n", | |
"#### 証明\n", | |
"\n", | |
"$n=0$\n", | |
"のときは自明に成り立つ. \n", | |
"$n$ まで成り立つとして, \n", | |
"\n", | |
"\\begin{align}\n", | |
" T^{n+1} v_0 = T(T^n v_0) \\le Tv_n = T_{n+1} v_n = v_{n+1}\n", | |
"\\end{align}" | |
] | |
} | |
], | |
"metadata": { | |
"celltoolbar": "Slideshow", | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.4.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment