Skip to content

Commit

Permalink
EHN: Add 'interior-point' option to is_dominated
Browse files Browse the repository at this point in the history
  • Loading branch information
oyamad committed May 20, 2018
1 parent c9a7670 commit 844b669
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions quantecon/game_theory/normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,9 @@ def is_dominated(self, action, tol=None, method=None):
method : str, optional(default=None)
If None, `lemke_howson` from `quantecon.game_theory` is used
to solve for a Nash equilibrium of an auxiliary zero-sum
game. If `method='simplex'`, `scipy.optimize.linprog` is
used with `method='simplex'`.
game. If `method` is set to `'simplex'` or
`'interior-point'`, `scipy.optimize.linprog` is used with
the method as specified by `method`.
Returns
-------
Expand Down Expand Up @@ -425,7 +426,7 @@ def is_dominated(self, action, tol=None, method=None):
g_zero_sum = NormalFormGame([Player(D), Player(-D.T)])
NE = lemke_howson(g_zero_sum)
return NE[0] @ D @ NE[1] > tol
elif method in ['simplex']:
elif method in ['simplex', 'interior-point']:
from scipy.optimize import linprog
m, n = D.shape
A = np.empty((n+2, m+1))
Expand Down
11 changes: 7 additions & 4 deletions quantecon/game_theory/tests/test_normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

# Player #

LP_METHODS = [None, 'simplex', 'interior-point']


class TestPlayer_1opponent:
"""Test the methods of Player with one opponent player"""

Expand Down Expand Up @@ -69,7 +72,7 @@ def test_is_best_response_against_mixed(self):

def test_is_dominated(self):
for action in range(self.player.num_actions):
for method in [None, 'simplex']:
for method in LP_METHODS:
eq_(self.player.is_dominated(action, method=method), False)


Expand Down Expand Up @@ -106,7 +109,7 @@ def test_best_response_list_when_tie(self):

def test_is_dominated(self):
for action in range(self.player.num_actions):
for method in [None, 'simplex']:
for method in LP_METHODS:
eq_(self.player.is_dominated(action, method=method), False)


Expand All @@ -126,15 +129,15 @@ def test_player_corner_cases():
player = Player(np.zeros((n, m)))
for action in range(n):
eq_(player.is_best_response(action, [1/m]*m), True)
for method in [None, 'simplex']:
for method in LP_METHODS:
eq_(player.is_dominated(action, method=method), False)

e = 1e-8
player = Player([[-e, -e], [1, -1], [-1, 1]])
action = 0
eq_(player.is_best_response(action, [1/2, 1/2], tol=e), True)
eq_(player.is_best_response(action, [1/2, 1/2], tol=e/2), False)
for method in [None, 'simplex']:
for method in LP_METHODS:
eq_(player.is_dominated(action, tol=e, method=method), False)
eq_(player.is_dominated(action, tol=e/2, method=method), True)

Expand Down

0 comments on commit 844b669

Please sign in to comment.