pythongambit

Removing Dominated Strategies in Strategic Game


The Problem

I'm using Gambit's Python API to create a game tree. I have game tree with strategies and I want to reduce my tree by eliminating all strictly dominated strategies. 2 Reasons why I am not doing this in the Gambit UI is: sometimes my tree is too big for it and it won't let me save a tree that's been trimmed of dominated strategies, which annoys me.

Anyways, I call this to get me the undominated strategies:

undominated = g.support_profile().undominated()

Failed attempt #1:

I want to remove all the strategies NOT in this list from my game (i.e. remove all dominated strategies in the game). (IS THIS WHAT I WANT EVEN? AM I ALSO REMOVING WEAKLY DOMINATED STRATEGIES?) So I call:

for strategy in g.support_profile():
    if strategy not in undominated:
        g.support_profile().remove(strategy)

However, I think this leaves my list unchanged... (I expected to remove ~200 and remain with 3 strategies, yet I still had my ~200 strategies).

What could I possibly be doing incorrectly?

Failed attempt #2:

I want to create a NEW game with all my undominated strategies. However, if I create a new game called "h" with my players, I want to try adding these strategies to my new game (unorthodox, but I thought of giving it a shot).

for strategy in undominated:
    h.strategies.add(strategy)

AttributeError: 'gambit.lib.libgambit.GameStrategies' 
object has no attribute 'add'

which confuses me because I thought this was a Strategies object as mentioned here: http://www.gambit-project.org/gambit15/pyapi.html#gambit.Strategies

Question

Can someone PLEASE help me figure out what I am supposed to do here?

Edit:

As @Gabriel stated I should do, I'll post the briefly summarized answer here. The solution involved calling:

undominated = g.support_profile().undominated().restrict()

The restrict() method creates and returns a new matrix game based on the given StrategySupportProfile. It's a bit slow when the tree gets big, but it gets the job done.


Solution

  • I posted the issue here and it looks like it was solved. https://github.com/gambitproject/gambit/issues/204

    Edit:

    As @Gabriel stated I should do, I'll post the briefly summarized answer here. The solution involved calling:

    undominated = g.support_profile().undominated().restrict()
    

    The restrict() method creates and returns a new matrix game based on the given StrategySupportProfile. It's a bit slow when the tree gets big, but it gets the job done.