Skip to main content

A Python library for manipulating, plotting and computing with polyhedral and ellipsoidal sets.

Project description

Geomin

Python library for manipulating, plotting and computing with polyhedral and ellipsoidal sets. It is a relatively thin wrapper around Pycddlib, including some utility functions for convenience.

Installation

(The following assume you have already created a Python virtual environment)

Option 1. Install directly from PyPI:

pip install geomin

This does assume some prerequisites for pycddlib have already been installed. See their documentation for more information.

Option 2. Clone the repo and from within its root, run

pip install .

Usage

Creation of polytopes

From inequalities

Use the Polyhedron.from_inequalities method to build a polyhedron $X$ from a system of linear inequalities

$$ X = { x \in \mathbb{R}^n \mid H x \le h }. $$

For example, to represent the system

$$ \begin{cases} x_1 \ge -1 \ x_2 \ge -1 \ x_1 + x_2 \le 1 \end{cases} $$

You would write

import geomin as gp
import numpy as np

H = np.vstack([-np.eye(2), np.ones((1,2))])
h = np.array([1., 1., 1.])
poly = gp.Polyhedron.from_inequalities(H, h)

From vertices

Alternatively, a polyhedron can be constructed as the convex hull of a list of vertices.

import geomin as gp
import numpy as np

verts = np.array([(0, 0), (1, 0), (0, 1)])
poly = gp.Polyhedron.from_generators(verts)

Creation of ellipsoids

An ellipsoid created as gp.Ellipsoid(Q, c) represents

$$ { x: (x - c)^\top Q (x - c) \leq 1 }. $$

The argument $c$ is optional and is assumed to be $0$ by default.

Plotting

We provide some functions for easy plotting of sets, built on Matplotlib. Check the examples folder for more.

import matplotlib.pyplot as plt

# basic usage
plot_polytope(poly)

# Or with some styling
plt.figure()

plot_polytope(
    poly,
    color="tab:green",  # base color
    alpha=0.5,          # transparency
)

plt.show()

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

geomin-0.0.5.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

geomin-0.0.5-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file geomin-0.0.5.tar.gz.

File metadata

  • Download URL: geomin-0.0.5.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for geomin-0.0.5.tar.gz
Algorithm Hash digest
SHA256 85cace990f2bc375e25f9dd353b02b029556cb239f75198c255fda8f44acd6bc
MD5 2c3456c8ff91ae7563dc7957de5313a5
BLAKE2b-256 841adad933d1c4fbd5e7f915d836b25674875a33835a67c85790b72778123857

See more details on using hashes here.

Provenance

The following attestation bundles were made for geomin-0.0.5.tar.gz:

Publisher: wheels.yaml on kul-optec/geomin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file geomin-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: geomin-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for geomin-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c8d4303f35d80209e2078cb5be4b040051eabf1615c1c9b42842dacdfe618887
MD5 820ecba29b1f2f5966e45d44f11b25b6
BLAKE2b-256 7b894c3a0689a459bbf6b6192d33a870863629055d7b12ebb5e3896e9bb8490d

See more details on using hashes here.

Provenance

The following attestation bundles were made for geomin-0.0.5-py3-none-any.whl:

Publisher: wheels.yaml on kul-optec/geomin

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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