|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "7779ca3d-99a8-4014-a001-4b4c9314e39f", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "> Obtain the full game representations $(A, B)$ for the zero sum games with row play payoff matrix given by:\n", |
| 9 | + "\n", |
| 10 | + " 1. $A =\\begin{pmatrix}1 & 3\\\\ -1 & 4\\end{pmatrix}\\qquad B =\\begin{pmatrix}-1 & -3\\\\ 1 & -4\\end{pmatrix}$" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": 12, |
| 16 | + "id": "f365cfb4-38bb-4605-b5cd-e4476bd60978", |
| 17 | + "metadata": {}, |
| 18 | + "outputs": [ |
| 19 | + { |
| 20 | + "data": { |
| 21 | + "text/plain": [ |
| 22 | + "Zero sum game with payoff matrices:\n", |
| 23 | + "\n", |
| 24 | + "Row player:\n", |
| 25 | + "[[ 1 3]\n", |
| 26 | + " [-1 4]]\n", |
| 27 | + "\n", |
| 28 | + "Column player:\n", |
| 29 | + "[[-1 -3]\n", |
| 30 | + " [ 1 -4]]" |
| 31 | + ] |
| 32 | + }, |
| 33 | + "execution_count": 12, |
| 34 | + "metadata": {}, |
| 35 | + "output_type": "execute_result" |
| 36 | + } |
| 37 | + ], |
| 38 | + "source": [ |
| 39 | + "import nashpy as nash\n", |
| 40 | + "import numpy as np\n", |
| 41 | + "\n", |
| 42 | + "A = np.array(((1, 3), (-1, 4)))\n", |
| 43 | + "game = nash.Game(A)\n", |
| 44 | + "game" |
| 45 | + ] |
| 46 | + }, |
| 47 | + { |
| 48 | + "cell_type": "markdown", |
| 49 | + "id": "206da237-a337-434b-b5f6-0b29ef992687", |
| 50 | + "metadata": {}, |
| 51 | + "source": [ |
| 52 | + " 2. $A =\\begin{pmatrix}1 & -2\\\\ -1 & 2\\end{pmatrix}\\qquad B =\\begin{pmatrix}-1 & 2\\\\ 1 & -2\\end{pmatrix}$" |
| 53 | + ] |
| 54 | + }, |
| 55 | + { |
| 56 | + "cell_type": "code", |
| 57 | + "execution_count": 13, |
| 58 | + "id": "a8698c05-a30b-40e9-864b-081fbd31da42", |
| 59 | + "metadata": {}, |
| 60 | + "outputs": [ |
| 61 | + { |
| 62 | + "data": { |
| 63 | + "text/plain": [ |
| 64 | + "Zero sum game with payoff matrices:\n", |
| 65 | + "\n", |
| 66 | + "Row player:\n", |
| 67 | + "[[ 1 -2]\n", |
| 68 | + " [-1 2]]\n", |
| 69 | + "\n", |
| 70 | + "Column player:\n", |
| 71 | + "[[-1 2]\n", |
| 72 | + " [ 1 -2]]" |
| 73 | + ] |
| 74 | + }, |
| 75 | + "execution_count": 13, |
| 76 | + "metadata": {}, |
| 77 | + "output_type": "execute_result" |
| 78 | + } |
| 79 | + ], |
| 80 | + "source": [ |
| 81 | + "A = np.array(((1, -2), (-1, 2)))\n", |
| 82 | + "B = np.array(((-1, 2), (1, -2)))\n", |
| 83 | + "game = nash.Game(A, B)\n", |
| 84 | + "game" |
| 85 | + ] |
| 86 | + }, |
| 87 | + { |
| 88 | + "cell_type": "markdown", |
| 89 | + "id": "07878c15-fb5d-4840-9c0d-e3fe95f1226a", |
| 90 | + "metadata": {}, |
| 91 | + "source": [ |
| 92 | + " 3. $A =\\begin{pmatrix}1 & -2 & 4\\\\ 2 & -1 & 2\\\\ 7 & -7 & 6\\end{pmatrix}\\qquad B =\\begin{pmatrix}-1 & 2 & -4\\\\ -2 & 1 & -2\\\\ -7 & 7 & -6\\end{pmatrix}$" |
| 93 | + ] |
| 94 | + }, |
| 95 | + { |
| 96 | + "cell_type": "code", |
| 97 | + "execution_count": 14, |
| 98 | + "id": "fc5f7b5a-91ba-4358-b9f6-0772033fcb8c", |
| 99 | + "metadata": {}, |
| 100 | + "outputs": [ |
| 101 | + { |
| 102 | + "data": { |
| 103 | + "text/plain": [ |
| 104 | + "Zero sum game with payoff matrices:\n", |
| 105 | + "\n", |
| 106 | + "Row player:\n", |
| 107 | + "[[ 1 -2 4]\n", |
| 108 | + " [ 2 -1 2]\n", |
| 109 | + " [ 7 -7 6]]\n", |
| 110 | + "\n", |
| 111 | + "Column player:\n", |
| 112 | + "[[-1 2 -4]\n", |
| 113 | + " [-2 1 -2]\n", |
| 114 | + " [-7 7 -6]]" |
| 115 | + ] |
| 116 | + }, |
| 117 | + "execution_count": 14, |
| 118 | + "metadata": {}, |
| 119 | + "output_type": "execute_result" |
| 120 | + } |
| 121 | + ], |
| 122 | + "source": [ |
| 123 | + "A = np.array(((1, -2, 4), (2, -1, 2), (7, -7, 6)))\n", |
| 124 | + "B = np.array(((-1, 2, -4), (-2, 1, -2), (-7, 7, -6)))\n", |
| 125 | + "game = nash.Game(A, B)\n", |
| 126 | + "game" |
| 127 | + ] |
| 128 | + }, |
| 129 | + { |
| 130 | + "cell_type": "markdown", |
| 131 | + "id": "7bafa50e-ac87-4ad8-a5ed-17a5b550066c", |
| 132 | + "metadata": {}, |
| 133 | + "source": [ |
| 134 | + "> `3.` Consider the game described as follows:\n", |
| 135 | + "\n", |
| 136 | + " > An airline loses two suitcases belonging to two different travelers. Both suitcases have the same value. An airline manager tasked to settle the claims of both travelers explains that the airline is liable for a maximum of £5 per suitcase. \n", |
| 137 | + "\n", |
| 138 | + " > To determine an honest appraised value of the suitcases, the manager separates both travelers and asks them to write down the amount of their value at no less than £2 and no larger than £5 (to the single dollar):\n", |
| 139 | + " > - If both write down the same number, that number as the true dollar value of both suitcases and reimburse both travelers that amount. \n", |
| 140 | + " > - However, if one writes down a smaller number than the other, this smaller number will be taken as the true dollar value, and both travelers will receive that amount along with a bonus/malus: £2 extra will be paid to the traveler who wrote down the lower value and a £2 deduction will be taken from the person who wrote down the higher amount. \n", |
| 141 | + " \n", |
| 142 | + " > Represent this as a Normal Form Game.\n", |
| 143 | + " \n", |
| 144 | + " \n", |
| 145 | + "$$\n", |
| 146 | + "A = \\begin{pmatrix}\n", |
| 147 | + "2 & 4 & 4 & 4\\\\\n", |
| 148 | + "0 & 3 & 5 & 5\\\\\n", |
| 149 | + "0 & 1 & 4 & 6\\\\\n", |
| 150 | + "0 & 1 & 2 & 5\n", |
| 151 | + "\\end{pmatrix}\n", |
| 152 | + "\\qquad\n", |
| 153 | + "B = \\begin{pmatrix}\n", |
| 154 | + "2 & 0 & 0 & 0\\\\\n", |
| 155 | + "4 & 3 & 1 & 1\\\\\n", |
| 156 | + "4 & 5 & 4 & 2\\\\\n", |
| 157 | + "4 & 5 & 6 & 5\n", |
| 158 | + "\\end{pmatrix}\n", |
| 159 | + "$$" |
| 160 | + ] |
| 161 | + }, |
| 162 | + { |
| 163 | + "cell_type": "code", |
| 164 | + "execution_count": 15, |
| 165 | + "id": "f1922cd9-a1ca-40ca-b1ad-c09de6b46a9d", |
| 166 | + "metadata": {}, |
| 167 | + "outputs": [ |
| 168 | + { |
| 169 | + "data": { |
| 170 | + "text/plain": [ |
| 171 | + "Bi matrix game with payoff matrices:\n", |
| 172 | + "\n", |
| 173 | + "Row player:\n", |
| 174 | + "[[2 4 4 4]\n", |
| 175 | + " [0 3 5 5]\n", |
| 176 | + " [0 1 4 6]\n", |
| 177 | + " [0 1 2 5]]\n", |
| 178 | + "\n", |
| 179 | + "Column player:\n", |
| 180 | + "[[2 0 0 0]\n", |
| 181 | + " [4 3 1 1]\n", |
| 182 | + " [4 5 4 2]\n", |
| 183 | + " [4 5 6 5]]" |
| 184 | + ] |
| 185 | + }, |
| 186 | + "execution_count": 15, |
| 187 | + "metadata": {}, |
| 188 | + "output_type": "execute_result" |
| 189 | + } |
| 190 | + ], |
| 191 | + "source": [ |
| 192 | + "A = np.array(((2, 4, 4, 4), (0, 3, 5, 5), (0, 1, 4, 6), (0, 1, 2,5)))\n", |
| 193 | + "B = np.array(((2, 0, 0, 0), (4, 3, 1, 1), (4, 5, 4, 2), (4, 5, 6, 5)))\n", |
| 194 | + "game = nash.Game(A, B)\n", |
| 195 | + "game" |
| 196 | + ] |
| 197 | + }, |
| 198 | + { |
| 199 | + "cell_type": "code", |
| 200 | + "execution_count": null, |
| 201 | + "id": "c8b6f40c-b1c9-4b63-b373-0c42436d8238", |
| 202 | + "metadata": {}, |
| 203 | + "outputs": [], |
| 204 | + "source": [] |
| 205 | + } |
| 206 | + ], |
| 207 | + "metadata": { |
| 208 | + "kernelspec": { |
| 209 | + "display_name": "Python 3 (ipykernel)", |
| 210 | + "language": "python", |
| 211 | + "name": "python3" |
| 212 | + }, |
| 213 | + "language_info": { |
| 214 | + "codemirror_mode": { |
| 215 | + "name": "ipython", |
| 216 | + "version": 3 |
| 217 | + }, |
| 218 | + "file_extension": ".py", |
| 219 | + "mimetype": "text/x-python", |
| 220 | + "name": "python", |
| 221 | + "nbconvert_exporter": "python", |
| 222 | + "pygments_lexer": "ipython3", |
| 223 | + "version": "3.11.4" |
| 224 | + } |
| 225 | + }, |
| 226 | + "nbformat": 4, |
| 227 | + "nbformat_minor": 5 |
| 228 | +} |
0 commit comments