How to use the nashpy.algorithms.support_enumeration.indifference_strategies function in nashpy

To help you get started, we’ve selected a few nashpy 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 drvinceknight / Nashpy / tests / unit / test_support_enumeration.py View on Github external
def test_indifference_strategies_with_non_degenerate(self):
        """Test for the indifference strategies of potential supports"""
        A = np.array([[2, 1], [0, 2]])
        B = np.array([[2, 0], [1, 2]])
        expected_indifference = [
            (np.array([1, 0]), np.array([1, 0])),
            (np.array([1, 0]), np.array([0, 1])),
            (np.array([0, 1]), np.array([1, 0])),
            (np.array([0, 1]), np.array([0, 1])),
            (np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
        ]
        obtained_indifference = [
            out[:2]
            for out in indifference_strategies(A, B, non_degenerate=True)
        ]
        self.assertEqual(len(obtained_indifference), len(expected_indifference))
        for obtained, expected in zip(
            obtained_indifference, expected_indifference
        ):
            self.assertTrue(
                np.array_equal(obtained, expected),
                msg="obtained: {} !=expected: {}".format(obtained, expected),
            )
github drvinceknight / Nashpy / tests / unit / test_support_enumeration.py View on Github external
def test_indifference_strategies(self):
        """Test for the indifference strategies of potential supports"""
        A = np.array([[2, 1], [0, 2]])
        B = np.array([[2, 0], [1, 2]])
        expected_indifference = [
            (np.array([1, 0]), np.array([1, 0])),
            (np.array([1, 0]), np.array([0, 1])),
            (np.array([0, 1]), np.array([1, 0])),
            (np.array([0, 1]), np.array([0, 1])),
            (np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
        ]
        obtained_indifference = [
            out[:2] for out in indifference_strategies(A, B)
        ]
        self.assertEqual(len(obtained_indifference), len(expected_indifference))
        for obtained, expected in zip(
            obtained_indifference, expected_indifference
        ):
            self.assertTrue(
                np.array_equal(obtained, expected),
                msg="obtained: {} !=expected: {}".format(obtained, expected),
            )
github drvinceknight / Nashpy / tests / unit / test_support_enumeration.py View on Github external
def test_indifference_strategies_with_high_tolerance(self):
        """Test for the indifference strategies of potential supports"""
        A = np.array([[2, 1], [0, 2]])
        B = np.array([[2, 0], [1, 2]])
        expected_indifference = [
            (np.array([1, 0]), np.array([1, 0])),
            (np.array([1, 0]), np.array([0, 1])),
            (np.array([0, 1]), np.array([1, 0])),
            (np.array([0, 1]), np.array([0, 1])),
            (np.array([1 / 3, 2 / 3]), np.array([1 / 3, 2 / 3])),
        ]
        obtained_indifference = [
            out[:2] for out in indifference_strategies(A, B, tol=10 ** -2)
        ]
        self.assertEqual(len(obtained_indifference), len(expected_indifference))
        for obtained, expected in zip(
            obtained_indifference, expected_indifference
        ):
            self.assertTrue(
                np.array_equal(obtained, expected),
                msg="obtained: {} !=expected: {}".format(obtained, expected),
            )