Skip to content

Commit 9eabc25

Browse files
committed
FIX: Player.is_dominated: Fix warnings
Fix #501
1 parent 7d1b305 commit 9eabc25

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

quantecon/game_theory/normal_form_game.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,17 +472,18 @@ def is_dominated(self, action, tol=None, method=None):
472472
elif method in ['simplex', 'interior-point']:
473473
from scipy.optimize import linprog
474474
m, n = D.shape
475-
A = np.empty((n+2, m+1))
476-
A[:n, :m] = -D.T
477-
A[:n, -1] = 1 # Slack variable
478-
A[n, :m], A[n+1, :m] = 1, -1 # Equality constraint
479-
A[n:, -1] = 0
480-
b = np.empty(n+2)
481-
b[:n] = 0
482-
b[n], b[n+1] = 1, -1
475+
A_ub = np.empty((n, m+1))
476+
A_ub[:, :m] = -D.T
477+
A_ub[:, -1] = 1 # Slack variable
478+
b_ub = np.zeros(n)
479+
A_eq = np.empty((1, m+1))
480+
A_eq[:, :m] = 1 # Equality constraint
481+
A_eq[:, -1] = 0
482+
b_eq = np.ones(1)
483483
c = np.zeros(m+1)
484484
c[-1] = -1
485-
res = linprog(c, A_ub=A, b_ub=b, method=method)
485+
res = linprog(c, A_ub=A_ub, b_ub=b_ub, A_eq=A_eq, b_eq=b_eq,
486+
method=method)
486487
if res.success:
487488
return res.x[-1] > tol
488489
elif res.status == 2: # infeasible

quantecon/game_theory/tests/test_normal_form_game.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_player_corner_cases():
162162
for method in LP_METHODS:
163163
eq_(player.is_dominated(action, method=method), False)
164164

165-
e = 1e-8
165+
e = 1e-8 * 2
166166
player = Player([[-e, -e], [1, -1], [-1, 1]])
167167
action = 0
168168
eq_(player.is_best_response(action, [1/2, 1/2], tol=e), True)

0 commit comments

Comments
 (0)