Comments (8)
Hello, I was able to reproduce the problem using the official python docker image versions 3.7 and 3.8 (they give similar results):
$ docker run -it --rm python:3.8 bash -c 'pip install nashpy && python -c "import nashpy as nash
import numpy
import scipy
print(\"nash version: \", nash.__version__)
print(\"numpy version: \", numpy.__version__)
print(\"scipy version: \", scipy.__version__)
A = [[52.46337363, 69.47195938, 0. , 54.14372075], [77. , 88. , 84.85714286, 92.4 ], [77.78571429, 87.35294118, 93.5 , 91.38461538], [66.37100751, 43.4530444 , 0. , 60.36191831]]
B = [[23.52690518, 17.35459006, 88.209 , 20.8021711 ], [16.17165 , 0. , 14.00142857, 6.46866 ], [ 0. , 5.76529412, 0. , 0. ], [15.68327304, 40.68156322, 84.00857143, 11.06596804]]
game = nash.Game(A, B)
print(game)
print(list(game.support_enumeration()))"'
Collecting nashpy
Downloading https://files.pythonhosted.org/packages/ad/a2/5d36744511640db1869029d2ab324b55f6eaaa2a51f75a87408a7e8000f4/nashpy-0.0.19.tar.gz
Collecting numpy>=1.12.1
Downloading https://files.pythonhosted.org/packages/d7/6a/3fed132c846d1e47963f30376cc041e9dd586d286d931055ad06ff65c6c7/numpy-1.17.4-cp38-cp38-manylinux1_x86_64.whl (20.5MB)
|████████████████████████████████| 20.5MB 3.0MB/s
Collecting scipy>=0.19.0
Downloading https://files.pythonhosted.org/packages/dd/25/b57bf2134f343909541977a79aa385addbc6a8ac470669739d8522e32c89/scipy-1.3.2-cp38-cp38-manylinux1_x86_64.whl (25.2MB)
|████████████████████████████████| 25.2MB 6.8MB/s
Building wheels for collected packages: nashpy
Building wheel for nashpy (setup.py) ... done
Created wheel for nashpy: filename=nashpy-0.0.19-cp38-none-any.whl size=10816 sha256=ed3e15df392bb9667bc3d2d0431b3baf24559594cf7bc33943a46e8b744829c1
Stored in directory: /root/.cache/pip/wheels/18/e9/56/2d04d01a6969d167f86d3afcb3d128c0b43d0d73ea471c835b
Successfully built nashpy
Installing collected packages: numpy, scipy, nashpy
Successfully installed nashpy-0.0.19 numpy-1.17.4 scipy-1.3.2
nash version: 0.0.19
numpy version: 1.17.4
scipy version: 1.3.2
Bi matrix game with payoff matrices:
Row player:
[[52.46337363 69.47195938 0. 54.14372075]
[77. 88. 84.85714286 92.4 ]
[77.78571429 87.35294118 93.5 91.38461538]
[66.37100751 43.4530444 0. 60.36191831]]
Column player:
[[23.52690518 17.35459006 88.209 20.8021711 ]
[16.17165 0. 14.00142857 6.46866 ]
[ 0. 5.76529412 0. 0. ]
[15.68327304 40.68156322 84.00857143 11.06596804]]
/usr/local/lib/python3.8/site-packages/nashpy/algorithms/support_enumeration.py:196: RuntimeWarning:
An even number of (0) equilibria was returned. This
indicates that the game is degenerate. Consider using another algorithm
to investigate.
warnings.warn(warning, RuntimeWarning)
[]
from nashpy.
from nashpy.
I do not get the same output:
>>> import nashpy as nash
>>> nash.__version__
'0.0.19'
>>> A = [[52.46337363, 69.47195938, 0. , 54.14372075], [77. , 88. , 84.85714286, 92.4 ], [77.78571429, 87.35294118, 93.5 , 91.38461538], [66.37100751, 43.4530444 , 0. , 60.36191831]]
>>> B = [[23.52690518, 17.35459006, 88.209 , 20.8021711 ], [16.17165 , 0. , 14.00142857, 6.46866 ], [ 0. , 5.76529412, 0. , 0. ], [15.68327304, 40.68156322, 84.00857143, 11.06596804]]
>>> game = nash.Game(A, B)
>>> game
Bi matrix game with payoff matrices:
Row player:
[[52.46337363 69.47195938 0. 54.14372075]
[77. 88. 84.85714286 92.4 ]
[77.78571429 87.35294118 93.5 91.38461538]
[66.37100751 43.4530444 0. 60.36191831]]
Column player:
[[23.52690518 17.35459006 88.209 20.8021711 ]
[16.17165 0. 14.00142857 6.46866 ]
[ 0. 5.76529412 0. 0. ]
[15.68327304 40.68156322 84.00857143 11.06596804]]
>>> list(game.support_enumeration())
[(array([7.33134761e-17, 2.62812089e-01, 7.37187911e-01, 0.00000000e+00]),
array([0.4516129, 0.5483871, 0. , 0. ]))]
Remember that game.support_enumeration()
returns a generator, perhaps you iterated over it once and then when querying it again found no equilibria.
from nashpy.
Not sure what might be happening, again doesn't reproduce (I just updated numpy in case it was that):
>>> import numpy
>>> import scipy
>>> import nashpy as nash
>>> print("nash version: ", nash.__version__)
>>> print("numpy version: ", numpy.__version__)
>>> print("scipy version: ", scipy.__version__)
>>> A = [[52.46337363, 69.47195938, 0. , 54.14372075], [77. , 88. , 84.85714286, 92.4 ], [77.78571429, 87.35294118, 93.5 , 91.38461538], [66.37100751, 43.4530444 , 0. , 60.36191831]]
>>> B = [[23.52690518, 17.35459006, 88.209 , 20.8021711 ], [16.17165 , 0. , 14.00142857, 6.46866 ], [ 0. , 5.76529412, 0. , 0. ], [15.68327304, 40.68156322, 84.00857143, 11.06596804]]
>>> game = nash.Game(A, B)
>>> print(list(game.support_enumeration()))
nash version: 0.0.19
numpy version: 1.17.3
scipy version: 1.3.1
[(array([7.33134761e-17, 2.62812089e-01, 7.37187911e-01, 0.00000000e+00]), array([0.4516129, 0.5483871, 0. , 0. ]))]
I will add this to the test suite to see what the CI says.
from nashpy.
Reopening as I've been able to reproduce on circle CI (not on travis or appveyor).
from nashpy.
See #68
from nashpy.
I have pinned down the error to being based on whether numpy is pip installed (I get the same error) or conda installed (no error). If either of you could try running with a conda install of numpy to confirm that would be appreciated.
from nashpy.
Still getting the error with conda
nash version: 0.0.19
numpy version: 1.17.3
scipy version: 1.3.2
That's very weird-- see below, I've run numerous experiments on numerous systems -- (have you uninstalled the pip install and reinstalled etc...?).
Anyway, I believe I have now gotten to the bottom of this. On #68 you can see what I have done:
- Before that PR the CI was running on travis (linux) and appveyor (windows) - I added the case we're discussing here to both of those and did not get an error.
- I added circle CI but did not use an anaconda environment on it but pip installed everything. This reproduced your error.
- I experimented locally: with pip installed numpy I got the error, with conda installed I did not (I tried this multiple times).
- When I round A and B to 5 decimal places I no longer get the error on with either version: this is essentially the test that is now being added by #68
- When adding intermediate tests I track this down to the
np.linalg.solve
(used to solve the underlying linear system).
To summarise: using precompiled (by anaconda) versions of dependencies the error does not reproduce (this has been run on 3 systems, mine locally, travis and appveyor) but using a pip installed version (run on 2 systems, mine locally and circle ci) does reproduce the error.
Thus my conclusion is that this is a precision error in the underlying numpy linear algebraic solver and not something that is fixable.
For completeness here is code that runs the solver with rounding to 5 decimals places:
>>> import numpy as np
>>> import scipy
>>> import nashpy as nash
>>> print("nash version: ", nash.__version__)
>>> print("numpy version: ", np.__version__)
>>> print("scipy version: ", scipy.__version__)
>>> A = [[52.46337363, 69.47195938, 0. , 54.14372075], [77. , 88. , 84.85714286, 92.4 ], [77.78571429, 87.35294118, 93.5 , 91.38461538], [66.37100751, 43.4530444 , 0. , 60.36191831]]
>>> B = [[23.52690518, 17.35459006, 88.209 , 20.8021711 ], [16.17165 , 0. , 14.00142857, 6.46866 ], [ 0. , 5.76529412, 0. , 0. ], [15.68327304, 40.68156322, 84.00857143, 11.06596804]]
>>> A = np.round(A, 5)
>>> B = np.round(B, 5)
>>> game = nash.Game(A, B)
>>> print(list(game.support_enumeration()))
nash version: 0.0.19
numpy version: 1.17.3
scipy version: 1.3.2
[(array([2.39382972e-17, 2.62811951e-01, 7.37188049e-01, 0.00000000e+00]), array([0.4516147, 0.5483853, 0. , 0. ]))]
If either of you feel there is something more that could be done here please don't hesitate to reopen the issue :) Thank you for taking time to report the bug. 👍
from nashpy.
Related Issues (20)
- Add support for py3.10
- Add discussion documentation for Moran process
- Add approximate fixation function
- Returns empty equilibrium
- NASHPY strengh HOT 1
- module 'numpy.typing' has no attribute 'NDArray' HOT 1
- Add more tests for Moran process
- Too low numpy version requirement in pyproject.toml HOT 1
- Fix Alex in CI
- Fix mypy in CI
- massive complexity improvement for fictitious play HOT 2
- Write theory docs on evolutionary graph theory (Moran processes on graphs)
- Add some performance regression tests HOT 1
- Add tests for individual methods in the tableaux
- Remove basic lemke howson algorithm
- Add open-graph extension to docs
- Fix bug in stochastic fictitious play HOT 2
- Improve use of pytest-memray HOT 1
- Not all Nash Equilibria are found by support_enumeration HOT 1
- Nashpy does not find equilibrium, clames game is degenerate HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nashpy.