Skip to main content

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

Project description

About SageMath

“Creating a Viable Open Source Alternative to

Magma, Maple, Mathematica, and MATLAB”

Copyright (C) 2005-2024 The Sage Development Team

https://www.sagemath.org

SageMath fully supports all major Linux distributions, recent versions of macOS, and Windows (Windows Subsystem for Linux).

See https://doc.sagemath.org/html/en/installation/index.html for general installation instructions.

About this pip-installable distribution

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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[graphs,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[graphs,groups,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[graphs,toric,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[latte,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[normaliz,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[cddlib,test]" ipython

In [1]: from sage.all__sagemath_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 --pip-args="--prefer-binary" --spec "passagemath-polyhedra[flint,lrslib,test]" ipython

In [1]: from sage.all__sagemath_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 JuPyMake

This currently requires a separate installation of polymake.

Optional backends for optimization

pip install “passagemath-polyhedra[cbc]”

COIN/OR CBC Mixed Integer Linear Optimization solver, via sage_numerical_backends_coin

pip install “passagemath-polyhedra[cplex]”

CPLEX Mixed Integer Optimization solver (proprietary; requires licensed installation), via sage_numerical_backends_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 sage_numerical_backends_gurobi

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 Distribution

passagemath_polyhedra-10.4.65.tar.gz (987.4 kB view details)

Uploaded Source

Built Distributions

passagemath_polyhedra-10.4.65-cp312-cp312-musllinux_1_2_x86_64.whl (13.3 MB view details)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

passagemath_polyhedra-10.4.65-cp312-cp312-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

passagemath_polyhedra-10.4.65-cp312-cp312-macosx_13_0_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12 macOS 13.0+ x86-64

passagemath_polyhedra-10.4.65-cp311-cp311-musllinux_1_2_x86_64.whl (13.5 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

passagemath_polyhedra-10.4.65-cp311-cp311-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

passagemath_polyhedra-10.4.65-cp311-cp311-macosx_13_0_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.11 macOS 13.0+ x86-64

passagemath_polyhedra-10.4.65-cp310-cp310-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

passagemath_polyhedra-10.4.65-cp310-cp310-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

passagemath_polyhedra-10.4.65-cp310-cp310-macosx_13_0_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.10 macOS 13.0+ x86-64

passagemath_polyhedra-10.4.65-cp39-cp39-musllinux_1_2_x86_64.whl (12.8 MB view details)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

passagemath_polyhedra-10.4.65-cp39-cp39-macosx_14_0_arm64.whl (6.9 MB view details)

Uploaded CPython 3.9 macOS 14.0+ ARM64

passagemath_polyhedra-10.4.65-cp39-cp39-macosx_13_0_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9 macOS 13.0+ x86-64

File details

Details for the file passagemath_polyhedra-10.4.65.tar.gz.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65.tar.gz
Algorithm Hash digest
SHA256 1f52acc7c04ce1d5c6cc9918e4227091b85fb94829ee1dc3c2ad44d202894c72
MD5 70eea38d43da23e7a7e5080f46109a4d
BLAKE2b-256 30de0fc40492cc0ea82ca90c52d3d613c1bfef83027ccaad7e2b1af56e88b9d3

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a13a0cfbf68ef1c5039cba8358a1e4b0c3eed473a3c2e7f044847b569616655f
MD5 4e460d07f3d8fc16319b613dc918f51d
BLAKE2b-256 49cfad3c37bc0ca75fc884b14147d60121d9dedb96f7d57ab24794b56190cd09

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 7cedec1032831047de13ba08e10953fa1dbe54185fc6b159d2f04894df0a16d1
MD5 78b9c4e5faa4c92ea991d1a61c6400c5
BLAKE2b-256 c5326faa6024e59eafc70d9e093c8e9f70993ae9c03ea5c3ecd202790307dc43

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp312-cp312-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp312-cp312-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 546bf17be2d9e39102c7d408eab092463b097ccd06bdd0aa9410c7900f739188
MD5 72841ac7eb39e09551ce765b54d6e1bb
BLAKE2b-256 7b58a9d9d94693cf566bc976cb10c546a1f57a4eaf69370cf9ff26b2bb213a0c

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 83c4256b410f2801a272d2424987ae17f9b0b1762368cd67b5f8bf98d056d4c3
MD5 d853b3237be54c19305a45cbbc7ea519
BLAKE2b-256 bdaaec0aaafd2244f93a1a0a59cd62682d5a6d945261ec5e9b4b44322ceb9457

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 79946a9fef17a2d20dfb151cea781944b1f0c39a7d9280643ad79eb7db0d27de
MD5 870c4f56f3175120165678f4ec3454eb
BLAKE2b-256 020c184961097a6222186b5a689fe3565f3a03e12b72c064dd1cb6dcddbe15a9

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp311-cp311-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp311-cp311-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 a5cf7acd7dcd48d42b18a84da761ee5087f5ada583639d72a8efa64eac70e331
MD5 2098c6b28280ceb76a53d38f3253976d
BLAKE2b-256 fbeecbb111f2ff4708764a748ac18140bef32a2b2d2610e493923d26aaf1cdd0

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d0f5fc95476eb78c54f0c97c678382635d767cca4b82374717bf5fab2f2220c2
MD5 52efe10b8ea8b0669c7046ef6f55fead
BLAKE2b-256 ae281c0699b11a6efbecab31b9f8d4a53f12cb7a059d13086cc3cf1ccdf0e9f3

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 038c30cfe3bae68aa7f8a2a3397ac2f3608dd02800816e43c603c7a79ac40a8a
MD5 6cb254c19ab3de38efbe134bc49f87fa
BLAKE2b-256 122784674684823aef0cbf45e91a1f291bf1e20c82c40d5d8b23f152d1e2730c

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp310-cp310-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp310-cp310-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 ac926beded736a8b637c1a83bebb1a66563308a10fd15ae828a1a9dc6bd2043a
MD5 4e036150e0c7f4834323da3a9279e20d
BLAKE2b-256 4705fd7fc8fbda785d2a5bab82cbb7320bc4bd539e0fd707d4515e712f71e557

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b7c7928a209e0d03deebc6180fbceffe81bc8cf8ce7749af22207805794263e4
MD5 66eff5578c94d887ff0fefb230f2ecb2
BLAKE2b-256 d8fbe5b560cad60a61eddd114723a07d66bb82cf2f4d6654fba76f6c5d4b1221

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 f8de903b8c67a34dedf0b663f0af807c0f94b3826a4a40b19cee1de99e4e56c4
MD5 57f7c5b888a6731478ff21b5259bdaa3
BLAKE2b-256 1711cf4cfb1045694ca1085fe873072907faf32049c694b339b033ed813f9aa4

See more details on using hashes here.

File details

Details for the file passagemath_polyhedra-10.4.65-cp39-cp39-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for passagemath_polyhedra-10.4.65-cp39-cp39-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 faa1186f510bc340319120963d6a627377b3dbb88f42a59b4acadbd2211927a3
MD5 d5a870da60dc8974a18ee55852752d6a
BLAKE2b-256 5ae7c954bde49f34693adbce3a030c089b88119c28c60eac8f0b849464b671e4

See more details on using hashes here.

Supported by

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