Skip to content

Commit 811d6bd

Browse files
load from catalog in starting points tutorial
1 parent 3a85cbe commit 811d6bd

1 file changed

Lines changed: 50 additions & 40 deletions

File tree

doc/tutorials/advanced_tutorials/starting_points.ipynb

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": null,
28+
"execution_count": 15,
29+
"id": "57df88bc-3ff1-4f0a-848e-02724351976c",
30+
"metadata": {},
31+
"outputs": [],
32+
"source": [
33+
"import numpy as np\n",
34+
"\n",
35+
"import pygambit as gbt"
36+
]
37+
},
38+
{
39+
"cell_type": "code",
40+
"execution_count": 16,
2941
"id": "493cafb8",
3042
"metadata": {},
3143
"outputs": [
@@ -39,14 +51,13 @@
3951
"Game(title='2x2x2 Example from McKelvey-McLennan, with 9 Nash equilibria, 2 totally mixed')"
4052
]
4153
},
42-
"execution_count": 1,
54+
"execution_count": 16,
4355
"metadata": {},
4456
"output_type": "execute_result"
4557
}
4658
],
4759
"source": [
48-
"import pygambit as gbt\n",
49-
"g = gbt.read_nfg(\"../../2x2x2.nfg\")\n",
60+
"g = gbt.catalog.Game2x2x2NFG()\n",
5061
"g"
5162
]
5263
},
@@ -61,7 +72,7 @@
6172
},
6273
{
6374
"cell_type": "code",
64-
"execution_count": 2,
75+
"execution_count": 17,
6576
"id": "b32adf22",
6677
"metadata": {},
6778
"outputs": [
@@ -74,7 +85,7 @@
7485
"[[0.5, 0.5], [0.5, 0.5], [0.5, 0.5]]"
7586
]
7687
},
77-
"execution_count": 2,
88+
"execution_count": 17,
7889
"metadata": {},
7990
"output_type": "execute_result"
8091
}
@@ -86,20 +97,20 @@
8697
},
8798
{
8899
"cell_type": "code",
89-
"execution_count": 3,
100+
"execution_count": 18,
90101
"id": "c0b62502",
91102
"metadata": {},
92103
"outputs": [
93104
{
94105
"data": {
95106
"text/latex": [
96-
"$\\left[[0.3999999026224355, 0.6000000973775644],[0.49999981670851457, 0.5000001832914854],[0.3333329684317666, 0.6666670315682334]\\right]$"
107+
"$\\left[[0.4000002947381336, 0.5999997052618664],[0.4999994065053205, 0.5000005934946796],[0.3333334410505316, 0.6666665589494684]\\right]$"
97108
],
98109
"text/plain": [
99-
"[[0.3999999026224355, 0.6000000973775644], [0.49999981670851457, 0.5000001832914854], [0.3333329684317666, 0.6666670315682334]]"
110+
"[[0.4000002947381336, 0.5999997052618664], [0.4999994065053205, 0.5000005934946796], [0.3333334410505316, 0.6666665589494684]]"
100111
]
101112
},
102-
"execution_count": 3,
113+
"execution_count": 18,
103114
"metadata": {},
104115
"output_type": "execute_result"
105116
}
@@ -121,7 +132,7 @@
121132
},
122133
{
123134
"cell_type": "code",
124-
"execution_count": 4,
135+
"execution_count": 19,
125136
"id": "cf22064e",
126137
"metadata": {},
127138
"outputs": [
@@ -134,7 +145,7 @@
134145
"[[0.9, 0.1], [0.9, 0.1], [0.9, 0.1]]"
135146
]
136147
},
137-
"execution_count": 4,
148+
"execution_count": 19,
138149
"metadata": {},
139150
"output_type": "execute_result"
140151
}
@@ -146,20 +157,20 @@
146157
},
147158
{
148159
"cell_type": "code",
149-
"execution_count": 5,
160+
"execution_count": 20,
150161
"id": "08a22505",
151162
"metadata": {},
152163
"outputs": [
153164
{
154165
"data": {
155166
"text/latex": [
156-
"$\\left[[1.0, 0.0],[0.9999999944750116, 5.524988446860122e-09],[0.9999999991845827, 8.154173380971617e-10]\\right]$"
167+
"$\\left[[0.9999999968173041, 3.1826958638999237e-09],[0.9999999929853859, 7.014614077736281e-09],[0.999999999193891, 8.061090096721423e-10]\\right]$"
157168
],
158169
"text/plain": [
159-
"[[1.0, 0.0], [0.9999999944750116, 5.524988446860122e-09], [0.9999999991845827, 8.154173380971617e-10]]"
170+
"[[0.9999999968173041, 3.1826958638999237e-09], [0.9999999929853859, 7.014614077736281e-09], [0.999999999193891, 8.061090096721423e-10]]"
160171
]
161172
},
162-
"execution_count": 5,
173+
"execution_count": 20,
163174
"metadata": {},
164175
"output_type": "execute_result"
165176
}
@@ -178,20 +189,20 @@
178189
},
179190
{
180191
"cell_type": "code",
181-
"execution_count": 6,
192+
"execution_count": 21,
182193
"id": "cfbc2714",
183194
"metadata": {},
184195
"outputs": [
185196
{
186197
"data": {
187198
"text/latex": [
188-
"$\\left[[0.7187961367413075, 0.2812038632586925],[0.1291105793795489, 0.8708894206204512],[0.12367227612277114, 0.876327723877229]\\right]$"
199+
"$\\left[[0.5816023335384932, 0.41839766646150667],[0.14988214487024656, 0.8501178551297536],[0.1633565719798093, 0.8366434280201908]\\right]$"
189200
],
190201
"text/plain": [
191-
"[[0.7187961367413075, 0.2812038632586925], [0.1291105793795489, 0.8708894206204512], [0.12367227612277114, 0.876327723877229]]"
202+
"[[0.5816023335384932, 0.41839766646150667], [0.14988214487024656, 0.8501178551297536], [0.1633565719798093, 0.8366434280201908]]"
192203
]
193204
},
194-
"execution_count": 6,
205+
"execution_count": 21,
195206
"metadata": {},
196207
"output_type": "execute_result"
197208
}
@@ -203,20 +214,20 @@
203214
},
204215
{
205216
"cell_type": "code",
206-
"execution_count": 7,
217+
"execution_count": 22,
207218
"id": "eb53062a",
208219
"metadata": {},
209220
"outputs": [
210221
{
211222
"data": {
212223
"text/latex": [
213-
"$\\left[[0.5000003932357804, 0.4999996067642197],[0.3999998501612186, 0.6000001498387814],[0.2500001518113522, 0.7499998481886477]\\right]$"
224+
"$\\left[[0.5000006764533134, 0.49999932354668664],[0.39999957335142133, 0.6000004266485787],[0.24999957325483269, 0.7500004267451672]\\right]$"
214225
],
215226
"text/plain": [
216-
"[[0.5000003932357804, 0.4999996067642197], [0.3999998501612186, 0.6000001498387814], [0.2500001518113522, 0.7499998481886477]]"
227+
"[[0.5000006764533134, 0.49999932354668664], [0.39999957335142133, 0.6000004266485787], [0.24999957325483269, 0.7500004267451672]]"
217228
]
218229
},
219-
"execution_count": 7,
230+
"execution_count": 22,
220231
"metadata": {},
221232
"output_type": "execute_result"
222233
}
@@ -238,7 +249,7 @@
238249
},
239250
{
240251
"cell_type": "code",
241-
"execution_count": 8,
252+
"execution_count": 23,
242253
"id": "4293343a",
243254
"metadata": {},
244255
"outputs": [
@@ -248,13 +259,12 @@
248259
"True"
249260
]
250261
},
251-
"execution_count": 8,
262+
"execution_count": 23,
252263
"metadata": {},
253264
"output_type": "execute_result"
254265
}
255266
],
256267
"source": [
257-
"import numpy as np\n",
258268
"gen = np.random.default_rng(seed=1234567890)\n",
259269
"p1 = g.random_strategy_profile(gen=gen)\n",
260270
"gen = np.random.default_rng(seed=1234567890)\n",
@@ -278,7 +288,7 @@
278288
},
279289
{
280290
"cell_type": "code",
281-
"execution_count": 9,
291+
"execution_count": 24,
282292
"id": "e9716ae0",
283293
"metadata": {},
284294
"outputs": [
@@ -291,7 +301,7 @@
291301
"[[Rational(1, 2), Rational(1, 2)], [Rational(7, 10), Rational(3, 10)], [Rational(0, 1), Rational(1, 1)]]"
292302
]
293303
},
294-
"execution_count": 9,
304+
"execution_count": 24,
295305
"metadata": {},
296306
"output_type": "execute_result"
297307
}
@@ -304,7 +314,7 @@
304314
},
305315
{
306316
"cell_type": "code",
307-
"execution_count": 10,
317+
"execution_count": 25,
308318
"id": "c153918a",
309319
"metadata": {},
310320
"outputs": [
@@ -317,7 +327,7 @@
317327
"[[Rational(1, 1), Rational(0, 1)], [Rational(1, 1), Rational(0, 1)], [Rational(1, 1), Rational(0, 1)]]"
318328
]
319329
},
320-
"execution_count": 10,
330+
"execution_count": 25,
321331
"metadata": {},
322332
"output_type": "execute_result"
323333
}
@@ -328,7 +338,7 @@
328338
},
329339
{
330340
"cell_type": "code",
331-
"execution_count": 11,
341+
"execution_count": 26,
332342
"id": "70a57b26",
333343
"metadata": {},
334344
"outputs": [
@@ -341,7 +351,7 @@
341351
"[[Rational(1, 10), Rational(9, 10)], [Rational(3, 5), Rational(2, 5)], [Rational(3, 5), Rational(2, 5)]]"
342352
]
343353
},
344-
"execution_count": 11,
354+
"execution_count": 26,
345355
"metadata": {},
346356
"output_type": "execute_result"
347357
}
@@ -353,7 +363,7 @@
353363
},
354364
{
355365
"cell_type": "code",
356-
"execution_count": 12,
366+
"execution_count": 27,
357367
"id": "11995836",
358368
"metadata": {},
359369
"outputs": [
@@ -366,7 +376,7 @@
366376
"[[Rational(0, 1), Rational(1, 1)], [Rational(0, 1), Rational(1, 1)], [Rational(1, 1), Rational(0, 1)]]"
367377
]
368378
},
369-
"execution_count": 12,
379+
"execution_count": 27,
370380
"metadata": {},
371381
"output_type": "execute_result"
372382
}
@@ -377,7 +387,7 @@
377387
},
378388
{
379389
"cell_type": "code",
380-
"execution_count": 13,
390+
"execution_count": 28,
381391
"id": "2791ffe2",
382392
"metadata": {},
383393
"outputs": [
@@ -390,7 +400,7 @@
390400
"[[Rational(7, 10), Rational(3, 10)], [Rational(4, 5), Rational(1, 5)], [Rational(0, 1), Rational(1, 1)]]"
391401
]
392402
},
393-
"execution_count": 13,
403+
"execution_count": 28,
394404
"metadata": {},
395405
"output_type": "execute_result"
396406
}
@@ -402,7 +412,7 @@
402412
},
403413
{
404414
"cell_type": "code",
405-
"execution_count": 14,
415+
"execution_count": 29,
406416
"id": "2ab2caa4",
407417
"metadata": {},
408418
"outputs": [
@@ -415,7 +425,7 @@
415425
"[[Rational(1, 1), Rational(0, 1)], [Rational(1, 1), Rational(0, 1)], [Rational(1, 1), Rational(0, 1)]]"
416426
]
417427
},
418-
"execution_count": 14,
428+
"execution_count": 29,
419429
"metadata": {},
420430
"output_type": "execute_result"
421431
}
@@ -427,7 +437,7 @@
427437
],
428438
"metadata": {
429439
"kernelspec": {
430-
"display_name": "gambitvenv313",
440+
"display_name": "Python 3 (ipykernel)",
431441
"language": "python",
432442
"name": "python3"
433443
},

0 commit comments

Comments
 (0)