pycvxset.ConstrainedZonotope¶
- class pycvxset.ConstrainedZonotope(**kwargs)[source]¶
Bases:
object
Constrained zonotope class
Constrained zonotope defines a polytope in the working dimension \(\mathbb{R}^n\) as an affine transformation of a polytope defined in latent space \(B_\infty(A_e, b_e)\subset \mathbb{R}^{N_C}\). Here, \(B_\infty(A_e, b_e)\) is defined as the intersection of a unit \(\ell_\infty\)-norm ball and a collection of \(M_C\) linear constraints \(\{\xi\in\mathbb{R}^{N_C}|A_e \xi = b_e\}.\)
Formally, a constrained zonotope is defined as follows,
\[\mathcal{C} = \{G \xi + c\ |\ \xi \in B_\infty(A_e, b_e)\} \subset \mathbb{R}^n,\]where
\[B_\infty(A_e, b_e)= \{\xi\ |\ \| \xi \|_\infty \leq 1, A_e \xi = b_e\} \subset \mathbb{R}^{N_C},\]with \(G\in\mathbb{R}^{n\times N_C}\), \(c\in\mathbb{R}^{n}\), \(A_e\in\mathbb{R}^{M_C\times N_C}\), and \(b\in\mathbb{R}^{M_C}\).
A constrained zonotope provide an alternative and equivalent representation of any convex and compact polytope. Furthermore, a constrained zonotope admits closed-form expressions for several set manipulations that can often be accomplished without invoking any optimization solvers. See [SDGR16] [RK22] [VWD24] for more details.
A zonotope is a special class of constrained zonotopes, and are defined as
\[\mathcal{Z} = \{G \xi + c\ |\ \|\xi\|_\infty \leq 1\} \subset \mathbb{R}^n.\]In other words, a zonotope is a constrained zonotope with no equality constraints in the latent dimension space. In
ConstrainedZonotope
, we model zonotopes by having (Ae,be) be empty (n_equalities is zero).Constrained zonotope object construction admits one of the following combinations (as keyword arguments):
dim for an empty constrained zonotope of dimension dim,
(G, c, Ae, be) for a constrained zonotope,
(G, c) for a zonotope,
(lb, ub) for a zonotope equivalent to an axis-aligned cuboid with appropriate bounds \(\{x\ |\ lb\leq x \leq ub\}\), and
(c, h) for a zonotope equivalent to an axis-aligned cuboid centered at c with specified scalar/vector half-sides \(h\), \(\{x\ |\ \forall i\in\{1,2,...,n\}, |x_i - c_i| \leq h_i\}\).
(c=p, G=None) for a zonotope equivalent to a single point p,
P for a constrained zonotope equivalent to the
pycvxset.Polytope.Polytope
object P,
- Parameters:
dim (int, optional) – Dimension of the empty constrained zonotope. If NOTHING is provided, dim=0 is assumed.
c (array_like, optional) – Affine transformation translation vector. Must be 1D array, and the constrained zonotope dimension is determined by number of elements in c. When c is provided, either (G) or (G, Ae, be) or (h) must be provided additionally. When h is provided, c is the centroid of the resulting zonotope.
G (array_like) – Affine transformation matrix. The vectors are stacked vertically with matching number of rows as c. When G is provided, (c, Ae, be) OR (c) must also be provided. To define a constrained zonotope with a single point, set c to the point AND G to None (do not set (Ae, be) or set them to (None, None)).
Ae (array_like) – Equality coefficient vectors. The vectors are stacked vertically with matching number of columns as G. When Ae is provided, (G, c, be) must also be provided.
be (array_like) – Equality coefficient constants. The constants are expected to be in a 1D numpy array. When be is provided, (G, c, Ae) must also be provided.
lb (array_like, optional) – Lower bounds of the axis-aligned cuboid. Must be 1D array, and the constrained zonotope dimension is determined by number of elements in lb. When lb is provided, ub must also be provided.
ub (array_like, optional) – Upper bounds of the axis-aligned cuboid. Must be 1D array of length as same as lb. When ub is provided, lb must also be provided.
h (array_like, optional) – Half-side length of the axis-aligned cuboid. Can be a scalar or a vector of length as same as c. When h is provided, c must also be provided.
polytope (Polytope, optional) – Polytope to use to construct constrained zonotope.
- Raises:
ValueError – (G, c) is not compatible.
ValueError – (G, c, Ae, be) is not compatible.
ValueError – (lb, ub) is not valid
ValueError – (c, h) is not valid
ValueError – Provided polytope is not bounded.
UserWarning – When a row with all zeros in Ae and be.
Methods
__init__
(**kwargs)Constructor for ConstrainedZonotope class
affine_map
(M)Multiply a matrix or a scalar with a constrained zonotope
approximate_pontryagin_difference
(norm_type, ...)Approximate Pontryagin difference between a constrained zonotope and an affine transformation of a unit-norm ball.
cartesian_product
(sequence_Q)Generate the Cartesian product of a set \(\mathcal{Q}\) (or a list of mathcal{Q}) with \(\mathcal{P}\).
Computes a ball with the largest radius that fits within the constrained zonotope.
closest_point
(points[, p])Wrapper for
project()
to compute the point in the convex set closest to the given point.containment_constraints
(x[, flatten_order])Get CVXPY constraints for containment of x (a cvxpy.Variable) in a constrained zonotope.
contains
(Q[, verbose, time_limit])Check containment of a set \(\mathcal{Q}\) (could be a polytope or a constrained zonotope), or a collection of points \(Q \in \mathbb{R}^{n_Q \times \mathcal{P}.\text{dim}}\) in the given constrained zonotope.
copy
()Get a copy of the constrained zonotope
distance
(points[, p])Wrapper for
project()
to compute distance of a point to a convex set.extreme
(eta)Wrapper for
support()
to compute the extreme point.Compute an interior point of the constrained zonotope.
intersection
(Q)Compute the intersection of constrained zonotope with another constrained zonotope or polytope.
Compute the intersection of constrained zonotope with another constrained zonotope under an inverse affine map
intersection_with_affine_set
(Ae, be)Compute the intersection of a constrained zonotope with an affine set.
Compute the intersection of a constrained zonotope with a collection of halfspaces (polyhedron).
Compute the inverse affine map of a constrained zonotope for a given matrix M.
Compute the maximum volume ellipsoid that fits within the given constrained zonotope.
minimize
(x, objective_to_minimize, cvxpy_args)Solve a convex program with CVXPY objective subject to containment constraints.
Compute the minimum volume circumscribing rectangle for a set.
minus
(Q)Implement - operation: Pontryagin difference with a constrained zonotope minuend
plot
([method, ax, direction_vectors, ...])Plot a polytopic approximation of the set.
plus
(Q)Add a point or a set Q to a constrained zonotope (Minkowski sum).
Compute a polytopic inner-approximation of a given set via ray shooting.
Compute a polytopic outer-approximation of a given set via ray shooting.
project
(x[, p])Project a point or a collection of points on to a set.
projection
(project_away_dims)Orthogonal projection of a set \(\mathcal{P}\) after removing some user-specified dimensions.
Remove any redundancies in the equality system using pycddlib and other geometric properties
slice
(dims, constants)Slice a set restricting certain dimensions to constants.
slice_then_projection
(dims, constants)Wrapper for
slice()
andprojection()
.support
(eta)Evaluates the support function and support vector of a set.
Attributes
Equality coefficient vectors Ae for the constrained zonotope.
Affine transformation matrix G for the constrained zonotope.
Equality constraints He=[Ae, be] for the constrained zonotope.
Equality constants be for the constrained zonotope.
Affine transformation vector c for the constrained zonotope.
CVXPY arguments in use when solving a linear program
CVXPY arguments in use when solving a second-order cone program
Dimension of the constrained zonotope.
Check if the constrained zonotope is bounded (which is always True)
Check if the constrained zonotope is empty
Check if the affine dimension of the constrained zonotope is the same as the constrained zonotope dimension
Check if the constrained zonotope is a singleton
Check if the constrained zonotope is a zonotope
Latent dimension of the constrained zonotope.
Number of equality constraints used when defining the constrained zonotope.