Skip to main content

Python PPL wrapper

Project description

This Python package provides a wrapper to the C++ Parma Polyhedra Library (PPL).

The whole package started as a fork of a tiny part of the Sage software.

How it works

The names of objects and methods are the same as in the library:

>>> import ppl
>>> x = ppl.Variable(0)
>>> y = ppl.Variable(1)
>>> z = ppl.Variable(2)
>>> cs = ppl.Constraint_System()
>>> cs.insert(x >= 0)
>>> cs.insert(y >= 0)
>>> cs.insert(z >= 0)
>>> cs.insert(x + y + z == 1)
>>> poly = ppl.C_Polyhedron(cs)
>>> poly.minimized_generators()
Generator_System {point(1/1, 0/1, 0/1), point(0/1, 1/1, 0/1), point(0/1, 0/1, 1/1)}

The available objects and functions from the ppl Python module are:

  • Variable, Variables_Set, Linear_Expression (defined in ppl.linear_algebra)

  • MIP_Problem (defined in ppl.mip_problem)

  • C_Polyhedron, NNC_Polyhedron (defined in ppl.polyhedron)

  • Generator, Generator_System, Poly_Gen_Relation, point, closure_point, ray, line (defined in ppl.generator)

  • Constraint, Constraint_System, Poly_Con_Relation, inequality, equation, strict_inequality (defined in ppl.constraint)

Installation

The project is available at Python Package Index and can be installed with pip:

$ pip install pplpy

Note that if you have gmp and ppl installed in a non standard directory (e.g. you use brew on MacOSX) then you need to set appropriately the variables CFLAGS before calling pip. For example:

$ export CFLAGS="-I/path/to/gmp/include/ -L/path/to/gmp/lib/ -I/path/to/ppl/include/ -L/path/to/ppl/lib $CFLAGS"
$ pip install pplpy

Using from Cython

All Python classes from pplpy are extension types and can be used with Cython. Each extension type carries an attribute thisptr that holds a pointer to the corresponding C++ object from ppl.

A complete example is provided with the files tests/testpplpy.pyx and tests/setup.py.

Source

You can find the latest version of the source code on github: https://github.com/sagemath/pplpy

Documentation

An online version of the documentation is available at https://www.sagemath.org/pplpy/

Compiling the html documentation requires make and sphinx. Before building the documentation, you need to install the pplpy package (sphinx uses Python introspection). The documentation source code is contained in the repository docs where there is a standard Makefile with a target html. Running make html in the docs repository builds the documentation inside docs/build/html. For more configuration options, run make help.

License

pplpy is distributed under the terms of the GNU General Public License (GPL) published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. See http://www.gnu.org/licenses/.

Requirements

On Debian/Ubuntu systems the dependencies can be installed with:

$ sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev libppl-dev cython3 python3-gmpy2 python3-cysignals-pari

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

pplpy-0.8.9.tar.gz (66.0 kB view details)

Uploaded Source

File details

Details for the file pplpy-0.8.9.tar.gz.

File metadata

  • Download URL: pplpy-0.8.9.tar.gz
  • Upload date:
  • Size: 66.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for pplpy-0.8.9.tar.gz
Algorithm Hash digest
SHA256 db7a3b571d6ef053f75137975e947c3a1c1e45a30bab90eaf215b4e5cc15797e
MD5 220fc7ab95d7bd62d40acb276f9b149f
BLAKE2b-256 72a68f5ff229ee82cec9d1e7d2507e6eba492350faf50ae41beb76ef0a7f34a7

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