Skip to main content

jlgametheory

Build Status Coverage Status Documentation (stable) Documentation (latest) PyPI - Version Conda Version

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.
  • hc_solve: Compute all isolated mixed-action Nash equilibria of an N-player normal form game with the polynomial 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))]

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

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.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jlgametheory 0.2.0
File Size Uploaded
jlgametheory-0.2.0.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jlgametheory 0.2.0
File Interpreter ABI Platform
jlgametheory-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.3 kB

Release files / jlgametheory-0.2.0.tar.gz

Download URL jlgametheory-0.2.0.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d62f343fb6760726fa887bce9b27caa2e07def1799c30f12fa2f62ac446a109c
BLAKE2b-256 checksum
How to use checksums
c6841b5af32ee55cee73dd11511f3f063f8705aabc4c818831d3fe73c4c25758
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.2.0-py3-none-any.whl

Download URL jlgametheory-0.2.0-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c21b06255e584724c49a74742225cd1f6467ec1583c29da415b41ee8d1c12881
BLAKE2b-256 checksum
How to use checksums
8f22595c57ec00bd98617e97bf0dce28c7159961720dcafd2ec492714d5fc27d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.4.0

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page