Skip to content

Commit

Permalink
Compare vertex values in the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
shizejin committed Sep 26, 2018
1 parent 73a6faa commit 5c5dafc
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions quantecon/game_theory/tests/test_repeated_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import numpy as np
from numpy.testing import assert_array_equal
from numpy.testing import assert_allclose
from quantecon.game_theory import Player, NormalFormGame, RepeatedGame

class TestAS():
Expand All @@ -14,28 +14,36 @@ def setUp(self):
bimatrix = [[(16, 9), (3, 13), (0, 3)],
[(21, 1), (10, 4), (-1, 0)],
[(9, 0), (5, -4), (-5, -15)]]
vertice_inds = np.array([4, 8, 12, 11, 6, 1])
vertices = np.array([[7.33770472e+00, 1.09826253e+01],
[1.12568240e+00, 2.80000000e+00],
[7.33770472e+00, 4.44089210e-16],
[7.86308964e+00, 4.44089210e-16],
[1.97917977e+01, 2.80000000e+00],
[1.55630896e+01, 9.10000000e+00]])
d = {'sg': NormalFormGame(bimatrix),
'delta': 0.3,
'vertices': vertice_inds,
'u': np.array([0, 0])}
'vertices': vertices,
'u': np.zeros(2)}
self.game_dicts.append(d)

# Prisoner's dilemma
bimatrix = [[(9, 9), (1, 10)],
[(10, 1), (3, 3)]]
vertice_inds = np.array([6, 3, 0, 1])
vertices = np.array([[3. , 3. ],
[9.75, 3. ],
[9. , 9. ],
[3. , 9.75]])
d = {'sg': NormalFormGame(bimatrix),
'delta': 0.9,
'vertices': vertice_inds,
'vertices': vertices,
'u': np.array([3, 3])}
self.game_dicts.append(d)

def test_AS(self):
for d in self.game_dicts:
rpg = RepeatedGame(d['sg'], d['delta'])
hull = rpg.AS(u=d['u'])
assert_array_equal(d['vertices'], hull.vertices)
assert_allclose(hull.points[hull.vertices], d['vertices'])

if __name__ == '__main__':
import sys
Expand Down

0 comments on commit 5c5dafc

Please sign in to comment.