Projection

Polytope projection functions.

pypoman.projection.project_point_to_polytope(point: ndarray, ineq: Tuple[ndarray, ndarray], qpsolver: str, **kwargs) ndarray

Projet a point onto a polytope in H-representation.

Parameters:
  • point – Point to project.

  • ineq – Pair (A, b) describing the inequality constraint.

  • qpsolver – Name of the backend quadratic programming solver to use, to be picked in qpsolvers.available_solvers.

Returns:

Projected point.

Note

This function requires qpsolvers.

pypoman.projection.project_polyhedron(proj: Tuple[ndarray, ndarray], ineq: Tuple[ndarray, ndarray], eq: Tuple[ndarray, ndarray] | None = None, canonicalize: bool = True) Tuple[List[ndarray], List[ndarray]]

Apply the affine projection \(y = E x + f\) to a polyhedron.

The polyhedron is defined by:

\[\begin{split}\begin{split}\begin{array}{ll} A x & \leq b \\ C x & = d \end{array}\end{split}\end{split}\]
Parameters:
  • proj – Pair (E, f) describing the affine projection.

  • ineq (pair of arrays) – Pair (A, b) describing the inequality constraint.

  • eq (pair of arrays, optional) – Pair (C, d) describing the equality constraint.

  • canonicalize (bool, optional) – Apply equality constraints from eq to reduce the dimension of the input polyhedron. May be a blessing or a curse, see notes below.

Returns:

  • vertices (list of arrays) – List of vertices of the projection.

  • rays (list of arrays) – List of rays of the projection.

Notes

When the equality set eq of the input polytope is not empty, it is usually faster to use these equality constraints to reduce the dimension of the input polytope (cdd function: canonicalize()) before enumerating vertices (cdd function: get_generators()). Yet, on some descriptions this operation may be problematic: if it fails, or if you get empty outputs when the output is supposed to be non-empty, you can try setting canonicalize=False.

See also

This

pypoman.projection.project_polytope(proj, ineq, eq=None, method='cdd', **kwargs)

Apply the affine projection \(y = E x + f\) to a polytope.

The polytope is defined by:

\[\begin{split}A x & \leq b \\ C x & = d\end{split}\]
Parameters:
  • proj (pair of arrays) – Pair (E, f) describing the affine projection.

  • ineq (pair of arrays) – Pair (A, b) describing the inequality constraint.

  • eq (pair of arrays, optional) – Pair (C, d) describing the equality constraint.

  • method (string, optional) – Choice between ‘bretl’ and ‘cdd’.

Returns:

vertices – List of vertices of the projection.

Return type:

list of arrays

Note

Additional keyword arguments can be provided when the method is ‘bretl’. They are passed directly to the corresponding function pypoman.projection.project_polytope_bretl().

Notes

The number of columns of all matrices A, C and E corresponds to the dimension of the input space, while the number of lines of E corresponds to the dimension of the output space.

pypoman.projection.project_polytope_bretl(proj: Tuple[ndarray, ndarray], ineq: Tuple[ndarray, ndarray], eq: Tuple[ndarray, ndarray], max_radius: float = 100000.0, max_iter: int = 1000, init_angle: float | None = None) List[ndarray]

Project a polytope into a 2D polygon using the IP algorithm.

The incremental projection algorithm is detailed in [Bretl08]. The 2D affine projection \(y = E x + f\) is applied to the polyhedron defined by:

\[\begin{split}A x & \leq b \\ C x & = d\end{split}\]
Parameters:
  • proj – Pair (E, f) describing the affine projection.

  • ineq – Pair (A, b) describing the inequality constraint.

  • eq – Pair (C, d) describing the equality constraint.

  • max_radius – Maximum distance from origin (in [m]) used to make sure the output is bounded.

  • max_iter – Maximum number of calls to the LP solver.

  • init_angle – Angle in [rad] giving the direction of the initial ray cast.

Returns:

List of vertices of the projected polygon.