开发者

Nash equilibrium in Python

开发者 https://www.devze.com 2023-02-08 09:28 出处:网络
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, scip开发者_开发

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, scip开发者_开发技巧y 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.


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.


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


I've just started putting together some game theory python code: http://drvinceknight.github.com/Gamepy/

There's code which:

  • solves matching games,
  • calculates shapley values in cooperative games,
  • runs agent based simulations to identify emergent behaviour in normal form games,
  • (clumsily - my python foo is still growing) uses the lrs library (written in C: http://cgm.cs.mcgill.ca/~avis/C/lrs.html) to calculate the solutions to normal form games (this is I believe what you want).

The code is all available on github and that site (the first link at the beginning of this answer) explains how the code works and gives user examples.

You might also want to check out 'Gambit' which I've never used.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号