jlgametheory
Python interface to GameTheory.jl
jlgametheory is a Python package that allows passing
a NormalFormGame instance from
QuantEcon.py to
GameTheory.jl functions
via JuliaCall.
Installation
pip install jlgametheory
or
conda install -c conda-forge jlgametheory
Implemented functions
lrsnash: Compute in exact arithmetic all extreme mixed-action Nash equilibria of a 2-player normal form game with integer payoffs, with the lexicographic reverse search vertex enumeration algorithm.support_enumeration: Compute all mixed-action Nash equilibria of an N-player regular normal form game with N >= 3 by support enumeration, solving the polynomial indifference equations on each support profile with the homotopy continuation method.ipa_solve: Compute one mixed-action approximate Nash equilibrium of an N-player normal form game with the iterated polymatrix approximation (IPA) algorithm.gnm_solve: Compute mixed-action Nash equilibria of an N-player normal form game with the global Newton method (GNM) algorithm.
Example usage
import quantecon.game_theory as gt
import jlgametheory as jgt
lrsnash
lrsnash calls the Nash equilibrium computation routine in lrslib
(through its Julia wrapper LRSLib.jl):
bimatrix = [[(3, 3), (3, 2)],
[(2, 2), (5, 6)],
[(0, 3), (6, 1)]]
g = gt.NormalFormGame(bimatrix)
jgt.lrsnash(g)
[(array([Fraction(4, 5), Fraction(1, 5), Fraction(0, 1)], dtype=object),
array([Fraction(2, 3), Fraction(1, 3)], dtype=object)),
(array([Fraction(0, 1), Fraction(1, 3), Fraction(2, 3)], dtype=object),
array([Fraction(1, 3), Fraction(2, 3)], dtype=object)),
(array([Fraction(1, 1), Fraction(0, 1), Fraction(0, 1)], dtype=object),
array([Fraction(1, 1), Fraction(0, 1)], dtype=object))]
support_enumeration
support_enumeration computes all Nash equilibria of an N-player regular game with N >= 3
by support enumeration, where the polynomial equations for each support profile are solved by using
HomotopyContinuation.jl:
g = gt.NormalFormGame((2, 2, 2))
g[0, 0, 0] = 9, 8, 12
g[1, 1, 0] = 9, 8, 2
g[0, 1, 1] = 3, 4, 6
g[1, 0, 1] = 3, 4, 4
jgt.support_enumeration(g)
[(array([1., 0.]), array([1., 0.]), array([1., 0.])),
(array([1., 0.]), array([0., 1.]), array([0., 1.])),
(array([0., 1.]), array([1., 0.]), array([0., 1.])),
(array([0., 1.]), array([0., 1.]), array([1., 0.])),
(array([0., 1.]), array([0.333, 0.667]), array([0.333, 0.667])),
(array([0.25, 0.75]), array([1., 0.]), array([0.25, 0.75])),
(array([0.5, 0.5]), array([0.5, 0.5]), array([1., 0.])),
(array([0.25, 0.75]), array([0.5, 0.5]), array([0.333, 0.667])),
(array([0.5, 0.5]), array([0.333, 0.667]), array([0.25, 0.75]))]
ipa_solve and gnm_solve
ipa_solve and gnm_solve call the iterated polymatrix approximation (IPA) and
global Newton method (GNM) routines in GameTracer
(through its Julia wrapper GameTracer.jl):
g = gt.NormalFormGame((2, 2, 2))
g[0, 0, 0] = 9, 8, 12
g[1, 1, 0] = 9, 8, 2
g[0, 1, 1] = 3, 4, 6
g[1, 0, 1] = 3, 4, 4
jgt.ipa_solve(g, rng=1)
(array([0.25, 0.75]), array([0.5, 0.5]), array([0.333, 0.667]))
jgt.gnm_solve(g, rng=42)
[(array([1., 0.]), array([0., 1.]), array([0., 1.])),
(array([0.5, 0.5]), array([0.333, 0.667]), array([0.25, 0.75])),
(array([1., 0.]), array([1., 0.]), array([1., 0.])),
(array([0.5, 0.5]), array([0.5, 0.5]), array([1., 0.])),
(array([0.25, 0.75]), array([0.5, 0.5]), array([0.333, 0.667])),
(array([0.25, 0.75]), array([1., 0.]), array([0.25, 0.75])),
(array([0., 1.]), array([1., 0.]), array([0., 1.])),
(array([0., 1.]), array([0.333, 0.667]), array([0.333, 0.667])),
(array([0., 1.]), array([0., 1.]), array([1., 0.]))]
Tutorials
Metadata
Release files for jlgametheory 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jlgametheory-0.4.0.tar.gz | 9.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jlgametheory-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / jlgametheory-0.4.0.tar.gz
| Download URL | jlgametheory-0.4.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ed0e09a175868d7dc0018137ca2005e07d5e590fb424d109e8776aa6ad9f78a
|
|
BLAKE2b-256 checksum How to use checksums |
54ac74f79a48882f6fce679064335010f9adfbd7c073e3d7be364a3575e04df2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / jlgametheory-0.4.0-py3-none-any.whl
| Download URL | jlgametheory-0.4.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa8903da5ecff2df2e0178ad0c722bf703d106aad65afa30d93bd631fab59ff1
|
|
BLAKE2b-256 checksum How to use checksums |
d275dc7725d972bf43bf98f8ded485490b621c3dbf6778bfd4aa94cf0393e031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|