Skip to content

Commit 1454891

Browse files
committed
EHN: Add 'interior-point' option to is_dominated
QuantEcon#327 (comment)
1 parent 8657c91 commit 1454891

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

quantecon/game_theory/normal_form_game.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,9 @@ def is_dominated(self, action, tol=None, method=None):
395395
method : str, optional(default=None)
396396
If None, `lemke_howson` from `quantecon.game_theory` is used
397397
to solve for a Nash equilibrium of an auxiliary zero-sum
398-
game. If `method='simplex'`, `scipy.optimize.linprog` is
399-
used with `method='simplex'`.
398+
game. If `method` is set to `'simplex'` or
399+
`'interior-point'`, `scipy.optimize.linprog` is used with
400+
the method as specified by `method`.
400401
401402
Returns
402403
-------
@@ -425,7 +426,7 @@ def is_dominated(self, action, tol=None, method=None):
425426
g_zero_sum = NormalFormGame([Player(D), Player(-D.T)])
426427
NE = lemke_howson(g_zero_sum)
427428
return NE[0] @ D @ NE[1] > tol
428-
elif method in ['simplex']:
429+
elif method in ['simplex', 'interior-point']:
429430
from scipy.optimize import linprog
430431
m, n = D.shape
431432
A = np.empty((n+2, m+1))

quantecon/game_theory/tests/test_normal_form_game.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
# Player #
1717

18+
LP_METHODS = [None, 'simplex', 'interior-point']
19+
20+
1821
class TestPlayer_1opponent:
1922
"""Test the methods of Player with one opponent player"""
2023

@@ -69,7 +72,7 @@ def test_is_best_response_against_mixed(self):
6972

7073
def test_is_dominated(self):
7174
for action in range(self.player.num_actions):
72-
for method in [None, 'simplex']:
75+
for method in LP_METHODS:
7376
eq_(self.player.is_dominated(action, method=method), False)
7477

7578

@@ -106,7 +109,7 @@ def test_best_response_list_when_tie(self):
106109

107110
def test_is_dominated(self):
108111
for action in range(self.player.num_actions):
109-
for method in [None, 'simplex']:
112+
for method in LP_METHODS:
110113
eq_(self.player.is_dominated(action, method=method), False)
111114

112115

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

132135
e = 1e-8
133136
player = Player([[-e, -e], [1, -1], [-1, 1]])
134137
action = 0
135138
eq_(player.is_best_response(action, [1/2, 1/2], tol=e), True)
136139
eq_(player.is_best_response(action, [1/2, 1/2], tol=e/2), False)
137-
for method in [None, 'simplex']:
140+
for method in LP_METHODS:
138141
eq_(player.is_dominated(action, tol=e, method=method), False)
139142
eq_(player.is_dominated(action, tol=e/2, method=method), True)
140143

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def write_version_py(filename=None):
115115
install_requires=[
116116
'numba>=0.36.2',
117117
'numpy',
118-
'scipy',
118+
'scipy>=1.0.0',
119119
'sympy',
120120
]
121121
)

0 commit comments

Comments
 (0)