pycapacity.polyhedral
Overview
Generic polyhedral methods for capacity polytopes, built on
pycddlib (double description) and
pypoman (Bretl-Lall
projection). Both are optional dependencies: pip install pycddlib pypoman.
They complement the capacity-specific algorithms of
pycapacity.algorithms with standard, general-purpose methods:
vertex_enumeration_dd: H- to V-representation with the double description method (cdd).
intersection_polytope_dd: vertices of \(\{x~|~Ax = y + b,~ y_{min} \leq y \leq y_{max}\}\) (e.g. robot force polytopes) via direct H-representation and cdd.
lifted_polytope: the unified form \(\{x~|~Ax = By + b,~ y \in P_y\}\) written as a polytope in the lifted space of \((x, y)\).
unified_polytope_dd: exact projection of the lifted polytope with cdd (any output dimension; cost grows with the input dimension).
unified_polytope_bretl: exact polygon (2D outputs) with the incremental projection of Bretl and Lall; cost grows with the size of the output polygon.
All functions accept the same arguments as
pycapacity.algorithms.iterative_convex_hull_method()
(A, B, y_min, y_max, optional P, bias, G_in, h_in, G_eq, h_eq).
- pycapacity.polyhedral.intersection_polytope_dd(A, y_min, y_max, bias=None)[source]
Vertices and half-spaces of the intersection-class polytope
\[P_x = \{x~ |~ Ax = y + b,\quad y_{min} \leq y \leq y_{max}\}\]using the direct H-representation (substitution) and the double description method. Same problem as
pycapacity.algorithms.vertex_enumeration_vepoli2().- Parameters:
A – matrix (n x m), full column rank, n >= m
y_min – input limits (n)
y_max – input limits (n)
bias – optional vector b (n)
- Returns:
x_vert(array) (m x n_v vertices)
H(array), d(array) (half-space representation H x <= d)
y_vert(array) (n x n_v inputs producing each vertex, y = A x - b)
- pycapacity.polyhedral.lifted_polytope(A, B, y_min, y_max, P=None, bias=None, G_in=None, h_in=None, G_eq=None, h_eq=None)[source]
The unified form
\[P_x = \{x~ |~Pz = x,~~ Az = By + b,~~ G_{in} y \leq h_{in},~~ G_{eq} y = h_{eq},~~ y_{min} \leq y \leq y_{max}\}\]as an affine projection of a polytope in the lifted variable \(w = (z, y)\), in the format used by
pypoman.project_polytope().- Returns:
proj (pair (E, f), x = E w + f)
ineq (pair (C_in, c_in), C_in w <= c_in)
eq (pair (C_eq, c_eq), C_eq w = c_eq)
- pycapacity.polyhedral.unified_polytope_bretl(A, B, y_min, y_max, P=None, bias=None, G_in=None, h_in=None, G_eq=None, h_eq=None, max_iter=1000, size=1000.0)[source]
Exact polygon of the unified form (see
lifted_polytope()) for two-dimensional outputs, with the incremental projection method of Bretl and Lall (through pypoman). Each iteration solves one LP in the lifted space; the number of iterations grows with the number of vertices of the output polygon, not with the input dimension.Note
pypoman’s implementation uses absolute tolerances (it stops refining an edge when the new triangle has an area below 1e-4, and merges output vertices closer than 1e-2). To make the result independent of the units, the output is first bounded with four LPs, then centred and scaled internally so that its bounding box has side
size.- Returns:
x_vert(array) (2 x n_v vertices)
H(array), d(array) (half-space representation H x <= d)
- pycapacity.polyhedral.unified_polytope_dd(A, B, y_min, y_max, P=None, bias=None, G_in=None, h_in=None, G_eq=None, h_eq=None)[source]
Exact vertices and half-spaces of the unified form (see
lifted_polytope()) by vertex enumeration of the lifted polytope with the double description method, followed by projection and a convex hull.Exact for any output dimension, but the cost grows with the number of vertices of the lifted polytope, i.e. with the input dimension: use it for small problems or as a reference.
- Returns:
x_vert(array) (m x n_v vertices)
H(array), d(array) (half-space representation H x <= d)