Skip to main content

passagemath: Convex polyhedra in arbitrary dimension, mixed integer linear optimization

Project description

passagemath is open source mathematical software in Python, released under the GNU General Public Licence GPLv2+.

It is a fork of SageMath, which has been developed 2005-2026 under the motto “Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, and MATLAB”.

The passagemath fork uses the motto “Creating a Free Passage Between the Scientific Python Ecosystem and Mathematical Software Communities.” It was created in October 2024 with the following goals:

Moreover, the passagemath project:

  • provides a stable, frequently updated version of the Sage distribution,

  • integrates additional mathematical software, notably Macaulay2, a full set of GAP packages, and the Combinatorial Matrix Recognition library,

  • curates a library of Sage user packages.

Full documentation is available online.

passagemath attempts to support and provides binary wheels suitable for all major Linux distributions and recent versions of macOS.

Binary wheels for native Windows (x86_64, ARM) are are available for a subset of the passagemath distributions. Use of the full functionality of passagemath on Windows currently requires the use of Windows Subsystem for Linux (WSL) or virtualization.

The supported Python versions in the passagemath-10.8.x series are 3.11.x-3.14.x; the passagemath-10.6.x series (EOL 2026-10) still supports Python 3.10.x.

About this pip-installable distribution package

This pip-installable distribution passagemath-polyhedra is a distribution of a part of the Sage Library. It provides a small subset of the modules of the Sage library (“sagelib”, passagemath-standard), sufficient for computations with convex polyhedra in arbitrary dimension (in exact rational arithmetic), and linear and mixed integer linear optimization (in floating point arithmetic).

What is included

Examples

A quick way to try it out interactively:

$ pipx run --spec "passagemath-polyhedra[test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: P = Polyhedron(ieqs=[[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 1, -1, -1, 1, 0], [0, 0, -1, 1, -1, 1, 0]], eqns=[[-31, 1, 1, 1, 1, 1, 1]]); P
Out[2]: A 5-dimensional polyhedron in QQ^6 defined as the convex hull of 7 vertices

In [3]: P.Vrepresentation()
Out[4]:
(A vertex at (31, 0, 0, 0, 0, 0),
 A vertex at (0, 0, 0, 0, 0, 31),
 A vertex at (0, 0, 0, 0, 31, 0),
 A vertex at (0, 0, 31/2, 0, 31/2, 0),
 A vertex at (0, 31/2, 31/2, 0, 0, 0),
 A vertex at (0, 31/2, 0, 0, 31/2, 0),
 A vertex at (0, 0, 0, 31/2, 31/2, 0))

Available as extras, from other distributions

Additional features

pip install "passagemath-polyhedra[graphs]"

Face lattices, combinatorial polyhedra, graph-theoretic constructions

$ pipx run --spec "passagemath-polyhedra[graphs,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: c5_10 = Polyhedron(vertices = [[i, i**2, i**3, i**4, i**5] for i in range(1, 11)]); c5_10
Out[2]: A 5-dimensional polyhedron in ZZ^5 defined as the convex hull of 10 vertices

In [3]: c5_10_fl = c5_10.face_lattice(); [len(x) for x in c5_10_fl.level_sets()]
Out[3]: [1, 10, 45, 100, 105, 42, 1]
pip install "passagemath-polyhedra[graphs,groups]"

Constructing symmetric polyhedra, computing automorphisms, lattice point counting modulo group actions

$ pipx run --spec "passagemath-polyhedra[graphs,groups,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: P24 = polytopes.twenty_four_cell(); P24
Out[2]: A 4-dimensional polyhedron in QQ^4 defined as the convex hull of 24 vertices

In [3]: AutP24 = P24.restricted_automorphism_group(); AutP24.order()
Out[3]: 1152
pip install "passagemath-polyhedra[toric]"

Toric varieties

$ pipx run --spec "passagemath-polyhedra[graphs,toric,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: TV3 = ToricVariety(NormalFan(lattice_polytope.cross_polytope(3))); TV3
Out[2]: 3-d toric variety covered by 6 affine patches

In [3]: TV3.is_orbifold()
Out[3]: False
pip install "passagemath-polyhedra[latte]"

Installs LattE integrale for lattice point counting and volume computation using generating function techniques.

$ pipx run --spec "passagemath-polyhedra[latte,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: P = polytopes.cube()

In [3]: P.integral_points_count()
Out[3]:
27

In [4]: (1000000000*P).integral_points_count(verbose=True)
This is LattE integrale...
...
Total time:...
Out[4]:
8000000012000000006000000001

Additional backends for polyhedral computations

pip install "passagemath-polyhedra[normaliz]"

Normaliz, via PyNormaliz, provides very fast computations in particular for polyhedra with data in algebraic number fields.

$ pipx run --spec "passagemath-polyhedra[normaliz,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: gap_norm = polytopes.grand_antiprism(backend='normaliz'); gap_norm

In [3]: gap_norm.f_vector()
pip install "passagemath-polyhedra[cddlib]"

cddlib provides support for computations with polyhedra in floating-point arithmetic.

$ pipx run --spec "passagemath-polyhedra[cddlib,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: P1 = polytopes.regular_polygon(5, exact=False); P1
Out[2]: A 2-dimensional polyhedron in RDF^2 defined as the convex hull of 5 vertices
pip install "passagemath-polyhedra[lrslib]"

lrslib can be used for polytope volume computations and for enumerating Nash equilibria.

$ pipx run --spec "passagemath-polyhedra[flint,lrslib,test]" ipython

In [1]: from passagemath_polyhedra import *

In [2]: A = matrix([[2, 1], [1, 5/2]]); B = matrix([[-1, 3], [2, 1]])

In [3]: g = NormalFormGame([A, B]); g.obtain_nash(algorithm='lrs')
Out[3]: [[(1/5, 4/5), (3/5, 2/5)]]
pip install "passagemath-polyhedra[polymake]"

Polymake, via passagemath-polymake

Optional backends for optimization

pip install "passagemath-polyhedra[cbc]"

COIN/OR CBC Mixed Integer Linear Optimization solver, via passagemath-coin-or-cbc

pip install "passagemath-polyhedra[cplex]"

CPLEX Mixed Integer Optimization solver (proprietary; requires licensed installation), via passagemath-cplex

pip install "passagemath-polyhedra[cvxpy]"

CVXPy as middle-end for various backends

pip install "passagemath-polyhedra[gurobi]"

Gurobi Mixed Integer Optimization solver (proprietary; requires licensed installation), via passagemath-gurobi

pip install "passagemath-polyhedra[highs]"

HiGHS

pip install "passagemath-polyhedra[scip]"

SCIP Mixed Integer Optimization solver, via PySCIPOpt

Development

$ git clone --origin passagemath https://github.com/passagemath/passagemath.git
$ cd passagemath
passagemath $ ./bootstrap
passagemath $ python3 -m venv polyhedra-venv
passagemath $ source polyhedra-venv/bin/activate
(polyhedra-venv) passagemath $ pip install -v -e pkgs/sagemath-polyhedra

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

passagemath_polyhedra-10.8.7-cp314-cp314t-macosx_13_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.14tmacOS 13.0+ ARM64

passagemath_polyhedra-10.8.7-cp314-cp314-macosx_13_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.14macOS 13.0+ ARM64

passagemath_polyhedra-10.8.7-cp313-cp313-macosx_13_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.13macOS 13.0+ ARM64

passagemath_polyhedra-10.8.7-cp312-cp312-macosx_13_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12macOS 13.0+ ARM64

passagemath_polyhedra-10.8.7-cp311-cp311-macosx_13_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.11macOS 13.0+ ARM64

File details

Details for the file passagemath_polyhedra-10.8.7-cp314-cp314t-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.8.7-cp314-cp314t-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 e4233b0036d00838be62c93cc65177d1f608316c948051eb431a7cc0310fe037
MD5 fa681a0bb2df7245548182787206c036
BLAKE2b-256 e9da38db2340074a2b67e2e335bfa54816fefadafa044ff76d2f46d97e95aefd

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.8.7-cp314-cp314-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.8.7-cp314-cp314-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 8a29ed7b3ed4cbb044fc8d6867001b3a71c36eb67cec1378e59fadabd4ca1cb4
MD5 c77e0400f0f63fd9ca2200b928673bf5
BLAKE2b-256 9ca503a505f712debfc3748d3d9f4239d9855467a3500e24850110674383ed3b

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.8.7-cp313-cp313-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.8.7-cp313-cp313-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 c16accd9257933e2fa38e2eb6709d9cb15fe98187c98c46c77ac74fb02b7a0ca
MD5 218d53206a9dbbd5eb9a0c7911d952e0
BLAKE2b-256 bbb85683829c203975f25f24c8e21c03527d07b2b0803815ea5cf65d896c6836

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.8.7-cp312-cp312-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.8.7-cp312-cp312-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 223bf92a5414627c99724ff9f3dc9d29898c346bf1ef268553f77c3649464326
MD5 ad20de7acea5ed029784cb9deb209297
BLAKE2b-256 8eb04783df2491b2aba5365b8a94d78001bfd0e54a028d76de518ecfb4f09ae4

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.8.7-cp311-cp311-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.8.7-cp311-cp311-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 2d772d733588a58d6ab21edfbea3b674c11d44d4c5ffb4561b334d66173cafec
MD5 2fd447008976b22d846485109ccb8d6b
BLAKE2b-256 d8b720bf5022c7de392abbb967623e49ede01450db7b1c6d838a4dd0d13459b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page