drvinceknight / Nashpy

A python library for 2 player games.
http://nashpy.readthedocs.io
MIT License
333 stars 71 forks source link

Not all Nash Equilibria are found by support_enumeration #222

Open lolokoko28 opened 11 months ago

lolokoko28 commented 11 months ago

Support Equilibria should "return all the equlibria" , so I would expect also the mixed equilibria. But it doesn't. The game from example has (p, 1) with p in <0, 2/7> but the function only returns (0,1).

I know that returning all the equlibria in case of infinite number of ne is not the possible. However, I would expect to get the "limit points", as this function is able to calculate mixed equlilibria as in case of Rock Paper Scissors game.

Code:

import nashpy
import numpy as np

n_game = nashpy.Game(np.array([[-3, 3], [-3, 5]]), np.array([[2, 7], [4, 2]]))

for ne in n_game.support_enumeration():
    print("Found Nash Equilibrium: ", ne)

mixed_nash_p1 = np.array([0.2857, 1 - 0.2857])
mixed_nash_p2 = np.array([1.0, 0.0])

print("Is (0.2857, 1.0) a best response? ", n_game.is_best_response(mixed_nash_p1, mixed_nash_p2))
print("Is (0.18, 1.0) a best response? ", n_game.is_best_response(np.array([0.18, 0.82]), np.array([1, 0])))

Output:

Found Nash Equilibrium:  (array([0., 1.]), array([1., 0.]))
Is (0.2857, 1.0) a best response?  (True, True)
Is (0.18, 1.0) a best response?  (True, True)
drvinceknight commented 10 months ago

Thanks for this, you're absolutely right that we should find a way to improve things here. The game is degenerate so the behaviour is somewhat expected but the usual warnings that pop up in some cases don't occur here.

We should essentially find a way to implement your implicit suggestion which is to get the limit points. I can open that up as a separate issue or discussion about implementation can occur here.