Skip to content

Add 3 player max cut test for enumpoly solver - #969

Merged
rahulsavani merged 7 commits into
gambitproject:masterfrom
ameliekleber:master
Jul 3, 2026
Merged

Add 3 player max cut test for enumpoly solver#969
rahulsavani merged 7 commits into
gambitproject:masterfrom
ameliekleber:master

Conversation

@ameliekleber

Copy link
Copy Markdown
Contributor

This PR adds a test for the enumpoly solver that covers the 2x2x2 max cut normal form game, ensuring it returns the two pure and one mixed equilibirum.

@ameliekleber

Copy link
Copy Markdown
Contributor Author

@rahulsavani I added the test we discussed on Wednesday, would appreciate your review :)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a targeted regression test to ensure enumpoly_solve correctly finds all equilibria (two pure + one symmetric mixed) for a 3-player 2x2x2 max-cut-derived normal-form game.

Changes:

  • Adds a new ENUMPOLY_STRATEGY_CASES test case validating three equilibria for a 2x2x2 NFG.
  • Updates the .nfg test game’s header comments to document the mixed equilibrium structure.
  • Registers a new pytest marker (nash_enumpoly_strategy) and wires the new case into the main strategy-solver parametrization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/test_nash.py Adds and registers an enumpoly strategy-form equilibrium test case for a 3-player 2x2x2 NFG.
tests/test_games/2x2x2_nfg_from_local_max_cut_2_pure_1_mixed_eq.nfg Clarifies documentation for the symmetric mixed equilibrium in the test fixture.
pyproject.toml Adds the nash_enumpoly_strategy marker so --strict-markers remains satisfied.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_nash.py

@rahulsavani rahulsavani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me, though co-pilot is right, we should probably include a regret_tol too. This max cut game is super simple so it may never error, but it's still good practice. For the suggestion below with nau2004, we'll definitely need that anyway.

Further suggestion:

Sorry to be demanding but I didn't realise we had no tests at all for "ENUMPOLY_STRATEGY", could you perhaps add a couple more, e.g. a 2-player coordination games would be natural (say in dimension 4 where we expect 7 eq, assuming it runs quickly enough, or dim 3 if not), for one or two further 3-player games you could try:

gbt.catalog.load("journals/ijgt/nau2004/sec4")
gbt.catalog.load("journals/ijgt/nau2004/sec5")

If sec5 takes too long for stop_after=None, feel free to set it otherwise.

Thanks.

@tturocy

tturocy commented Jul 3, 2026

Copy link
Copy Markdown
Member

@rahulsavani Further to our in-person conversation, indeed it looks like we never got around to doing strategy versions of tests for enumpoly - likely due to combination of issues with coordination games and with ordering of outputs...!

@ameliekleber

ameliekleber commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

I've added the 3 test you requested, the two from the catalog and the coordination game for n=3 (I think this is what you meant as this one has 7 eq and n=4 has 15?). The coordination game test was already in the behavior tests for enumpoly, so I added the use_strategic parameter for this test

@rahulsavani

Copy link
Copy Markdown
Member

I've added the 3 test you requested, the two from the catalog and the coordination game for n=3 (I think this is what you meant as this one has 7 eq and n=4 has 15?). The coordination game test was already in the behavior tests for enumpoly, so I added the use_strategic parameter for this test

You are right I have an "off by one error" with my reference to the dimensions of the coordination game: n=3 is good.

@rahulsavani

Copy link
Copy Markdown
Member

https://github.com/all-contributors

please add @ameliekleber for code

@rahulsavani

Copy link
Copy Markdown
Member

@tturocy

    # A three-player 2x2x2 game with 3 pure, 2 incompletely mixed, and a continuum of completely mixed Nash equilibria (nau2004 sec5 catalog game)
    pytest.param(
        EquilibriumTestCase(
            factory=functools.partial(gbt.catalog.load, "journals/ijgt/nau2004/sec5"),
            solver=functools.partial(gbt.nash.enumpoly_solve, stop_after=None),
            expected=[
                    [d(1, 0), d(0, 1), d(1, 0)],
                    [d(0, 1), d(1, 0), d(1, 0)],
                    [d(0, 1), d(0, 1), d(0, 1)],
            ],
            prob_tol=TOL,
            regret_tol=TOL,
        ),
        marks=pytest.mark.nash_enumpoly_strategy,
        id="test_enumpoly_strategy_4",

This is more like a regression test because I am not sure that we should only get the pure here -- or is this clear to you?

@rahulsavani rahulsavani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

One minor thing is flake8 -- please install pre-commit, which will help with this.

For a quick look at the required changes in this case, please see what co-pilot did in PR #972

@rahulsavani
rahulsavani self-requested a review July 3, 2026 20:38
@rahulsavani
rahulsavani merged commit 39deff0 into gambitproject:master Jul 3, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants