Duality
Functions to switch between halfspace and vertex representations.
- pypoman.duality.compute_cone_face_matrix(S: ndarray) ndarray
Compute the face matrix of a polyhedral cone from its span matrix.
- Parameters:
S – Span matrix defining the cone as \(x = S \lambda\) with \(\lambda \geq 0\).
- Returns:
Face matrix defining the cone equivalently by \(F x \leq 0\).
- pypoman.duality.compute_polytope_halfspaces(vertices: List[ndarray]) ndarray | Tuple[ndarray, ndarray]
Compute the halfspace representation (H-rep) of a polytope.
The polytope is defined as convex hull of a set of vertices:
\[A x \leq b \quad \Leftrightarrow \quad x \in \mathrm{conv}(\mathrm{vertices})\]- Parameters:
vertices – List of polytope vertices.
- Returns:
Tuple
(A, b)
of the halfspace representation, or empty array if it is empty.
- pypoman.duality.compute_polytope_vertices(A: ndarray, b: ndarray) List[ndarray]
Compute the vertices of a polytope.
The polytope is given in halfspace representation by \(A x \leq b\).
- Parameters:
A – Matrix of halfspace representation.
b – Vector of halfspace representation.
- Returns:
List of polytope vertices.
Notes
This method won’t work well if your halfspace representation includes equality constraints \(A x = b\) written as \((A x \leq b \wedge -A x \leq -b)\). If this is your use case, consider using directly the linear set
lin_set
of equality-constraint generatorsin pycddlib.
- pypoman.duality.convex_hull(points: List[ndarray]) List[ndarray]
Compute the convex hull of a set of points.
- Parameters:
points – Set of points.
- Returns:
List of polytope vertices.