How to use the quantecon.util.combinatorics.next_k_array function in quantecon

To help you get started, we’ve selected a few quantecon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github QuantEcon / QuantEcon.py / quantecon / game_theory / game_generators / bimatrix_generators.py View on Github external
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)
github QuantEcon / QuantEcon.py / quantecon / game_theory / support_enumeration.py View on Github external
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])
github QuantEcon / QuantEcon.py / quantecon / game_theory / game_generators / bimatrix_generators.py View on Github external
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)
github QuantEcon / QuantEcon.py / quantecon / game_theory / support_enumeration.py View on Github external
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])