hc_solve

hc_solve(g, ntofind=inf, **options)[source]

Compute all isolated mixed-action Nash equilibria of an N-player normal form game.

This function solves a system of polynomial equations arising from the nonlinear complementarity problem representation of Nash equilibrium, by using HomotopyContinuation.jl.

Parameters

gNormalFormGame

N-player NormalFormGame instance.

ntofindscalar, optional(default=float(‘inf’))

Number of Nash equilibria to find.

options :

Optional keyword arguments to pass to HomotopyContinuation.solve. For example, the option seed can set the random seed used during the computations. See the documentation for HomotopyContinuation.solve for details.

Returns

NEslist(tuple(ndarray(float, ndim=1)))

List containing tuples of Nash equilibrium mixed actions.

Examples

Consider the 3-player 2-action game with 9 Nash equilibria in McKelvey and McLennan (1996) “Computation of Equilibria in Finite Games”:

>>> import quantecon.game_theory as gt
>>> import jlgametheory as jgt
>>> from pprint import pprint
>>> import numpy as np
>>> np.set_printoptions(precision=3)  # Reduce the digits printed
>>> 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
>>> print(g)
3-player NormalFormGame with payoff profile array:
[[[[ 9.,  8., 12.],   [ 0.,  0.,  0.]],
  [[ 0.,  0.,  0.],   [ 3.,  4.,  6.]]],

 [[[ 0.,  0.,  0.],   [ 3.,  4.,  4.]],
  [[ 9.,  8.,  2.],   [ 0.,  0.,  0.]]]]
>>> NEs = jgt.hc_solve(g, show_progress=False)
>>> len(NEs)
9
>>> pprint(NEs)
[(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]))]
>>> all(g.is_nash(NE) for NE in NEs)
True