Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions build/pkgs/gambit/SPKG.rst

This file was deleted.

4 changes: 0 additions & 4 deletions build/pkgs/gambit/checksums.ini

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gambit/distros/homebrew.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gambit/distros/repology.txt

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gambit/package-version.txt

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions build/pkgs/gambit/spkg-install.in

This file was deleted.

1 change: 0 additions & 1 deletion build/pkgs/gambit/type

This file was deleted.

18 changes: 18 additions & 0 deletions build/pkgs/pygambit/SPKG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pygambit: The package for computation in game theory
====================================================

Description
-----------

The package for computation in game theory

License
-------

GPL2+

Upstream Contact
----------------

https://pypi.org/project/pygambit/

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cython | $(PYTHON_TOOLCHAIN) $(PYTHON)
numpy scipy | $(PYTHON_TOOLCHAIN) cython $(PYTHON)

----------
All lines of this file are ignored except the first.
File renamed without changes.
1 change: 1 addition & 0 deletions build/pkgs/pygambit/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pygambit
1 change: 1 addition & 0 deletions build/pkgs/pygambit/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
optional
4 changes: 4 additions & 0 deletions src/doc/en/developer/sage_manuals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ by Sage, you can link toward it without specifying its full path:
- ``:ppl:`Linear_Expression <classParma__Polyhedra__Library_1_1 Linear__Expression>```
- :ppl:`Linear_Expression <classParma__Polyhedra__Library_1_1Linear__Expression>`

* - :ref:`pygambit <spkg_pygambit>`
- ``:pygambit:`pygambit.nash.lcp_solve```
- :pygambit:`pygambit.nash.lcp_solve`

* - :ref:`QEPCAD <spkg_qepcad>`
- ``:qepcad:`QEPCAD: Entering formulas <user/EnterForm>```
- :qepcad:`QEPCAD: Entering formulas <user/EnterForm>`
Expand Down
42 changes: 42 additions & 0 deletions src/sage/features/gambit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# sage_setup: distribution = sagemath-environment
r"""
Check for pygambit
"""

# ****************************************************************************
# Copyright (C) 2024 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************

from . import PythonModule


class pygambit(PythonModule):
r"""
A :class:`sage.features.Feature` describing the presence of the
Python package :ref:`pygambit <spkg_pygambit>`.

EXAMPLES::

sage: from sage.features.gambit import pygambit
sage: pygambit().is_present() # optional - pygambit
FeatureTestResult('pygambit', True)
"""
def __init__(self):
r"""
TESTS::

sage: from sage.features.gambit import pygambit
sage: isinstance(pygambit(), pygambit)
True
"""
PythonModule.__init__(self, 'pygambit', spkg="pygambit")


def all_features():
return [pygambit()]
22 changes: 11 additions & 11 deletions src/sage/game_theory/gambit_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

Here is an example that constructs the Prisoner's Dilemma::

In [1]: import gambit
In [2]: g = gambit.Game.new_table([2,2])
In [1]: import pygambit
In [2]: g = pygambit.Game.new_table([2,2])
In [3]: g.title = "A prisoner's dilemma game"
In [4]: g.players[0].label = "Alphonse"
In [5]: g.players[1].label = "Gaston"
Expand Down Expand Up @@ -79,16 +79,16 @@

Here is how to use the ``ExternalEnumPureSolver``::

In [21]: solver = gambit.nash.ExternalEnumPureSolver()
In [21]: solver = pygambit.nash.ExternalEnumPureSolver()
In [22]: solver.solve(g)
Out[22]: [<NashProfile for 'A prisoner's dilemma game': [Fraction(0, 1), Fraction(1, 1), Fraction(0, 1), Fraction(1, 1)]>]

Note that the above finds the equilibria by investigating all potential pure
pure strategy pairs. This will fail to find all Nash equilibria in certain
games. For example here is an implementation of Matching Pennies::

In [1]: import gambit
In [2]: g = gambit.Game.new_table([2,2])
In [1]: import pygambit
In [2]: g = pygambit.Game.new_table([2,2])
In [3]: g[0, 0][0] = 1
In [4]: g[0, 0][1] = -1
In [5]: g[0, 1][0] = -1
Expand All @@ -97,13 +97,13 @@
In [8]: g[1, 0][1] = 1
In [9]: g[1, 1][0] = 1
In [10]: g[1, 1][1] = -1
In [11]: solver = gambit.nash.ExternalEnumPureSolver()
In [11]: solver = pygambit.nash.ExternalEnumPureSolver()
In [12]: solver.solve(g)
Out[12]: []

If we solve this with the ``LCP`` solver we get the expected Nash equilibrium::

In [13]: solver = gambit.nash.ExternalLCPSolver()
In [13]: solver = pygambit.nash.ExternalLCPSolver()
In [14]: solver.solve(g)
Out[14]: [<NashProfile for '': [0.5, 0.5, 0.5, 0.5]>]

Expand All @@ -116,9 +116,9 @@
converted to Python integers (due to the preparser). Here is an example
showing the Battle of the Sexes::

sage: # optional - gambit
sage: import gambit
sage: g = gambit.Game.new_table([2,2])
sage: # optional - pygambit
sage: import pygambit
sage: g = pygambit.Game.new_table([2,2])
sage: g[int(0), int(0)][int(0)] = int(2)
sage: g[int(0), int(0)][int(1)] = int(1)
sage: g[int(0), int(1)][int(0)] = int(0)
Expand All @@ -127,7 +127,7 @@
sage: g[int(1), int(0)][int(1)] = int(0)
sage: g[int(1), int(1)][int(0)] = int(1)
sage: g[int(1), int(1)][int(1)] = int(2)
sage: solver = gambit.nash.ExternalLCPSolver()
sage: solver = pygambit.nash.ExternalLCPSolver()
sage: solver.solve(g)
[<NashProfile for '': [[1.0, 0.0], [1.0, 0.0]]>,
<NashProfile for '': [[0.6666666667, 0.3333333333], [0.3333333333, 0.6666666667]]>,
Expand Down
Loading