noregret 0.0.0.dev0__tar.gz → 0.0.0.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: noregret
3
- Version: 0.0.0.dev0
3
+ Version: 0.0.0.dev1
4
4
  Summary: No-regret learning dynamics
5
5
  Home-page: https://github.com/uoftcprg/noregret
6
6
  Author: Universal, Open, Free, and Transparent Computer Poker Research Group
@@ -1,10 +1,11 @@
1
1
  from abc import ABC, abstractmethod
2
- from dataclasses import dataclass, field
2
+ from dataclasses import dataclass
3
3
  from functools import partial
4
- from itertools import count, permutations
4
+ from itertools import permutations
5
5
  from math import factorial
6
6
  from typing import Any
7
7
 
8
+ from ordered_set import OrderedSet
8
9
  from scipy.sparse import lil_array
9
10
  import numpy as np
10
11
 
@@ -255,13 +256,11 @@ class NormalFormGame(Serializable, Game):
255
256
 
256
257
  actions: Any
257
258
  utilities: Any
258
- indices: Any = field(init=False, default_factory=list)
259
259
 
260
260
  def __post_init__(self):
261
261
  super().__post_init__()
262
262
 
263
- for i, actions in enumerate(self.actions):
264
- self.indices.append(dict(zip(actions, count())))
263
+ self.actions = tuple(map(OrderedSet, self.actions))
265
264
 
266
265
  def _verify(self, *, utilities_shape=None, **kwargs):
267
266
  super()._verify(**kwargs)
@@ -304,14 +303,6 @@ class TwoPlayerNormalFormGame(TwoPlayerGame, NormalFormGame):
304
303
  def column_actions(self):
305
304
  return self.actions[1]
306
305
 
307
- @property
308
- def row_indices(self):
309
- return self.indices[0]
310
-
311
- @property
312
- def column_indices(self):
313
- return self.indices[1]
314
-
315
306
  @property
316
307
  def row_utilities(self):
317
308
  return self.utilities[:, :, 0]
@@ -414,7 +405,7 @@ class TwoPlayerExtensiveFormGame(TwoPlayerGame, ExtensiveFormGame):
414
405
  for tfsdp, sequence in zip(tfsdps, raw_utility['sequences']):
415
406
  sequence = tuple(sequence)
416
407
 
417
- indices.append(tfsdp.indices[sequence])
408
+ indices.append(tfsdp.sequences.index(sequence))
418
409
 
419
410
  indices = tuple(indices)
420
411
  row_utilities[indices] = raw_utility['values'][0]
@@ -448,14 +439,6 @@ class TwoPlayerExtensiveFormGame(TwoPlayerGame, ExtensiveFormGame):
448
439
  def column_sequences(self):
449
440
  return self.column_tree_form_sequential_decision_process.sequences
450
441
 
451
- @property
452
- def row_indices(self):
453
- return self.row_tree_form_sequential_decision_process.indices
454
-
455
- @property
456
- def column_indices(self):
457
- return self.column_tree_form_sequential_decision_process.indices
458
-
459
442
  @property
460
443
  def row_utilities(self):
461
444
  return self.utilities[0]
@@ -530,7 +513,7 @@ class TwoPlayerZeroSumExtensiveFormGame(
530
513
  for tfsdp, sequence in zip(tfsdps, raw_utility['sequences']):
531
514
  sequence = tuple(sequence)
532
515
 
533
- indices.append(tfsdp.indices[sequence])
516
+ indices.append(tfsdp.sequences.index(sequence))
534
517
 
535
518
  indices = tuple(indices)
536
519
  utilities[indices] = raw_utility['value']
@@ -153,7 +153,6 @@ class TreeFormSequentialDecisionProcess(Serializable):
153
153
  decision_points: Any = field(init=False, default_factory=OrderedSet)
154
154
  observation_points: Any = field(init=False, default_factory=OrderedSet)
155
155
  sequences: Any = field(init=False, default_factory=OrderedSet)
156
- indices: Any = field(init=False, default_factory=dict)
157
156
  parent_sequences: Any = field(init=False, default_factory=dict)
158
157
  actions: Any = field(
159
158
  init=False,
@@ -203,8 +202,6 @@ class TreeFormSequentialDecisionProcess(Serializable):
203
202
  if is_sequence:
204
203
  self.sequences.add(parent_edge)
205
204
 
206
- self.indices[parent_edge] = len(self.indices)
207
-
208
205
  self.parent_sequences[p] = parent_sequence
209
206
 
210
207
  def behavioral_uniform_strategy(self):
@@ -227,7 +224,7 @@ class TreeFormSequentialDecisionProcess(Serializable):
227
224
 
228
225
  for i, a in enumerate(self.actions[p]):
229
226
  value = (
230
- utility[self.indices[p, a]]
227
+ utility[self.sequences.index((p, a))]
231
228
  + V[self.transitions[p, a]]
232
229
  )
233
230
 
@@ -250,15 +247,15 @@ class TreeFormSequentialDecisionProcess(Serializable):
250
247
 
251
248
  def behavioral_to_sequence_form(self, behavioral_strategy):
252
249
  strategy = np.zeros(len(self.sequences))
253
- strategy[self.indices[()]] = 1
250
+ strategy[self.sequences.index(())] = 1
254
251
 
255
252
  for j in self.decision_points:
256
253
  p_j = self.parent_sequences[j]
257
254
 
258
255
  for i, a in enumerate(self.actions[j]):
259
- strategy[self.indices[j, a]] = (
256
+ strategy[self.sequences.index((j, a))] = (
260
257
  behavioral_strategy[j][i]
261
- * strategy[self.indices[p_j]]
258
+ * strategy[self.sequences.index(p_j)]
262
259
  )
263
260
 
264
261
  return strategy
@@ -273,7 +270,7 @@ class TreeFormSequentialDecisionProcess(Serializable):
273
270
  V[p] += (
274
271
  behavioral_strategy[p][i]
275
272
  * (
276
- utility[self.indices[p, a]]
273
+ utility[self.sequences.index((p, a))]
277
274
  + V[self.transitions[p, a]]
278
275
  )
279
276
  )
@@ -288,7 +285,7 @@ class TreeFormSequentialDecisionProcess(Serializable):
288
285
 
289
286
  for i, a in enumerate(self.actions[j]):
290
287
  utilities[j][i] = (
291
- utility[self.indices[j, a]]
288
+ utility[self.sequences.index((j, a))]
292
289
  + V[self.transitions[j, a]]
293
290
  )
294
291
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: noregret
3
- Version: 0.0.0.dev0
3
+ Version: 0.0.0.dev1
4
4
  Summary: No-regret learning dynamics
5
5
  Home-page: https://github.com/uoftcprg/noregret
6
6
  Author: Universal, Open, Free, and Transparent Computer Poker Research Group
@@ -4,7 +4,7 @@ from setuptools import find_packages, setup
4
4
 
5
5
  setup(
6
6
  name='noregret',
7
- version='0.0.0.dev0',
7
+ version='0.0.0.dev1',
8
8
  description='No-regret learning dynamics',
9
9
  long_description=open('README.md').read(),
10
10
  long_description_content_type='text/markdown',
File without changes
File without changes
File without changes