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.3.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.3.0
File Size Uploaded
jlgametheory-0.3.0.tar.gz 8.1 kB Details

Built distribution (wheel)

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

Total release size: 16.7 kB

Release files / jlgametheory-0.3.0.tar.gz

Download URL jlgametheory-0.3.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
99afe8a0f7c2899d894288cf83d18e632e3463db491c3236f3b560e5f0c0b03c
BLAKE2b-256 checksum
How to use checksums
0e3211b8bfbe57d2d96fd5db29d46c4194cda2a9e0695a7663e1c099ea83eb37
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.3.0-py3-none-any.whl

Download URL jlgametheory-0.3.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
190dd2b7785904bb0eb9be8a45048077cb30296449c581c014bc1f4bf3fd1162
BLAKE2b-256 checksum
How to use checksums
8bbf871908fd6029fe05dad17cd1fce6f9283b0c6501909de78f7007c4cd8403
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

This release

0.3.0 This release

2 release files

0.2.0

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