{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "

Finding all equilibria of a two-player game: Bagwell's commitment example

\n", "Theodore L. Turocy
\n", "University of East Anglia\n", "

\n", "

EC'16 Workshop\n", "24 July 2016

" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import gambit" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Bagwell (1993) pointed out that the usual story of Stackelberg commitment to an action depends critically on the observability of the commitment to the action. If there is any chance that the action might be misinterpreted, then the only equilibrium *in pure strategies* is the equilibrium of the simultaneous-move game. He noted however that if the chance of misinterpreting the action is sufficiently small, then there is an equilibrium in mixed strategies in which the player chooses the Stackelberg action with probability arbitarily close to one.\n", "\n", "We'll explore this example numerically, and use it as a vehicle for showing how to compute all equilibria of a two-player game." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We'll start with a quick overview of the \"base\" simultaneous-move game used by Bagwell in his example. First we'll create the payoff matrix for the \"leader\" player:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([[5, 3],\n", " [6, 4]])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy\n", "L = numpy.array([[5,3], [6,4]])\n", "L" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And the payoff matrix for the \"follower\" player:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "array([[2, 1],\n", " [3, 4]])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "F = numpy.array([[2,1], [3,4]])\n", "F" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The constructor `Game.from_arrays` creates a game in normal form from a collection of payoff matrices, one per player." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "

\n", "
SC
S5,23,1
C6,34,4
\n" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = gambit.Game.from_arrays(L, F)\n", "g.players[0].label = \"Leader\"\n", "g.players[0].strategies[0].label = \"S\"\n", "g.players[0].strategies[1].label = \"C\"\n", "g.players[1].label = \"Follower\"\n", "g.players[1].strategies[0].label = \"S\"\n", "g.players[1].strategies[1].label = \"C\"\n", "import IPython.display; IPython.display.HTML(g.write('html'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we have set up the row player as the would-be \"Leader\" player (the one who would have an incentive to commit). The strategy \"S\" (for both players) would be the subgame-perfect outcome if the row player had the opportunity to commit, where as we can see that \"C\" is going to be the unique equilibrium (obtainable by iterative elimination of strictly dominated strategies!) if players choose simultaneously." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Aside: dominated strategies and restrictions of a game\n", "\n", "Did someone say something about dominated strategies? Gambit 16 contains new features for manipulating dominance information. (These do not yet appear in the documentation for 16.0.0.)\n", "\n", "The first concept to introduce is the `StrategySupportProfile`. (This is a name we believe we have coined, because we cannot think of a standard termfor it. If you know of one, please suggest!) A support profile is a subset of strategies of a game, subject to the requirement that each player must have at least one strategy in the profile.\n", "\n", "The function `Game.support_profile()` returns a support profile, initialized to include all strategies in the game." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[, , , ]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sp = g.support_profile()\n", "sp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The function `StrategySupportProfile.undominated()` determines which strategies are (strictly) dominated (taking into account only those in the SupportProfile), and returns a new `StrategySupportProfile` containing only the undominated ones.\n", "\n", "As we expect here, strategy `S` is dominated for the Leader player, so it does not appear in the returned support profile." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[, , ]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sp.undominated()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Iterating on this allows you to implement iterative elimination of strictly dominated strategies, to whatever depth you would like." ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "[, ]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sp.undominated().undominated()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Of course after two rounds, we run out of things to eliminate!" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sp.undominated().undominated().undominated() == sp.undominated().undominated()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The other useful concept is the `StrategicRestriction`. A `StrategicRestriction` is a full-fledged game in its own right, derived from another game by using only a subset of its strategies. `StrategySupportProfile` objects have a `.restrict()` member that returns a restricted game." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "NFG 1 R \"\" { \"Leader\" \"Follower\" }\n", "\n", "{ { \"C\" }\n", "{ \"C\" }\n", "}\n", "\"\"\n", "\n", "4 4 \n" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rest = sp.undominated().undominated().restrict()\n", "rest" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A `StrategicRestriction` remembers its \"parent\" or \"unrestricted\" game. So while a `StrategicRestriction` is itself a game that can be manipulated in its own right, it is also possible to map e.g. mixed strategy profiles defined on a restriction of a game, to a mixed strategy profile on the corresponding unrestricted game." ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "NFG 1 R \"\" { \"Leader\" \"Follower\" }\n", "\n", "{ { \"S\" \"C\" }\n", "{ \"S\" \"C\" }\n", "}\n", "\"\"\n", "\n", "{\n", "{ \"\" 5, 2 }\n", "{ \"\" 6, 3 }\n", "{ \"\" 3, 1 }\n", "{ \"\" 4, 4 }\n", "}\n", "1 2 3 4 " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rest.unrestrict()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rest.unrestrict() == g" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The game with imperfectly-observed commitment\n", "\n", "Back to the main thrust of this example. We now want to allow the Leader player to move first. The Follower player, however, will observe the Leader's choice only with noise. If Leader chooses `S`, then Follower will see a signal `s` with some probability $p$, and a signal `c` otherwise. Similarly, if Leader chooses `C`, then follower will see a signal `c` with the same probability $p$, and a signal `s` otherwise. If $p=1$ then we have the standard case of perfectly-observed Stackelberg-style commitment.\n", "\n", "We've prepared in advance an extensive game file with $p=\\frac{99}{100}$. Here is the extensive game in pictures.\n", "
\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "EFG 2 R \"Bagwell Commitment and Unobservability Example\" { \"Player 1\" \"Player 2\" }\n", "\"Stackelberg game with imperfectly observed commitment, from Bagwell (1993)\"\n", "\n", "p \"\" 1 1 \"\" { \"S\" \"C\" } 0\n", "c \"\" 1 \"\" { \"s\" 99/100 \"c\" 1/100 } 0\n", "p \"\" 2 1 \"\" { \"S\" \"C\" } 0\n", "t \"\" 1 \"SS\" { 5, 2 }\n", "t \"\" 2 \"SC\" { 3, 1 }\n", "p \"\" 2 2 \"\" { \"S\" \"C\" } 0\n", "t \"\" 1 \"SS\" { 5, 2 }\n", "t \"\" 2 \"SC\" { 3, 1 }\n", "c \"\" 2 \"\" { \"s\" 1/100 \"c\" 99/100 } 0\n", "p \"\" 2 1 \"\" { \"S\" \"C\" } 0\n", "t \"\" 3 \"CS\" { 6, 3 }\n", "t \"\" 4 \"CC\" { 4, 4 }\n", "p \"\" 2 2 \"\" { \"S\" \"C\" } 0\n", "t \"\" 3 \"CS\" { 6, 3 }\n", "t \"\" 4 \"CC\" { 4, 4 }" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g = gambit.Game.read_game(\"bagwell.efg\")\n", "g" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this example, we want to be sure we compute all equilibria. The `lcp_solve` method we used in the poker example computes \"most\" equilibria. For many games, it actually finds all of them, but there do exist games for which it will miss some out. Fortunately, for two-player games, there is an enumeration method which is guaranteed to find all of them. This is implemented as `gambit.nash.enummixed_solve()`.\n", "\n", "From Gambit 16, this method (optionally) uses lrs by David Avis: http://cgm.cs.mcgill.ca/~avis/C/lrs.html, which is an excellent package (and much faster than the Gambit version written originally in the mid-1990s!). We'll use it for this example (although for games of this size there's no meaningful speed differential.)" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "3" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = gambit.nash.enummixed_solve(g, use_lrs=True)\n", "len(result)" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "So, we have multiple equilibria. Let's inspect them. This method actually returns mixed strategies on the strategic game (a version that uses the sequence form to do enumeration directly on the extensive game is forthcoming!):" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[0,1\\right],\\left[0,0,0,1\\right]\\right]$" ], "text/plain": [ "[[Fraction(0, 1), Fraction(1, 1)], [Fraction(0, 1), Fraction(0, 1), Fraction(0, 1), Fraction(1, 1)]]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can view the behaviour equivalent using `.as_behavior()`, which does the Kuhn's Theorem calculation for us. The first equilibrium is in pure strategies, and corresponds to the simultaneous-move outcome:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[\\left[0,1\\right]\\right],\\left[\\left[0,1\\right],\\left[0,1\\right]\\right]\\right]$" ], "text/plain": [ "[[[Fraction(0, 1), Fraction(1, 1)]], [[Fraction(0, 1), Fraction(1, 1)], [Fraction(0, 1), Fraction(1, 1)]]]" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[0].as_behavior()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The second equilibrium is a low-commitment equilibrium: the probability of choosing the Stackelberg action $S$ is small:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[\\left[\\frac{1}{100},\\frac{99}{100}\\right]\\right],\\left[\\left[\\frac{25}{49},\\frac{24}{49}\\right],\\left[0,1\\right]\\right]\\right]$" ], "text/plain": [ "[[[Fraction(1, 100), Fraction(99, 100)]], [[Fraction(25, 49), Fraction(24, 49)], [Fraction(0, 1), Fraction(1, 1)]]]" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[1].as_behavior()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And the third equilibrium is a high-commitment equilibrium: the probability of choosing the Stackelberg action $S$ is large. So while it is indeed true that there is no pure-strategy equilibrium with full commitment, there is a mixed-strategy equilibrium with a high probability of commitment." ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[\\left[\\frac{99}{100},\\frac{1}{100}\\right]\\right],\\left[\\left[1,0\\right],\\left[\\frac{24}{49},\\frac{25}{49}\\right]\\right]\\right]$" ], "text/plain": [ "[[[Fraction(99, 100), Fraction(1, 100)]], [[Fraction(1, 1), Fraction(0, 1)], [Fraction(24, 49), Fraction(25, 49)]]]" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[2].as_behavior()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can then make a plot, in which we vary the probability the signal \"correctly\" transmits Leader's action, and ask what are the probabilities the leader plays $S$ as a function (technically, correspondance) of that accuracy." ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [], "source": [ "probs = [ gambit.Rational(i, 100) for i in xrange(99, 0, -1) ]\n", "eqa = [ ]\n", "for prob in probs:\n", " g.players.chance.infosets[0].actions[0].prob = prob\n", " g.players.chance.infosets[0].actions[1].prob = 1-prob\n", " g.players.chance.infosets[1].actions[0].prob = 1-prob\n", " g.players.chance.infosets[1].actions[1].prob = prob\n", " eqa.append([ eqm.as_behavior()[g.players[0].infosets[0].actions[0]] \n", " for eqm in gambit.nash.enummixed_solve(g, use_lrs=True) ])\n", " " ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYkAAAEPCAYAAAC3NDh4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucFOWd7/EPMMqwRmEc3bhRFDOioijxBviKwdmoDBGN\nJqsiWRVjYhKNQIzJceWyjBfOievmIriJSbwkG93oJmuyOrgy7q4Dmgh4IVwiYJwjCrKaIy9AJQEF\n+vzxq6Zrarpn6umpqq6u/r5fr3lNVU111dPPzNTTv+cKIiIiIiIiIiIiIiIiIiIiIiIiIiIi0oP7\ngLeAVT2cMw/4A7ACOCmJRImISDp8AnvwlyokzgUe97bHAEuSSJSIiKTHMEoXEncDk3z7a4EPx50g\nEREprn+lExBwKLDBt78ROKxCaRERqXlpKyT6eV9+eyqREBERgbpKJyBgIzDUt38YsCl40kcOOSS3\n6c03E0uUiEhGdAJHubwgbZHEo8AV3vZYYCvWG6qLTW++SQ66fV3S2MicM89k5vjxLGprI5fLZf5r\nzpw5FU9DWr6UF8qLWs6LRW1tzBw/niuGDGEmsCjwfJzV0gLQ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JB+fz4PrYO+8VYFPBekXNKvXYSVth+gH2Cvzlw\n3gqs6u/3WBvLM97xD7zXzscK4z9hU2Tfgz2wV3rn/MhL381YofgW1sidv3+x32ux97IC+z3/Dotm\n5mHVbS9iBc0fgc+UeK8iIqnxF1i9fjDCcLGf71rPAR/ra6JERKTyzsY+/U/r43UexD69r8GiExER\nERERERERERERERERERERERERERGpvP8PtPGt/0kl5IkAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pylab\n", "%matplotlib inline\n", "for (prob, solns) in zip(probs, eqa):\n", " pylab.plot([ prob for eqm in solns ], solns, 'ro')\n", "pylab.xlabel(\"Probability signal is accurate\")\n", "pylab.ylabel(\"Equilibrium probability of choosing $S$\")\n", "pylab.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "That's an interesting enough graph. It shows there is a \"high-commitment\" equilibrium as long as $p\\geq \\frac{3}{4}$, or $p\\leq \\frac{1}{4}$. However, game theorists will be surprised to see the two branches of the graph are not connected. After all, we are essentially perturbing the payoffs of the game continuously as we move along the horizontal axis.\n", "\n", "Let's have a closer look at the game when $p=\\frac{3}{4}$." ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "

Bagwell Commitment and Unobservability Example

\n", "
11122122
15,29/2,7/47/2,5/43,1
26,39/2,15/411/2,13/44,4
\n" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "g.players.chance.infosets[0].actions[0].prob = gambit.Rational(3,4)\n", "g.players.chance.infosets[0].actions[1].prob = gambit.Rational(1,4)\n", "g.players.chance.infosets[1].actions[0].prob = gambit.Rational(1,4)\n", "g.players.chance.infosets[1].actions[1].prob = gambit.Rational(3,4)\n", "IPython.display.HTML(g.write('html'))" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "3" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result = gambit.nash.enummixed_solve(g)\n", "len(result)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[0,1\\right],\\left[0,0,0,1\\right]\\right]$" ], "text/plain": [ "[[Fraction(0, 1), Fraction(1, 1)], [Fraction(0, 1), Fraction(0, 1), Fraction(0, 1), Fraction(1, 1)]]" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[0]" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[\\frac{1}{4},\\frac{3}{4}\\right],\\left[0,1,0,0\\right]\\right]$" ], "text/plain": [ "[[Fraction(1, 4), Fraction(3, 4)], [Fraction(0, 1), Fraction(1, 1), Fraction(0, 1), Fraction(0, 1)]]" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[1]" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$\\left[\\left[\\frac{3}{4},\\frac{1}{4}\\right],\\left[0,1,0,0\\right]\\right]$" ], "text/plain": [ "[[Fraction(3, 4), Fraction(1, 4)], [Fraction(0, 1), Fraction(1, 1), Fraction(0, 1), Fraction(0, 1)]]" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "result[2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We have three equilibria listed, but note that the second and third both involve the Follower (column) player choosing the same pure strategy (which is to respond to `s` with `S` and `c` with `C`). In the game, there is a degeneracy: Leader is indifferent between `S` and `C` when Follower chooses this strategy. You should be able to convince yourself that *any* probability distribution over `S` and `C` for Leader, with probabilities between $\\frac{1}{4}$ and $\\frac{3}{4}$ (on `S`) forms an equilibrium.\n", "\n", "The enumeration method in `gambit.nash.enummixed_solve` enumerates *extreme points* of the equilibrium set. In a two-player game, the set of equilibria can be expressed as a union of convex sets. There *is* support in Gambit for computing these convex sets - but it is not yet exposed directly via Python.\n", "\n", "What we will do instead is to write this game out to disk, and then use the Gambit command-line tools (via Jupyter's shell magic) to inspect the output." ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "collapsed": true }, "outputs": [], "source": [ "with file(\"bagwell-75.nfg\", \"w\") as f:\n", " f.write(g.write('nfg'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, we'll run the `gambit-enummixed` tool on the game, and we'll see we get the same equilibria out. The equilibria are written out in CSV for convenient parsing." ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Compute Nash equilibria by enumerating extreme points\n", "Gambit version 16.0.0, Copyright (C) 1994-2016, The Gambit Project\n", "Enumeration code based on lrslib 6.2,\n", "Copyright (C) 1995-2016 by David Avis (avis@cs.mcgill.ca)\n", "This is free software, distributed under the GNU GPL\n", "\n", "NE,0,1,0,0,0,1\n", "NE,1/4,3/4,0,1,0,0\n", "NE,3/4,1/4,0,1,0,0\n" ] } ], "source": [ "!gambit-enummixed bagwell-75.nfg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `-h` switch to any command-line tool gives a standard brief help synopsis." ] }, { "cell_type": "code", "execution_count": 27, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Compute Nash equilibria by enumerating extreme points\r\n", "Gambit version 16.0.0, Copyright (C) 1994-2016, The Gambit Project\r\n", "Enumeration code based on lrslib 6.2,\r\n", "Copyright (C) 1995-2016 by David Avis (avis@cs.mcgill.ca)\r\n", "This is free software, distributed under the GNU GPL\r\n", "\r\n", "Usage: gambit-enummixed [OPTIONS] [file]\r\n", "If file is not specified, attempts to read game from standard input.\r\n", "With no options, reports all Nash equilibria found.\r\n", "\r\n", "Options:\r\n", " -d DECIMALS compute using floating-point arithmetic;\r\n", " display results with DECIMALS digits\r\n", " -D don't eliminate dominated strategies first\r\n", " -L use lrslib for enumeration (experimental!)\r\n", " -c output connectedness information\r\n", " -h, --help print this help message\r\n", " -q quiet mode (suppresses banner)\r\n", " -v, --version print version information\r\n" ] } ], "source": [ "!gambit-enummixed -h" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The option `-c` (output connectnedness information) is the one we want; it'll tell us how the three extreme equilibria listed are structured." ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Compute Nash equilibria by enumerating extreme points\r\n", "Gambit version 16.0.0, Copyright (C) 1994-2016, The Gambit Project\r\n", "Enumeration code based on lrslib 6.2,\r\n", "Copyright (C) 1995-2016 by David Avis (avis@cs.mcgill.ca)\r\n", "This is free software, distributed under the GNU GPL\r\n", "\r\n", "NE,0,1,0,0,0,1\r\n", "NE,1/4,3/4,0,1,0,0\r\n", "NE,3/4,1/4,0,1,0,0\r\n", "convex-1,0,1,0,0,0,1\r\n", "convex-2,3/4,1/4,0,1,0,0\r\n", "convex-2,1/4,3/4,0,1,0,0\r\n" ] } ], "source": [ "!gambit-enummixed -c bagwell-75.nfg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The set of equilibria can be expressed as two convex components. One component is the isolated equilibrium in which Leader and Follower both play `C` (Follower playing this after both possible signals). The other component is the one we identified above: Follower responds to signal `s` with `S` and signal `c` with `C`, and Leader mixes between his two actions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Advice**: It is quite easy to write down games which have positive-dimensional equilibrium sets. Games in strategic form which derive from games in extensive form often have these naturally (because of off-path play), but equally we often write down games where the same payoff appears in multiple places in a game, making it rather easier to have degenerate situations arise. Support for identifying these situations in Gambit in two-player games is in good shape (especially once it will be possible to manipulate the above output directly in Python). Diagnosing these situations in games with three or more players is a bit more tricky, as we will see in a following thematic example." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.12" } }, "nbformat": 4, "nbformat_minor": 0 }