Skip to main content

Python interface to GameTheory.jl

Project description

jlgametheory

Build Status Coverage Status Documentation (stable) Documentation (latest)

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

Implemented functions

  • lrsnash: Compute in exact arithmetic all extreme mixed-action Nash equilibria of a 2-player normal form game with integer payoffs.
  • hc_solve: Compute all isolated mixed-action Nash equilibria of an N-player normal form game.

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))]

hc_solve

hc_solve computes all isolated Nash equilibria of an N-player game 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.hc_solve(g)
[(array([0., 1.]), array([0., 1.]), array([1., 0.])),
 (array([0.5, 0.5]), array([0.5, 0.5]), array([1.000e+00, 2.351e-38])),
 (array([1., 0.]), array([0., 1.]), array([-1.881e-37,  1.000e+00])),
 (array([0.25, 0.75]), array([0.5, 0.5]), array([0.333, 0.667])),
 (array([0.25, 0.75]), array([1.000e+00, 1.345e-43]), array([0.25, 0.75])),
 (array([0., 1.]), array([0.333, 0.667]), array([0.333, 0.667])),
 (array([1., 0.]), array([ 1.00e+00, -5.74e-42]), array([1., 0.])),
 (array([0., 1.]), array([1., 0.]), array([2.374e-66, 1.000e+00])),
 (array([0.5, 0.5]), array([0.333, 0.667]), array([0.25, 0.75]))]

Tutorials

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jlgametheory-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jlgametheory-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file jlgametheory-0.1.1.tar.gz.

File metadata

  • Download URL: jlgametheory-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jlgametheory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 97ba684303dad9e624b3437c9b273810e0518a85feb416ce69170c7fa0c96144
MD5 7f6e09393fa9bd1022863d9c98cf2f95
BLAKE2b-256 e718dd1ade5dfec867c78594d1fcaa0044ace1198c7fda832c91a344b4382cd1

See more details on using hashes here.

File details

Details for the file jlgametheory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: jlgametheory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jlgametheory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb753bf89426fb86f010a9dac3d626ffa47646097d54017c182b62ae1ad0562
MD5 6d1ee6513afc50481c6975a769638e25
BLAKE2b-256 ee5c3196d58a88ae1d8b393e2f2ac08a92370d2f094dd5ffa366f06f3d40ebdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page