Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nash equilibrium in Python

Is there a Python library out there that solves for the Nash equilibrium of two-person zero-games? I know the solution can be written down in terms of linear constraints and, in theory, scipy should be able to optimize it. However, for two-person zero-games the solution is exact and unique, but some of the solvers fail to converge for certain problems.

Rather than listing any of the libraries on Linear programing on the Python website, I would like to know what library would be most effective in terms of ease of use and speed.

like image 232
Hooked Avatar asked Feb 04 '11 18:02

Hooked


2 Answers

Raymond Hettinger wrote a recipe for solving zero-sum payoff matrices. It should serve your purposes alright.

As for a more general library for solving game theory, there's nothing specifically designed for that. But, like you said, scipy can tackle optimization problems like this. You might be able to do something with GarlicSim, which claims to be for "any kind of simulation: Physics, game theory..." but I've never used it before so I can't recommend it.

like image 99
Rafe Kettler Avatar answered Oct 20 '22 06:10

Rafe Kettler


There is Gambit, which is a little difficult to set up, but has a python API.

like image 25
theresawalrus Avatar answered Oct 20 '22 06:10

theresawalrus