@@ -83,20 +83,25 @@ def _support_enumeration_gen(payoff_matrices):
83
83
"""
84
84
nums_actions = payoff_matrices [0 ].shape
85
85
n_min = min (nums_actions )
86
+ flags_vecs = (np .empty (nums_actions [0 ], np .bool_ ),
87
+ np .empty (nums_actions [1 ], np .bool_ ))
86
88
87
89
for k in range (1 , n_min + 1 ):
88
90
supps = (np .arange (0 , k , 1 , np .int_ ), np .empty (k , np .int_ ))
89
91
actions = (np .empty (k + 1 ), np .empty (k + 1 ))
90
92
A = np .empty ((k + 1 , k + 1 ))
91
93
92
94
while supps [0 ][- 1 ] < nums_actions [0 ]:
93
- supps [1 ][:] = np .arange (k )
95
+ for i in range (k ):
96
+ supps [1 ][i ] = i
94
97
while supps [1 ][- 1 ] < nums_actions [1 ]:
95
98
if _indiff_mixed_action (
96
- payoff_matrices [0 ], supps [0 ], supps [1 ], A , actions [1 ]
99
+ payoff_matrices [0 ], supps [0 ], supps [1 ],
100
+ A , flags_vecs [0 ], actions [1 ]
97
101
):
98
102
if _indiff_mixed_action (
99
- payoff_matrices [1 ], supps [1 ], supps [0 ], A , actions [0 ]
103
+ payoff_matrices [1 ], supps [1 ], supps [0 ],
104
+ A , flags_vecs [1 ], actions [0 ]
100
105
):
101
106
out = (np .zeros (nums_actions [0 ]),
102
107
np .zeros (nums_actions [1 ]))
@@ -109,7 +114,8 @@ def _support_enumeration_gen(payoff_matrices):
109
114
110
115
111
116
@jit (nopython = True , cache = True )
112
- def _indiff_mixed_action (payoff_matrix , own_supp , opp_supp , A , out ):
117
+ def _indiff_mixed_action (payoff_matrix , own_supp , opp_supp ,
118
+ A , own_supp_flags , out ):
113
119
"""
114
120
Given a player's payoff matrix `payoff_matrix`, an array `own_supp`
115
121
of this player's actions, and an array `opp_supp` of the opponent's
@@ -118,7 +124,8 @@ def _indiff_mixed_action(payoff_matrix, own_supp, opp_supp, A, out):
118
124
among the actions in `own_supp`, if any such exists. Return `True`
119
125
if such a mixed action exists and actions in `own_supp` are indeed
120
126
best responses to it, in which case the outcome is stored in `out`;
121
- `False` otherwise. Array `A` is used in intermediate steps.
127
+ `False` otherwise. Arrays `A` and `own_supp_flags` are used in
128
+ intermediate steps.
122
129
123
130
Parameters
124
131
----------
@@ -134,6 +141,9 @@ def _indiff_mixed_action(payoff_matrix, own_supp, opp_supp, A, out):
134
141
A : ndarray(float, ndim=2)
135
142
Array used in intermediate steps, of shape (k+1, k+1).
136
143
144
+ own_supp_flags : ndarray(bool, ndim=1)
145
+ Array used in intermediate steps, of length m.
146
+
137
147
out : ndarray(float, ndim=1)
138
148
Array of length k+1 to store the k nonzero values of the desired
139
149
mixed action in `out[:-1]` (and the payoff value in `out[-1]`).
@@ -167,7 +177,7 @@ def _indiff_mixed_action(payoff_matrix, own_supp, opp_supp, A, out):
167
177
if k == m :
168
178
return True
169
179
170
- own_supp_flags = np . zeros ( m , np . bool_ )
180
+ own_supp_flags [:] = False
171
181
own_supp_flags [own_supp ] = True
172
182
173
183
for i in range (m ):
0 commit comments