Skip to content

Commit dbd67e6

Browse files
committed
Add docs to index.
1 parent 08bd7fb commit dbd67e6

9 files changed

+655
-10
lines changed

docs/how-to/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ How to:
2525
obtain-a-repeated-game.rst
2626
use-moran-process-on-replacement-graph.rst
2727
use-moran-process-on-interaction-graph.rst
28+
use-imitation-dynamics.rst
29+
use-regret-minimization.rst

docs/how-to/solve-with-imitation-dynamics.rst renamed to docs/how-to/use-imitation-dynamics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _how-to-use-imitation-dynamics:
22

3-
Solve with Imitation Dynamics
4-
==============================
3+
Use Imitation Dynamics
4+
======================
55

66
One of the algorithms implemented in :code:`Nashpy` is called
77
:code:`imitation_dynamics()`, this is implemented as a method on the :code:`Game`
@@ -33,4 +33,4 @@ of the imitation dynamics algorithm::
3333
>>> threshold=0.3
3434
>>> ne_imitation_dynamics = rps.imitation_dynamics(population_size=population_size,iterations=iterations,random_seed=random_seed,threshold=threshold)
3535
>>> list(ne_imitation_dynamics)
36-
[(array([0., 1., 0.]), array([1., 0., 1.]))]
36+
[(array([0., 1., 0.]), array([1., 0., 1.]))]

docs/how-to/solve-with-regret-minimization.rst renamed to docs/how-to/use-regret-minimization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _how-to-use-regret-minimization:
22

3-
Solve with Regret Minimization
4-
==============================
3+
Use with Regret Minimization
4+
============================
55

66
One of the algorithms implemented in :code:`Nashpy` is called
77
:code:`regret_minimization()`, this is implemented as a method on the :code:`Game`

docs/text-book/imitation-dynamics.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Detailed Mathematical Model of Imitation Dynamics
2-
==================================================
1+
Imitation Dynamics
2+
==================
33

44
Introduction
55
------------
@@ -62,4 +62,4 @@ Using Nashpy
6262
------------
6363

6464
See :ref:`how-to-use-imitation-dynamics` for guidance of how to use Nashpy to
65-
simulation Imitation Dynamics.
65+
simulation Imitation Dynamics.

docs/text-book/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Nashpy Game Theory Text book
1919
replicator-dynamics.rst
2020
asymmetric-replicator-dynamics.rst
2121
moran-process.rst
22+
imitation-dynamics.rst
23+
regret_minimization.rst

docs/text-book/regret_minimization.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Regret Minimization in Game Theory
2-
==================================
1+
Regret Minimization
2+
===================
33

44
Introduction
55
------------

docs/text-book/solutions/.ipynb_checkpoints/best-responses-checkpoint.ipynb

Lines changed: 267 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
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": 3,
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": 3,
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+
"B = np.array(((-1, -3), (1, -4)))\n",
44+
"game = nash.Game(A, B)\n",
45+
"game"
46+
]
47+
},
48+
{
49+
"cell_type": "markdown",
50+
"id": "206da237-a337-434b-b5f6-0b29ef992687",
51+
"metadata": {},
52+
"source": [
53+
" 2. $A =\\begin{pmatrix}1 & -2\\\\ -1 & 2\\end{pmatrix}\\qquad B =\\begin{pmatrix}-1 & 2\\\\ 1 & -2\\end{pmatrix}$"
54+
]
55+
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": 5,
59+
"id": "a8698c05-a30b-40e9-864b-081fbd31da42",
60+
"metadata": {},
61+
"outputs": [
62+
{
63+
"data": {
64+
"text/plain": [
65+
"Zero sum game with payoff matrices:\n",
66+
"\n",
67+
"Row player:\n",
68+
"[[ 1 -2]\n",
69+
" [-1 2]]\n",
70+
"\n",
71+
"Column player:\n",
72+
"[[-1 2]\n",
73+
" [ 1 -2]]"
74+
]
75+
},
76+
"execution_count": 5,
77+
"metadata": {},
78+
"output_type": "execute_result"
79+
}
80+
],
81+
"source": [
82+
"A = np.array(((1, -2), (-1, 2)))\n",
83+
"B = np.array(((-1, 2), (1, -2)))\n",
84+
"game = nash.Game(A, B)\n",
85+
"game"
86+
]
87+
},
88+
{
89+
"cell_type": "markdown",
90+
"id": "07878c15-fb5d-4840-9c0d-e3fe95f1226a",
91+
"metadata": {},
92+
"source": [
93+
" 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}$"
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": 7,
99+
"id": "fc5f7b5a-91ba-4358-b9f6-0772033fcb8c",
100+
"metadata": {},
101+
"outputs": [
102+
{
103+
"data": {
104+
"text/plain": [
105+
"Zero sum game with payoff matrices:\n",
106+
"\n",
107+
"Row player:\n",
108+
"[[ 1 -2 4]\n",
109+
" [ 2 -1 2]\n",
110+
" [ 7 -7 6]]\n",
111+
"\n",
112+
"Column player:\n",
113+
"[[-1 2 -4]\n",
114+
" [-2 1 -2]\n",
115+
" [-7 7 -6]]"
116+
]
117+
},
118+
"execution_count": 7,
119+
"metadata": {},
120+
"output_type": "execute_result"
121+
}
122+
],
123+
"source": [
124+
"A = np.array(((1, -2, 4), (2, -1, 2), (7, -7, 6)))\n",
125+
"B = np.array(((-1, 2, -4), (-2, 1, -2), (-7, 7, -6)))\n",
126+
"game = nash.Game(A, B)\n",
127+
"game"
128+
]
129+
},
130+
{
131+
"cell_type": "markdown",
132+
"id": "7bafa50e-ac87-4ad8-a5ed-17a5b550066c",
133+
"metadata": {},
134+
"source": [
135+
"> `3.` Consider the game described as follows:\n",
136+
"\n",
137+
" > 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",
138+
"\n",
139+
" > 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",
140+
" > - If both write down the same number, that number as the true dollar value of both suitcases and reimburse both travelers that amount. \n",
141+
" > - 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",
142+
" \n",
143+
" > Represent this as a Normal Form Game.\n",
144+
" \n",
145+
" \n",
146+
"$$\n",
147+
"A = \\begin{pmatrix}\n",
148+
"2 & 4 & 4 & 4\\\\\n",
149+
"0 & 3 & 5 & 5\\\\\n",
150+
"0 & 1 & 4 & 6\\\\\n",
151+
"0 & 1 & 2 & 5\n",
152+
"\\end{pmatrix}\n",
153+
"\\qquad\n",
154+
"B = \\begin{pmatrix}\n",
155+
"2 & 0 & 0 & 0\\\\\n",
156+
"4 & 3 & 1 & 1\\\\\n",
157+
"4 & 5 & 4 & 2\\\\\n",
158+
"4 & 5 & 6 & 5\n",
159+
"\\end{pmatrix}\n",
160+
"$$"
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": 8,
166+
"id": "f1922cd9-a1ca-40ca-b1ad-c09de6b46a9d",
167+
"metadata": {},
168+
"outputs": [
169+
{
170+
"data": {
171+
"text/plain": [
172+
"Bi matrix game with payoff matrices:\n",
173+
"\n",
174+
"Row player:\n",
175+
"[[2 4 4 4]\n",
176+
" [0 3 5 5]\n",
177+
" [0 1 4 6]\n",
178+
" [0 1 2 5]]\n",
179+
"\n",
180+
"Column player:\n",
181+
"[[2 0 0 0]\n",
182+
" [4 3 1 1]\n",
183+
" [4 5 4 2]\n",
184+
" [4 5 6 5]]"
185+
]
186+
},
187+
"execution_count": 8,
188+
"metadata": {},
189+
"output_type": "execute_result"
190+
}
191+
],
192+
"source": [
193+
"A = np.array(((2, 4, 4, 4), (0, 3, 5, 5), (0, 1, 4, 6), (0, 1, 2,5)))\n",
194+
"B = np.array(((2, 0, 0, 0), (4, 3, 1, 1), (4, 5, 4, 2), (4, 5, 6, 5)))\n",
195+
"game = nash.Game(A, B)\n",
196+
"game"
197+
]
198+
}
199+
],
200+
"metadata": {
201+
"kernelspec": {
202+
"display_name": "Python 3 (ipykernel)",
203+
"language": "python",
204+
"name": "python3"
205+
},
206+
"language_info": {
207+
"codemirror_mode": {
208+
"name": "ipython",
209+
"version": 3
210+
},
211+
"file_extension": ".py",
212+
"mimetype": "text/x-python",
213+
"name": "python",
214+
"nbconvert_exporter": "python",
215+
"pygments_lexer": "ipython3",
216+
"version": "3.11.4"
217+
}
218+
},
219+
"nbformat": 4,
220+
"nbformat_minor": 5
221+
}

0 commit comments

Comments
 (0)