Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tournament graph.
"""
n = payoff_array.shape[0]
X = np.empty(k, dtype=np.int_)
a = np.empty(k, dtype=np.int_)
for i in range(n):
d = indptr[i+1] - indptr[i]
if d >= k:
for j in range(k):
a[j] = j
while a[-1] < d:
for j in range(k):
X[j] = indices[indptr[i]+a[j]]
payoff_array[i, k_array_rank_jit(X)] = 1
a = next_k_array(a)
while supps[0][-1] < nums_actions[0]:
supps[1][:] = np.arange(k)
while supps[1][-1] < nums_actions[1]:
if _indiff_mixed_action(
payoff_matrices[0], supps[0], supps[1], A, actions[1]
):
if _indiff_mixed_action(
payoff_matrices[1], supps[1], supps[0], A, actions[0]
):
out = (np.zeros(nums_actions[0]),
np.zeros(nums_actions[1]))
for p, (supp, action) in enumerate(zip(supps,
actions)):
out[p][supp] = action[:-1]
yield out
next_k_array(supps[1])
next_k_array(supps[0])
Parameters
----------
payoff_array : ndarray(float, ndim=2)
ndarray of shape (m, n), where m = n choose k, prefilled with
zeros. Modified in place.
k : scalar(int)
Size of the subsets of nodes.
"""
m = payoff_array.shape[0]
X = np.arange(k)
for j in range(m):
for i in range(k):
payoff_array[j, X[i]] = 1
X = next_k_array(X)
supps[1][:] = np.arange(k)
while supps[1][-1] < nums_actions[1]:
if _indiff_mixed_action(
payoff_matrices[0], supps[0], supps[1], A, actions[1]
):
if _indiff_mixed_action(
payoff_matrices[1], supps[1], supps[0], A, actions[0]
):
out = (np.zeros(nums_actions[0]),
np.zeros(nums_actions[1]))
for p, (supp, action) in enumerate(zip(supps,
actions)):
out[p][supp] = action[:-1]
yield out
next_k_array(supps[1])
next_k_array(supps[0])