{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### A Recursive Formulation of Repeated Games\n", "\n", "**Authors**: Chase Coleman with Thomas Sargent\n", "\n", "This notebook describes Julia code that implements an algorithm for computing equilibrium values and associated equilibrium strategy profiles for repeated games with $N$ players and finite actions.\n", "\n", "The code builds on ideas of Abreu, Pearce, Stachetti (1986, 1990).\n", "\n", "It uses a numerical algorithm called the _outer hyperplane approximation algorithm_ invented by Judd, Yeltekin, Conklin (2003).\n", "\n", "We focus on a particularly simple example, namely, a repeated prisoner's dilemma.\n", "\n", "Our friends Timothy Hills and Ben Tengelsen provided useful comments about detailed aspects of the algorithm.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.webio.node+json": { "children": [], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": {}, "type": "node" }, "text/html": [ "
\n", "

The WebIO Jupyter extension was not detected. See the\n", "\n", " WebIO Jupyter integration documentation\n", "\n", "for more information.\n", "

\n" ], "text/plain": [ "WebIO._IJuliaInit()" ] }, "metadata": { "application/vnd.webio.node+json": { "kernelId": "11f65e91-a7b5-4769-a651-a2eedf714205" } }, "output_type": "display_data" } ], "source": [ "using GameTheory\n", "using PlotlyJS" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "\n", "Ideas in play in this notebook are a one-shot or stage **game** and its **Nash equilibria**; a **repeated game** and the values associated with its **subgame perfect equilibria**; **backward induction** and **dynamic programming**; and **linear programming**\n", "\n", "While each of these concepts is worth studying in its own right, here we will focus only on the mechanics necessary to understand the outer approximation algorithm.\n", "\n", "### A Game\n", "\n", "A *game* consists of\n", " * a list of players\n", " * a set of actions available to each player\n", " * a description of payoffs to each player as a function of actions chosen by all players\n", " * a timing protocol which specifies who chooses what when\n", "\n", "\n", "### Nash equilibrium\n", "\n", "A *Nash equilibrium* is a collection of actions that pass the following test: the action of each player gives that player the highest payoff, taking as given the actions of all other players.\n", "\n", "### A Repeated Game\n", "\n", "A *repeated game* in discrete time consists of\n", " * A game replayed by the same players at a sequence of dates $t =0, 1, \\ldots, T$, where $T$ might be infinity\n", " * A common discount rate at which all players discount future payoffs\n", " * For each player a *strategy* in the form of a sequence of functions; the time $t$ component of this sequence prescribes an action at time $t$ as a function of information available to that player at $t$\n", "\n", "### Subgame Perfect Equilibria\n", "\n", "A *Subgame Perfect equilibrium* is a collection of strategies, one for each player, that satisfies the test that, given other players' strategies, each player wants to adhere to his strategy at each date $t \\geq 0$ for all possible histories\n", "\n", "A *Subgame Perfect value* is the expected discounted utility that an agent receives within a subgame perfect equilibrium.\n", "\n", "### Backwards Induction and Dynamic Programming\n", "\n", "We will encounter an operator reminscent of the *Bellman operator* associated with dynamic programming. This new operator, $\\mathcal{B}$, maps a **set** of a vector of continuation values into a **set** of a vector of values. The $i$th element of a vector of values is the discounted value assigned to agent $i$. Continuation value vectors are be drawn from a *set* of candidate value vectors. For good reasons, we will be tempted to iterate to convergence on this operator. \n", "\n", "### Linear programming\n", "\n", "We'll use linear programs to do most of the heavy lifting\n", "\n", "### Prisoner's Dilemma\n", "\n", "We'll use the prisoner's dilemma as an example" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## One-Shot Prisoner's Dilemma\n", "\n", "The Prisoners' Dilemma is a list of two players and a $2 \\times 2$ payoff matrix designed to express the following situation.\n", "\n", "Two suspects are in police custody. Without a confession or testimony from one of the suspects, the police have evidence indicating but not proving that together the two committed a serious crime. But the police have enough evidence to convict both suspects on a less serious crime. The police offer both the suspects the following deal: If you betray your partner by testifying against him, then we'll let you walk free while your partner is punished for the serious crime; but if you accuse each other, then we'll convict both of you of the more serious crime but with a slightly lesser sentence than if you had stayed quiet. The suspects know that the police have only enough evidence to convict them of the lesser charge if neither of them betrays the other.\n", "\n", "We represent this game with the following payoff matrix:\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(9, 9) (1, 10)
(10, 1) (3, 3)
\n", "\n", "In this game there is a unique Nash equilibrium in which both A and B choose to betray and receive payoffs (3, 3)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Repeated Prisoner's Dilemma\n", "\n", "We change the game by repeating it forever.\n", "\n", "The same two criminals repeatedly face the prisoner's dilemma an infinite number of times. \n", "\n", "They play the game described above in every period with the same per period payoffs. Both players discount the future at $\\delta \\in (0, 1)$.\n", "\n", "In the unique Nash equilibrium of a single shot prisoners dilemma, both players betray.\n", "\n", "Do there exist subgame perfect equilibria of the **repeated prisoner's dilemma game** in which the prisoners always remain silent?\n", "\n", "If the prisoners are patient enough, i.e., $\\delta$ is close enough to one, the answer is **yes**.\n", "\n", "In the repeated game, the prisoners' payoffs depend on sequences of both players' actions.\n", "\n", "Let $\\vec{a}$ ($\\vec{b}$) denote the history of actions of prisoner A (B) and let $a_t$ ($b_t$) denote the action taken by A (B) at period $t$. \n", "\n", "Then A's present value of payoffs is\n", "\n", "$$v^A(\\vec{a}, \\vec{b}) = (1-\\delta) \\sum_{t=0}^{\\infty} \\delta^t u(a_t, b_t)$$\n", "\n", "and B's present value of payoffs is\n", "\n", "$$v^B(\\vec{a}, \\vec{b}) = (1-\\delta) \\sum_{t=0}^{\\infty} \\delta^t u(b_t, a_t)$$\n", "\n", "where\n", "\n", "$$u(a_t, b_t) = \\begin{cases} 9 \\text{ if } a_t = b_t = \\text{silent} \\\\ 10 \\text{ if } a_t = \\text{betray} \\ \\& \\ b_t = \\text{silent} \\\\ 1 \\text{ if } a_t = \\text{silent} \\ \\& \\ b_t = \\text{betray} \\\\ 3 \\text{ if } a_t = b_t = \\text{betray} \\end{cases}$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can now use the QuantEcon `GameTheory` library to represent the stage game and the repeated game.\n", "\n", "The stage game is simply created by `NormalFormGame((A, B))`. This command takes a tuple of players (in this case `A` and `B`) and using the information held about payoffs for each player creates a normal form game. For more information consider reviewing the [Tools for Game Theory notebook](https://nbviewer.jupyter.org/github/QuantEcon/game-theory-notebooks/blob/main/game_theory_jl.ipynb).\n", "\n", "A repeated game is then defined as a normal form game and a discount factor. It is created by the command `RepeatedGame(nfg, delta)`." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RepeatedGame{2, Float64}(2×2 NormalFormGame{2, Float64}, 0.75)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create the payoff matrix for prisoner's dilemma\n", "pd_payoff = [9.0 1.0;\n", " 10.0 3.0]\n", "\n", "# Create two players: A and B\n", "A, B = Player(pd_payoff), Player(pd_payoff)\n", "\n", "# These two players and their payoffs define a stage game\n", "nfg = NormalFormGame((A, B))\n", "\n", "# The repeated game is stage game plus a discount factor\n", "delta = 0.75\n", "rpd = RepeatedGame(nfg, delta)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### APS Insight\n", "\n", "We follow Abreu, Pearce, Stachetti (1986, 1990) (whom we denote APS hereon) who created a set of practical techniques for characterizing all possible subgame equilibrium **values**. \n", "\n", "APS use the following objects and flow of ideas.\n", "\n", " * A history of action pairs $a^t, b^t = (a_0,b_0), (a_1, b_1), \\ldots , (a_t,b_t) $\n", "\n", " * A strategy $\\sigma^i$ for a player is a time $0$ action and a sequence of functions $\\{\\sigma_t^i\\}_{t=0}^\\infty $, the $t$th component of which maps a history $a^{t-1}, b^{t-1}$ into a time $t$ action for player $i$\n", " \n", " * A strategy profile $\\sigma = (\\sigma^A, \\sigma^B)$ for our two players.\n", " \n", " * The observation that a strategy profile determines a pair of present discounted values $(v^A, v^B)$ for our two players (just plug the implied sequence of action pairs into the appropriate expressions for discounted utility).\n", "\n", " * A definition of **subgame equilibria** as strategy profiles that satisfy the requirement that given the other player's strategy, each player wants to adhere to his strategy at each date $t \\geq 0$ for all possible histories.\n", " \n", " * The observation that a strategy consists of a first-period action and a (continuation) strategy to be followed subsequently.\n", " \n", " * The observation that continuation strategy profiles have associated present values\n", "$\\tilde{v}^A, \\tilde{v}^B$ too.\n", " \n", " * The observation that a subgame equilibrium consists of first period actions for both players chosen in light of players' (rational) expectations about the consequences of those choices for future utilities.\n", " \n", " * A characterization of subgame equilibrium values $v^i, i= A, B$ in terms of a first period action pair $a^A, a^B$ and a pair of subgame perfect continuation values $\\tilde v^i, \\check v^i$ that satisfy recursions $$v^i = (1-\\delta) u(a^i, a^{-i}) + \\delta \\tilde v^i \\geq (1- \\delta ) u( \\check a^i, a^{-i} ) + \\delta \\check v^i \\quad (\\dagger)$$ where $a^i$ is the action chosen by player $i$ and $a^{-i}$ is the action chosen by player $-i$ (the other player). Here $\\tilde v^i$ is the continuation value that player $i$ receives if he adheres to a strategy that prescribes first period action $a^i$ this period and $\\check v^i$ is the continuation value in a subgame perfect equilibrium value prescribed if the player deviates from the strategy by choosing $\\check a^i \\neq a^i$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " APS note that\n", "\n", " * Equation $(\\dagger)$ for each player $i$ maps **pairs** of subgame perfect equilibrium continuation values $\\tilde v^i, \\check v^i$ into a single value $v^i$.\n", "\n", " * Equation $(\\dagger)$ characterizes **all** subgame perfect equilibrium values. This means that $\\tilde v^i$ and $\\check v^i$ each satisfy versions of this equation where they are now on the **left** side of the equation and another pair of continuation values are on the right side. That $\\check v^i$ is itself a subgame perfect equilibrium value captures the notion that it is the value associated with a strategy that is a **credible threat** that deters player $i$ from deviating from the first-period action $a^i$.\n", "\n", " * APS use this insight together with the backward induction inherent in equation ($\\dagger$) to characterize the set of subgame perfect equilibrium values $V \\in \\mathbb{R}^2$ as the largest fixed point of iterations of a set-to-set mapping $\\mathcal{B}$ that maps four-tuples of continuation values, two for player $A$, two for player $B$, into pairs of values, one for player $A$ and one for player $B$.\n", " \n", "More formally, let $W \\subseteq \\mathbb{R}^2$ be a compact set of pairs of candidate continuation values: one for player $A$ and the other for player $B$.\n", "\n", "A reward is a continuation value that a player receives for adhering to a strategy; a punishment is a continuation value that a player receives for deviating from a strategy.\n", "\n", "To be a subgame equilibrium stategy, both the reward and the punishment must be values associated with (possibly other) subgame perfect equilibrium strategies.\n", "\n", "APS's aim is to find the set of value pairs associated with _all_ subgame equilibrium \n", "strategy profiles.\n", "\n", "In the spirit of dynamic programming, APS start by guessing a set of candidate continuation values to use as rewards and punishments and then deducing the set of values that those continuation values could support in the sense of satisfying a counterpart to\n", "the incentive constraint equation ($\\dagger$). Their proposal is to iterate on this construction.\n", "\n", "Thus, APS's $\\mathcal{B}$ operator maps a set of candidate pairs of continuation values $W$ into the set of values that can be supported by using elements of $W$ as rewards and punishments for players $A$ and $B$. In particular, one can consider without loss of generality a particular pair of punishments, the worst-case punishments, $(\\underline{w}_1, \\underline{w}_2)$ where\n", "\n", "\\begin{align*}\n", "\\underline{w}_i &= \\min_{w_i} \\; w_i \\\\\n", " &\\text{subject to } w_i \\in W\n", "\\end{align*}\n", "\n", "To understand why we can use only the worst-cast punishments, $(\\underline{w}_1, \\underline{w}_2)$, just look at equation ($\\dagger$). If the inequality is satisfied for some ($\\tilde{v}_i$, $\\check{v}_i$) then it is also satisfied for ($\\tilde{v}_i, \\underline{w}_i$) because $\\check{v}_i \\geq \\underline{w}_i$.\n", "\n", "Using the insight that we can consider only worst-case punishments, the $\\mathcal{B}$ operator is explicitly defined by\n", "\n", "\\begin{align*}\n", " \\mathcal{B}(W) &= \\{ (w_1, w_2) \\\\\n", " &\\text{such that} \\\\\n", " &(w_1, w_2) \\in W \\\\\n", " &\\exists (a_1, a_2) \\text{ such that } \\forall \\check{a}_1 \\;(1-\\delta) u(a_1, a_2) + \\delta w_1 \\geq (1- \\delta) u(\\check{a}_1, a_2) + \\delta \\underline{w}_1 \\\\\n", " &\\exists (a_1, a_2) \\text{ such that } \\forall \\check{a}_2 \\;((1-\\delta) u(a_1, a_2) + \\delta w_2 \\geq (1- \\delta) u(a_1, \\check{a}_2) + \\delta \\underline{w}_2 \\}\n", "\\end{align*}\n", "\n", " * APS show that $\\mathcal{B}$ is a **monotone operator** in the sense that if $V \\subset V'$ then $\\mathcal{B}(V) \\subset \\mathcal{B}(V')$\n", "\n", " * The monotonicity of $\\mathcal{B}$ means that \n", " - iterations on $\\mathcal{B}$ starting from any initial set converge to a fixed point.\n", " - if we start from a sufficiently large initial guess $W_0$, iterations on $\\mathcal{B}$ converge to the largest fixed point.\n", " - It can then be verified that the largest fixed point of $\\mathcal{B}$ equals the set of all subgame equilibrium values.\n", "\n", "To make things work, it is important to start APS's operator $\\mathcal{B}$ from a generous (meaning it might be too big) set of candidate continuation values $W$. From this set, the algorithm draws two pairs $\\tilde v^i, \\check v^i$ for $i=A, B$, where $\\tilde v^i, \\check v^i$ are both drawn from the $i$ component of W (usually, $\\tilde v^i$ a high value and $\\check v^i$ a low value) for $i=A,B$. It then finds a feasible first period \n", "action pair and associated pair of values $v^A, v^B$ that satisfies inequalities $(\\dagger)$. The set of **all** value pairs $v^A, v^B$ that satisfy these inequalities for \n", "a given set of candidate continuation values is a new set $\\mathcal{B}(W)$. \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Public Randomization\n", "\n", "Judd, Yeltekin, Conklin (2003) simplify a candidate value set by *convexifying* it. This can be accomplished with **public randomization**\n", "\n", "Public randomization enables players to coordinate by making their actions depend on a commonly observed public signal. For example: At the beginning of every period every player observes a realization of a uniform random variable with domain on the interval $[0,1]$. If the realization is less than 0.5, then the players take some previously agreed upon action while if the number is greater than 0.5 then they each take a (possibly different) previously specified action. This device ensures the convexity of value sets. If players can achieve $V = (v_1, v_2)$ and $W = (w_1, w_2)$, then public randomization lets players achieve any value $Z = \\lambda V + (1-\\lambda) W$.\n", "\n", "In line with our example, one can think of $\\lambda$ as a probability of an event that leads players to choose SPE actions with value $V$, while the complement of $\\lambda$ is an event that prompts SPE actions with value $W$.\n", "\n", "We have left out many technical details here, but if you are interested in understanding this material further then we recommend reading Abreu Pearce Stacchetti 1986, Abreu Pearce Stachetti 1990, and Judd Yeltekin Conklin 2003 (all are cited at the end of this notebook).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Approximating the set\n", "\n", "A key recommendation of JYC 2003 is a way to approximate the set of subgame perfect equilibrium values. \n", "\n", "As mentioned above, we use public randomization to assure that sets are convex.\n", "\n", "A convenient property of convex sets (polytopes in particular) is that because we only need to keep track of extreme points, they can be represented easily inside a computer. This is referred to as the vertice representation.\n", "\n", "It is also useful to recognize that polytopes could also be represented as the intersection of a finite number of half-spaces.\n", "\n", "The algorithm will mostly represent sets in the half-space representation, but we mention the vertice representation because that is typically how we envision (and display) sets.\n", "\n", "We can describe a set using half-spaces in the following way: Consider a set of subgradients (think about these as directional vectors) $H$. For example, let $H = \\{ (1, 0), (0, 1), (-1, 0), (0, -1) \\}$. Let $C$ be a set of hyperplane levels, for example, $C = \\{4, 3, 2, 1\\}$. The halfspace corresponding to a specific subgradient, $h \\in H$, and hyperplane level, $c \\in C$, is described by the set $s = \\{ (x, y) | h \\cdot (x, y) \\leq c \\}$. In our example, the set of half-spaces would be $S = \\{s_1, s_2, s_3, s_4\\}$, where\n", "\n", "\\begin{align*}\n", " s_1 &:= \\{ (x, y) | x \\leq 4 \\} \\\\\n", " s_2 &:= \\{ (x, y) | y \\leq 3 \\} \\\\\n", " s_3 &:= \\{ (x, y) | -x \\leq 2 \\} \\\\\n", " s_4 &:= \\{ (x, y) | -y \\leq 1 \\}\n", "\\end{align*}\n", "\n", "We draw the following below:\n", "\n", " * Each of the half-spaces (draw their hyper-planes)\n", " * Intersection of the half-spaces (shaded red)\n", " * Subgradients ($h_i$)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "editable": false, "responsive": true, "scrollZoom": true, "showLink": false, "staticPlot": false }, "data": [ { "name": "s_1", "type": "scatter", "x": [ 4, 4 ], "y": [ -5, 5 ] }, { "name": "s_2", "type": "scatter", "x": [ -5, 5 ], "y": [ 3, 3 ] }, { "name": "s_3", "type": "scatter", "x": [ -2, -2 ], "y": [ -5, 5 ] }, { "name": "s_4", "type": "scatter", "x": [ -5, 5 ], "y": [ -1, -1 ] } ], "frames": [], "layout": { "annotations": [ { "arrowhead": 2, "arrowsize": 1, "arrowwidth": 2, "ax": -105, "ay": 0, "showarrow": true, "x": 1, "y": 0 }, { "arrowhead": 2, "arrowsize": 1, "arrowwidth": 2, "ax": 0, "ay": 65, "showarrow": true, "x": 0, "y": 1 }, { "arrowhead": 2, "arrowsize": 1, "arrowwidth": 2, "ax": 105, "ay": 0, "showarrow": true, "x": -1, "y": 0 }, { "arrowhead": 2, "arrowsize": 1, "arrowwidth": 2, "ax": 0, "ay": -65, "showarrow": true, "x": 0, "y": -1 }, { "arrowhead": 2, "showarrow": false, "text": "h_1", "x": 1, "y": 0.25 }, { "arrowhead": 2, "showarrow": false, "text": "h_2", "x": 0.25, "y": 1 }, { "arrowhead": 2, "showarrow": false, "text": "h_3", "x": -1, "y": 0.25 }, { "arrowhead": 2, "showarrow": false, "text": "h_4", "x": 0.25, "y": -0.75 } ], "autosize": false, "height": 500, "margin": { "b": 50, "l": 50, "r": 50, "t": 60 }, "shapes": [ { "fillcolor": "red", "line": { "width": 0 }, "opacity": 0.4, "type": "rect", "x0": -2, "x1": 4, "y0": -1, "y1": 3 } ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": "Intersection of Half-spaces", "width": 700, "xaxis": { "range": [ -3.5, 4.5 ] }, "yaxis": { "range": [ -3, 4 ] } } }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "data: [\n", " \"scatter with fields name, type, x, and y\",\n", " \"scatter with fields name, type, x, and y\",\n", " \"scatter with fields name, type, x, and y\",\n", " \"scatter with fields name, type, x, and y\"\n", "]\n", "\n", "layout: \"layout with fields annotations, autosize, height, margin, shapes, template, title, width, xaxis, and yaxis\"\n", "\n" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 2\n", "ls_m5_p5 = [i for i in range(-5, stop=5, length=n)]\n", "\n", "# Build traces\n", "t_s1 = scatter(;x=fill(4, n), y=ls_m5_p5, name=\"s_1\")\n", "t_s2 = scatter(;x=ls_m5_p5, y=fill(3, n), name=\"s_2\")\n", "t_s3 = scatter(;x=fill(-2, n), y=ls_m5_p5, name=\"s_3\")\n", "t_s4 = scatter(;x=ls_m5_p5, y=fill(-1, n), name=\"s_4\")\n", "\n", "# Build layout\n", "h_s1 = Dict(\"x\"=>1, \"y\"=>0,\"arrowhead\"=>2, \"arrowsize\"=>1, \"arrowwidth\"=>2,\n", " \"showarrow\"=>true, \"ax\"=>-105, \"ay\"=>0)\n", "h_s2 = Dict(\"x\"=>0, \"y\"=>1,\"arrowhead\"=>2, \"arrowsize\"=>1, \"arrowwidth\"=>2,\n", " \"showarrow\"=>true, \"ax\"=>0, \"ay\"=>65)\n", "h_s3 = Dict(\"x\"=>-1, \"y\"=>0,\"arrowhead\"=>2, \"arrowsize\"=>1, \"arrowwidth\"=>2,\n", " \"showarrow\"=>true, \"ax\"=>105, \"ay\"=>0)\n", "h_s4 = Dict(\"x\"=>0, \"y\"=>-1,\"arrowhead\"=>2, \"arrowsize\"=>1, \"arrowwidth\"=>2,\n", " \"showarrow\"=>true, \"ax\"=>0, \"ay\"=>-65)\n", "\n", "h_1 = Dict(\"x\"=>1, \"y\"=>0.25,\"arrowhead\"=>2, \"text\"=>\"h_1\", \"showarrow\"=>false)\n", "h_2 = Dict(\"x\"=>0.25, \"y\"=>1,\"arrowhead\"=>2, \"text\"=>\"h_2\", \"showarrow\"=>false)\n", "h_3 = Dict(\"x\"=>-1, \"y\"=>0.25,\"arrowhead\"=>2, \"text\"=>\"h_3\", \"showarrow\"=>false)\n", "h_4 = Dict(\"x\"=>0.25, \"y\"=>-0.75,\"arrowhead\"=>2, \"text\"=>\"h_4\", \"showarrow\"=>false)\n", "\n", "shapes = [rect(-2, 4, -1, 3, fillcolor=\"red\", opacity=0.4, line_width=0)]\n", "l = Layout(;shapes=shapes, title=\"Intersection of Half-spaces\",\n", " xaxis_range=[-3.5, 4.5], yaxis_range=[-3.0, 4.0],\n", " annotations=[h_s1, h_s2, h_s3, h_s4,\n", " h_1, h_2, h_3, h_4],\n", " autosize=false, width=700, height=500)\n", "\n", "plot([t_s1, t_s2, t_s3, t_s4], l)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We promised to show you three things:\n", " * Each of the half-spaces\n", " * Intersection of the half-spaces\n", " * Subgradients\n", "\n", "We have delivered on these promises by plotting the subgradients (directional vectors) as black arrows, plotting the hyperplane of each half space, and shading the intersection of the 4 half-spaces in red. The blue line corresponds to the hyperplane for the first half-space and everything to the left of this line is an element of the half-space. The orange line corresponds to the hyperplane for the second half-space and everything below this line is an element of the half-space. The green line corresponds to the hyperplane for the third half-space and everything to the right of this line is an element of the half-space. The red line corresponds to the hyperplane for the fourth half-space and everything above this line is an element of the half-space.\n", "\n", "This picture also provides insights into relationships among the subgradient, hyperplane level, and the hyperplane/half-space. In particular, note that the hyperplane of the half-space is orthogonal to its corresponding subgradient -- The subgradient determines the slope and orientation of the set (whether it lies to the left, right, above, or below the hyperplane). The hyperplane level determines the location of the hyperplane -- It expresses how far from the origin the hyperplane lies. We will see this highlighted again when we plot value sets associated with the repeated game." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In practice how do we map our $\\mathcal{B}$ operator into the correct set of half-spaces?\n", "\n", "We accomplish this by transforming the $\\mathcal{B}$ operator into a sequence of linear programs that constructs the smallest convex set that contains the fixed point of the $\\mathcal{B}$ operator. We call this smallest convex set the **outer hyperplane approximation**.\n", "\n", "Here is an outline of the **outer hyperalogrithm**.\n", "\n", "1. Initialize elements of our algorithm\n", " * Subgradients, $H$\n", " * Hyperplane levels, $C$\n", "2. Given a set of subgradients and corresponding hyperplane levels\n", " * For each subgradient, $h \\in H$,\n", " 1. Solve a linear program for each action in the action space\n", " 2. Find maximum to update hyperplane level\n", " 3. Find the associated $(w_1, w_2)$ pair\n", "3. Check whether hyperplane levels changed more than the set tolerance. If so, return to 2. Else, proceed.\n", "4. Set of vertices is described by $Z$ and define $W^* = \\text{co}(Z)$.\n", "\n", "We discuss each of these steps in more detail below" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 1: Initilization Step\n", "\n", "#### Unit Circle\n", "\n", "There is not a unique way to pick the initial subgradients and hyperplane levels. However, a way that seems to work quite well is simply to partition a unit circle. If there are $N$ subgradients, set\n", "\n", "$$h_i = \\left( \\cos \\left( 2 \\pi \\frac{i}{N} \\right), \\sin \\left(2 \\pi \\frac{i}{N} \\right) \\right)$$\n", "\n", "Here is a function that produces such a set of subgradients. We plot them below." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "editable": false, "responsive": true, "scrollZoom": true, "showLink": false, "staticPlot": false }, "data": [ { "type": "scatter" }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 1", "showlegend": false, "type": "scatter", "x": [ 0, 1 ], "y": [ 0, 0 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 2", "showlegend": false, "type": "scatter", "x": [ 0, 0.9510565162951535 ], "y": [ 0, 0.3090169943749474 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 3", "showlegend": false, "type": "scatter", "x": [ 0, 0.8090169943749475 ], "y": [ 0, 0.5877852522924731 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 4", "showlegend": false, "type": "scatter", "x": [ 0, 0.5877852522924731 ], "y": [ 0, 0.8090169943749475 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 5", "showlegend": false, "type": "scatter", "x": [ 0, 0.30901699437494745 ], "y": [ 0, 0.9510565162951535 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 6", "showlegend": false, "type": "scatter", "x": [ 0, 6.123233995736766e-17 ], "y": [ 0, 1 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 7", "showlegend": false, "type": "scatter", "x": [ 0, -0.30901699437494734 ], "y": [ 0, 0.9510565162951536 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 8", "showlegend": false, "type": "scatter", "x": [ 0, -0.587785252292473 ], "y": [ 0, 0.8090169943749475 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 9", "showlegend": false, "type": "scatter", "x": [ 0, -0.8090169943749473 ], "y": [ 0, 0.5877852522924732 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 10", "showlegend": false, "type": "scatter", "x": [ 0, -0.9510565162951535 ], "y": [ 0, 0.3090169943749475 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 11", "showlegend": false, "type": "scatter", "x": [ 0, -1 ], "y": [ 0, 1.2246467991473532e-16 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 12", "showlegend": false, "type": "scatter", "x": [ 0, -0.9510565162951536 ], "y": [ 0, -0.3090169943749473 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 13", "showlegend": false, "type": "scatter", "x": [ 0, -0.8090169943749475 ], "y": [ 0, -0.587785252292473 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 14", "showlegend": false, "type": "scatter", "x": [ 0, -0.5877852522924732 ], "y": [ 0, -0.8090169943749473 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 15", "showlegend": false, "type": "scatter", "x": [ 0, -0.30901699437494756 ], "y": [ 0, -0.9510565162951535 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 16", "showlegend": false, "type": "scatter", "x": [ 0, -1.8369701987210297e-16 ], "y": [ 0, -1 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 17", "showlegend": false, "type": "scatter", "x": [ 0, 0.30901699437494723 ], "y": [ 0, -0.9510565162951536 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 18", "showlegend": false, "type": "scatter", "x": [ 0, 0.5877852522924729 ], "y": [ 0, -0.8090169943749476 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 19", "showlegend": false, "type": "scatter", "x": [ 0, 0.8090169943749473 ], "y": [ 0, -0.5877852522924734 ] }, { "line": { "color": "grey" }, "mode": "lines", "name": "Subgradient 20", "showlegend": false, "type": "scatter", "x": [ 0, 0.9510565162951535 ], "y": [ 0, -0.3090169943749476 ] } ], "frames": [], "layout": { "autosize": false, "height": 500, "margin": { "b": 50, "l": 50, "r": 50, "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": "Subgradients from Unit Circle", "width": 700 } }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "data: [\n", " \"scatter with field type\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\",\n", " \"scatter with fields line, mode, name, showlegend, type, x, and y\"\n", "]\n", "\n", "layout: \"layout with fields autosize, height, margin, template, title, and width\"\n", "\n" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 20\n", "pts = GameTheory.unitcircle(n)\n", "p = plot(scatter(), Layout(;title=\"Subgradients from Unit Circle\",\n", " autosize=false, height=500, width=700))\n", "\n", "for i=1:n\n", " xi, yi = pts[i, :]\n", " ti = scatter(;x=[0.0, xi], y=[0.0, yi], mode=\"lines\",\n", " name=\"Subgradient $i\", line_color=\"grey\",\n", " showlegend=false)\n", " addtraces!(p, ti)\n", "end\n", "\n", "p" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here there are $n$ lines. Each line is a single subgradient. Try to conceive a half-space at the end of each of these subgradients -- Points that determine the shape of the polygon aren't actually the points at the end of the subgradients, but rather points at which the halfspaces intersect. As we drive the number of lines to infinity, we will obtain a circle." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Hyperplanes\n", "\n", "In addition to choosing the subgradient directions, we must also pick initial hyperplane levels. One way (again this isn't unique) is to pick an origin and a radius, then to compute points that would be along the circle in the direction of each subgradient. Once we have these points then we can use them to compute the hyperplane levels simply by $H \\cdot Z'$.\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "editable": false, "responsive": true, "scrollZoom": true, "showLink": false, "staticPlot": false }, "data": [ { "type": "scatter", "x": [ 11.863961030678928, 11.552486607675615, 10.648552625359159, 9.240642439997082, 7.466572110019695, 5.5, 3.533427889980306, 1.7593575600029197, 0.3514473746408422, -0.5524866076756156, -0.8639610306789276, -0.5524866076756165, 0.3514473746408413, 1.7593575600029183, 3.533427889980304, 5.499999999999999, 7.466572110019694, 9.24064243999708, 10.648552625359159, 11.552486607675615, 11.863961030678928 ], "y": [ 5.5, 7.466572110019695, 9.240642439997082, 10.648552625359159, 11.552486607675615, 11.863961030678928, 11.552486607675617, 10.648552625359159, 9.240642439997082, 7.466572110019696, 5.500000000000001, 3.533427889980306, 1.7593575600029197, 0.3514473746408422, -0.5524866076756156, -0.8639610306789276, -0.5524866076756165, 0.3514473746408404, 1.7593575600029179, 3.533427889980304, 5.5 ] } ], "frames": [], "layout": { "autosize": false, "height": 500, "margin": { "b": 50, "l": 50, "r": 50, "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": "Starting Set", "width": 700, "xaxis": { "title": { "text": "w_1" } }, "yaxis": { "title": { "text": "w_2" } } } }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "data: [\n", " \"scatter with fields type, x, and y\"\n", "]\n", "\n", "layout: \"layout with fields autosize, height, margin, template, title, width, xaxis, and yaxis\"\n", "\n" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n = 20\n", "C, H, Z = GameTheory.initialize_sg_hpl(rpd, n)\n", "t = scatter(;x=vcat(Z'[:, 1], Z[1, 1]), y=vcat(Z'[:, 2], Z[2, 1]))\n", "l = Layout(;title=\"Starting Set\", xaxis_title=\"w_1\", yaxis_title=\"w_2\",\n", " autosize=false, height=500, width=700)\n", "p = plot(t, l)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 2: Iterative Step\n", "\n", "The general idea of this step will be to push each hyperplane (which defines the set's boundary) as far in each direction as possible -- We are trying to make the set of continuation values as large as possible while satisfying the constraints of the $\\mathcal{B}$ operator.\n", "\n", "There is a sequence of linear programs (one for each subgradient) that each take the following form. For the current subgradient $h_i$ and given a specified action for today, $a$, maximize the dot product of the agents' values and the subgradient (i.e. maximize in a specific direction):\n", "\n", "\\begin{align*}\n", " \\max_{w} \\; &h_i \\cdot ((1-\\delta) u(a) + \\delta w) \\\\\n", " &\\text{subject to} \\\\\n", " &(w_1, w_2) \\in W \\\\\n", " &(1-\\delta) u_1(a) + \\delta w_1 \\geq (1-\\delta) u_1(a_{-1}) + \\delta \\underline{w}_1 \\\\\n", " &(1-\\delta) u_2(a) + \\delta w_2 \\geq (1-\\delta) u_2(a_{-2}) + \\delta \\underline{w}_2\n", "\\end{align*}\n", "\n", "The three constraints just correspond to the constraints described in our $\\mathcal{B}$ operator. The first specifies that we are picking continuation values from the set $W$ and the next two insure that the continuation values are incentive compatible given the specified action.\n", "\n", "In order to apply the standard linear programming routines, we need to change this problem into the form\n", "\n", "\\begin{align*}\n", " \\min_x \\; & c^T x \\\\\n", " &\\text{subject to } \\\\\n", " &Ax \\leq b\n", "\\end{align*}\n", "\n", "The following observations guide us.\n", "\n", "1) $\\max_w h_i \\cdot ((1-\\delta) u(a) + \\delta w)$ produces the same optimal solution, $w^*$, as $\\min_w -h_i \\cdot ((1-\\delta) u(a) + \\delta w)$.\n", "\n", "2) Additionally, $\\min_w h_i \\cdot (u(a) + \\delta w)$ produces the same optimal solution, $w^*$, as $\\min_w h_i \\cdot \\delta w$.\n", "\n", "3) $w \\in W$ is equivalent to $H \\cdot w \\leq C$ (where $C$ are our hyperplane levels and $H$ are our subgradients).\n", "\n", "4) $(1-\\delta) u_i(a) + \\delta w_i \\geq (1-\\delta) u^*_i(a_{-i}) + \\delta \\underline{w}_i$ can be rewritten as $-\\delta w_i \\leq (1-\\delta) (u_i(a) - u^*_i(a_{-i})) - \\delta \\underline{w}_i$.\n", "\n", "Using these observations, we now specify the values for $c, x, A, b$ that relate the standard linear programming description to our specific linear program.\n", "\n", "* Variable we maximize over is $x = \\begin{bmatrix} w_1 \\\\ w_2 \\end{bmatrix}$\n", "* The objective vector will be $c^T = \\begin{bmatrix} -h_1 & -h_2 \\end{bmatrix}$\n", "* $A$ and $b$ are then made up of combinations of the matrices and vectors from the constraints. Let $N$ be the number of subgradients used in the approximation, let $h^n_i$ denote the $i$th element of the $n$th subgradient (i.e. $H_{n, i}$), and let $c_i$ denote the $i$th element of the hyperplane level vector (i.e. $C_i$) then:\n", " - $A = \\begin{bmatrix} h^1_1 & h^1_2 \\\\ h^2_1 & h^2_2 \\\\ \\dots \\\\ h^N_1 & h^N_2 \\\\ -\\delta & 0 \\\\ 0 & -\\delta \\end{bmatrix}$\n", " - $b = \\begin{bmatrix} c_1 \\\\ c_2 \\\\ \\dots \\\\ c_N \\\\ (1-\\delta) (u_1(a) - u^*_1(a_{-1})) - \\delta \\underline{w}_1 \\\\ (1-\\delta) (u_2(a) - u^*_2(a_{-2})) - \\delta \\underline{w}_2 \\end{bmatrix}$.\n", " - It is important to note that the vector $b$ depends on $a$ -- This means that the vector $b$ will change as we iterate over different actions. The dependence of $c^T$ on $h_i$ implies that it will also change as we iterate over the different subgradients.\n", "\n", "The functions which implement the details of these steps can be found in the [GameTheory.jl](https://github.com/QuantEcon/GameTheory.jl) library. Applying these steps repeatedly is the basis for the outer hyperplane approximation theorem we have been discussing. We can see the output of this below." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RepeatedGame{2, Float64}(2×2 NormalFormGame{2, Float64}, 0.75)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pd_payoff = [9.0 1.0;\n", " 10.0 3.0]\n", "\n", "A = Player(pd_payoff)\n", "B = Player(pd_payoff)\n", "\n", "pd = NormalFormGame((A, B))\n", "rpd = RepeatedGame(pd, 0.75)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now call the `outerapproximation` function that applies our algorithm. We include the `verbose=true` argument in order to watch the algorithm converge.\n", "\n", "In the printouts below, the left entry records the absolute changes in the hyperplane levels $C$ and $C'$ -- Evidently, the longer we iterate, the closer the two sets of hyperplane levels become. The right entry records a tuple $(\\underline{w}_1, \\underline{w}_2)$ -- As the set shrinks, these objects grow monotonically larger. That can be interpreted as occurring because the potential punishments available become weaker as we iterate." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "10\t0.08865814883358292\t(2.709875698216042, 2.7098756982160457)\n", "20\t0.0049926519684553305\t(2.983662080863912, 2.9836620808639154)\n", "30\t0.0002811537800662123\t(2.9990799543504063, 2.99907995435041)\n", "40\t1.583275753036517e-5\t(2.999948188995776, 2.9999481889957798)\n", "50\t8.915982254720234e-7\t(2.9999970823402498, 2.9999970823402533)\n", "60\t5.020902937857841e-8\t(2.999999835696323, 2.9999998356963267)\n" ] } ], "source": [ "hp_pts = outerapproximation(rpd; nH=64, maxiter=500, tol=1e-8,\n", " verbose=true, nskipprint=10);" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "editable": false, "responsive": true, "scrollZoom": true, "showLink": false, "staticPlot": false }, "data": [ { "mode": "lines+markers", "type": "scatter", "x": [ 9.4200627, 9.8030172, 3, 3, 6.8882022, 9, 9.4200627 ], "y": [ 6.8882022, 3, 3, 9.8030172, 9.4200627, 9, 6.8882022 ] } ], "frames": [], "layout": { "autosize": false, "height": 500, "margin": { "b": 50, "l": 50, "r": 50, "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": "Set of Subgame Perfect Values", "width": 700, "xaxis": { "range": [ 0, 15 ], "title": { "text": "w_1" } }, "yaxis": { "range": [ 0, 15 ], "title": { "text": "w_2" } } } }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "data: [\n", " \"scatter with fields mode, type, x, and y\"\n", "]\n", "\n", "layout: \"layout with fields autosize, height, margin, template, title, width, xaxis, and yaxis\"\n", "\n" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Add the first point to the bottom as well so that\n", "# the polygon connects\n", "plot_pts = vcat(hp_pts, hp_pts[1, :]')\n", "\n", "plot(scatter(;x=plot_pts[:, 1], y=plot_pts[:, 2], mode=\"lines+markers\"),\n", " Layout(;xaxis_range=[0, 15], yaxis_range=[0, 15],\n", " title=\"Set of Subgame Perfect Values\",\n", " xaxis_title=\"w_1\", yaxis_title=\"w_2\",\n", " autosize=false, height=500, width=700))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The approximation of the set of subgame perfect equilibrium values are presented above.\n", "\n", "There are several things to take note of:\n", " * The criminals can sustain silence (The (9, 9) payoff is an element of the set)\n", " * One of the criminals could possibly do better than the silence payoff though the other would do worse.\n", " * The worst case punishments in this case correspond to the Nash equilibrium -- This is not always the case. Sometimes lower payoffs can be sustained." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We could think about varying the discount factor. How would this change the set of achievable values?" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "pd_payoff = [9.0 1.0\n", " 10.0 3.0]\n", "\n", "A = Player(pd_payoff)\n", "B = Player(pd_payoff)\n", "\n", "pd = NormalFormGame((A, B))\n", "rpd1 = RepeatedGame(pd, 0.9)\n", "rpd2 = RepeatedGame(pd, 0.2475)\n", "\n", "hp_pts1 = outerapproximation(rpd1; nH=128, maxiter=750, tol=1e-8);\n", "hp_pts2 = outerapproximation(rpd2; nH=128, maxiter=750, tol=1e-8);" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "editable": false, "responsive": true, "scrollZoom": true, "showLink": false, "staticPlot": false }, "data": [ { "mode": "lines+markers", "name": "High Discount", "type": "scatter", "x": [ 9.6311103, 9.8030172, 2.9999999, 2.9999999, 4.7453999, 9, 9.6311103 ], "y": [ 4.7453999, 2.9999999, 2.9999999, 9.8030172, 9.6311103, 9, 4.7453999 ] }, { "mode": "lines+markers", "name": "Low Discount", "type": "scatter", "x": [ 9.5081247, 9.5494366, 3, 3, 3.8409237, 9, 9.5081247 ], "y": [ 3.8409237, 3, 3, 9.5494366, 9.5081247, 9, 3.8409237 ] } ], "frames": [], "layout": { "autosize": false, "height": 500, "margin": { "b": 50, "l": 50, "r": 50, "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": "Set of Subgame Perfect Values", "width": 700, "xaxis": { "range": [ 0, 12 ], "title": { "text": "w_1" } }, "yaxis": { "range": [ 0, 12 ], "title": { "text": "w_2" } } } }, "text/html": [ "\n", " \n", "\n" ], "text/plain": [ "data: [\n", " \"scatter with fields mode, name, type, x, and y\",\n", " \"scatter with fields mode, name, type, x, and y\"\n", "]\n", "\n", "layout: \"layout with fields autosize, height, margin, template, title, width, xaxis, and yaxis\"\n", "\n" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pts_1 = vcat(hp_pts1, hp_pts1[1, :]')\n", "t1 = scatter(;x=pts_1[:, 1], y=pts_1[:, 2], mode=\"lines+markers\", name=\"High Discount\")\n", "pts_2 = vcat(hp_pts2, hp_pts2[1, :]')\n", "t2 = scatter(;x=pts_2[:, 1], y=pts_2[:, 2], mode=\"lines+markers\", name=\"Low Discount\")\n", "\n", "plot([t1, t2],\n", " Layout(;xaxis_range=[0, 12], yaxis_range=[0, 12],\n", " title=\"Set of Subgame Perfect Values\",\n", " xaxis_title=\"w_1\", yaxis_title=\"w_2\",\n", " autosize=false, height=500, width=700))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "While the differences themselves are pretty small, it does appear that high discount factor supports a slightly larger set of equilibrium though (which isn't surprising)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Deducing SPE strategies\n", "\n", "In addition to wanting SPE values, we also want strategy profiles that attain them. Some of these are obvious -- For example, (9, 9) is sustained by maintaining silence and (3, 3) is sustained by always betraying. Others are less obvious and involve mixtures of silence and betrayal.\n", "\n", "Here is how APS would deduce a SPE equilbrium strategy profile associated with a SPE value profile $v\\in V$.\n", "\n", "Let $s \\in U[0,1]$ be the uniform random variable used to effect public randomization and let\n", "$V$ be the set of SPE values. \n", "\n", "Start with two $v$s that are extreme points of the final outer hyperplane approximation. \n", "Let $v_1 = (1-\\delta) u(a_1) + \\delta v_1'$ and for let $v_2 = (1-\\delta) u(a_2) + \\delta v_2'$ be two such SPE values with associated first period actions and continuation value pairs $(a_1, v_1')$, $(a_2,v_2')$, respectively. Because $v_1$ and $v_2$ are values obtained as extreme points from the outer hyperplane approximation, they use no public randomization. The linear programming algorithm that produces the outer hyperplane approximation computes pairs $(a_1, v_1')$, $(a_2,v_2')$ that attain these $v$'s.\n", "\n", "Now we activate public randomization.\n", "\n", "For probability $p \\in [0,1]$, we obtain a continuation value profile $v \\in V$ from \n", "an appropriate version of the equality\n", "\n", "$$ v = p [ (1-\\delta) u(a_1) + \\delta v_1'] + (1-p) [ (1-\\delta) u(a_2) + \\delta v_2'] $$\n", "\n", "The value profile $v$ is then attained by a strategy profile that can be represented recursively with the pair of functions\n", "\n", "$$ a = f (v,s) $$\n", "\n", "$$ v' = g( v, a, s) $$\n", "\n", "where $s \\in [0,1]$ is a realization of the public random variable.\n", "\n", "If we iterate these functions starting from a SPE value profile $v_0 \\in V$, we obtain a sequence of functions representing a SPE strategy profile that attains $v_0$:\n", "\n", "$$ a_0 = \\tilde f_0(a_0, s_0, v_0) $$\n", "\n", "$$ a_t = \\tilde f_t (a^{t-1}, s^t, v_0) , \\quad t \\geq 1 $$\n", "\n", "Here $s^t $ denotes the history $s_t, s_{t-1}, \\ldots, s_0$ and $a^{t-1}$\n", "denotes the history $a_{t-1}, \\ldots, a_0$. \n", "\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### References\n", "\n", "Abreu, Dilip, David Pearce, and Ennio Stacchetti, 1986. Optimal Cartel Equilibria with Imperfect Monitoring, _Journal of Economic Theory_, 39, 251-269.\n", "\n", "Abreu, Dilip, David Pearce, and Ennio Stacchetti, 1990. Toward a Theory of Discounted Repeated Games with Imperfect Monitoring, _Econometrica_, 58, 1041-1063.\n", "\n", "Judd,Kenneth, Sevin Yeltekin, and James Conklin, 2003. Computing Supergame Equilibria, _Econometrica_, 71(4), pages 1239-1254, 07.\n", "\n" ] } ], "metadata": { "@webio": { "lastCommId": "a6e5c4ef14a24b60816bf193476752f0", "lastKernelId": "11f65e91-a7b5-4769-a651-a2eedf714205" }, "anaconda-cloud": {}, "kernelspec": { "display_name": "Julia 1.8.5", "language": "julia", "name": "julia-1.8" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }