Dual description of polytopes.
Project description
dualdesc
Dual description for polytopes. A wrapper around pycddlib. Mainly for easily converting between H- and V-representations. No utilities for facet enumeration, adjacencies, etc.
Usage
This package contains two classes, HRepr
and VRepr
, for the H- and V-representations of polytopes.
They have methods to_v()
and to_h()
, respectively, for converting between them.
HRepr(Au, bu, Ae, be)
represents the polytope defined by all points x
s.t. Au @ x <= bu
and Ae @ x == be
.
Au
, bu
(inequality constraints) and Ae
, be
(equality constraints) are also fields on the HRepr
object.
If there are nu
inequality and ne
equality constraints, and the ambient dimension is d
,
the shapes of these matrices are:
Au
:(nu, d)
bu
:(d,)
Ae
:(ne, d)
be
:(d,)
VRepr(Vc, Vn, Vl)
represents the polytope defined by conv(Vc) + nonneg(Vn) + linspace(Vl)
,
where conv
is the convex combination of a set of points, nonneg
is non-negative linear combinations
of a set of points, linspace
is a linear combination of a set of points, and +
is Minkowski addition.
A simple example
The example below defines an unbounded (i.e. non-null cone part) polytope with 3 facets and 2 vertices:
import numpy as np
import dualdesc as dd
M = np.array([
[1, 0, 1], # x0 <= 1
[0, 2, 1], # 2 x1 <= 1
[1, 1, 1], # x0 + x1 <= 1
], dtype = np.float64)
Au = M[:,:2]
bu = M[:,-1]
h = dd.HRepr(Au, bu)
v = h.to_v()
# Vertices (conv component):
# v.Vc = [[0.5, 0.5], [1, 0]]
# Cone part (nonneg and linear components):
# v.Vn = [[-1, 0], [0, -1]]
# v.Vl = []
Why not pypoman?
pypoman has more features, but only supports bounded polytopes.
Why not use pycddlib directly?
pycddlib has more features (like adjacency lists), but is too low level and doesn't have a nice interface.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.