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.
  • 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.
  • nash_cp: Compute one mixed-action Nash equilibrium of an N-player normal form game by solving the complementarity problem formulation as a nonlinear program.
  • nash_se: Compute mixed-action Nash equilibria of an N-player normal form game by support enumeration, solving the indifference conditions on each support profile with linear or nonlinear programming.

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

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.4.1
File Size Uploaded Provenance Actions
jlgametheory-0.4.1.tar.gz 10.8 kB Without provenance Details for jlgametheory-0.4.1.tar.gz

Built distribution (wheel)

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

Total release size: 21.9 kB

Release files / jlgametheory-0.4.1.tar.gz

Download URL jlgametheory-0.4.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6dce05ee70afca06ab57f3c82487d1eaa0d549bf6bc49b677004ef11946a79ff
BLAKE2b-256 checksum
How to use checksums
31d8446b0d799a5cbe86c10e6e6b5f72d8e3d28d0aa9f23b67ebc4bd527a35bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / jlgametheory-0.4.1-py3-none-any.whl

Download URL jlgametheory-0.4.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e36e819625f5ad3d8e831b88bb5c3998ec6dd41591a0e3532454681f618202c7
BLAKE2b-256 checksum
How to use checksums
136b075e80f4d90d5231a1cd86059fecc721213dc41d6b0806392d9d720bb455
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for jlgametheory 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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