Operations¶
-
pypolycontain.operations.
AH_polytope_vertices
(P, N=200, epsilon=0.001, solver='Gurobi')¶ Returns N*2 matrix of vertices
-
pypolycontain.operations.
AddMatrixInequalityConstraint_classical
(mathematical_program, A, X, B)¶
-
pypolycontain.operations.
Hausdorff_distance
(Q1, Q2, ball='infinty_norm', solver='gurobi')¶
-
pypolycontain.operations.
Lambda_H_Gamma
(mathematical_program, Lambda, H_1, H_2, Gamma)¶ Lambda H_1 = H_2 Gamma
-
pypolycontain.operations.
Lambda_h_Inequality
(mathematical_program, Lambda, beta, H, h_1, h_2)¶ Adds Lambda H-1 le h_2 + H beta to the Mathematical Program
-
pypolycontain.operations.
Lambda_h_Inequality_D
(mathematical_program, Lambda, beta, H, h_1, h_2, D)¶ Adds Lambda H-1 le h_2 D + H beta to the Mathematical Program
-
pypolycontain.operations.
affine_map
(T, P, t=None)¶ Returns the affine map of a polytope.
-
pypolycontain.operations.
bounding_box
(Q, solver='Gurobi')¶ Computes the bounding box of a polytope by solving \(2n\) linear programs. Each linear program is in the form:
\[\begin{split}\begin{array}{lll} l_i= & \min & e_i^T x \\ & \text{subject to} & x \in \mathbb{P} \end{array}\end{split}\]and
\[\begin{split}\begin{array}{lll} u_i= & \max & e_i^T x \\ & \text{subject to} & x \in \mathbb{P} \end{array} \end{split}\]where \(l,u\) define the lower and upper corners of the bounding box.
-
pypolycontain.operations.
boxing_order_reduction
(zonotope, desired_order=1)¶ boxing method for zonotope order reduction inputs: input zonotope , order of the output zonotope output: zonotope
Based on Kopetzki, Anna-Kathrin, Bastian Schürmann, and Matthias Althoff. “Methods for order reduction of zonotopes.” 2017 IEEE 56th Annual Conference on Decision and Control (CDC). IEEE, 2017.
-
pypolycontain.operations.
check_non_empty
(Q, tol=1e-05, solver='gurobi')¶
-
pypolycontain.operations.
check_subset
(P1, P2, k=-1)¶ Checks if .math..`P1 subseteq P2` Inputs:
-
pypolycontain.operations.
convex_hull
(P1, P2)¶ - Inputs:
- P1, P2: AH_polytopes
- Output:
- returns :math:` ext{ConvexHull}(mathbb{P}_1,mathbb{P}_2)` as an AH-polytope
-
pypolycontain.operations.
convex_hull_of_point_and_polytope
(x, Q)¶ - Inputs:
- x: numpy n*1 array Q: AH-polytope in R^n
- Returns:
- AH-polytope representing convexhull(x,Q)
\[\text{conv}(x,Q):=\{y | y= \lambda q + (1-\lambda) x, q \in Q\}.\]
-
pypolycontain.operations.
decompose
(zonotope, dimensions)¶ @author: kasra Decompising a given set into bunch of fewer dimensional sets such that the Cartesian product of those sets is a subset of the given set.
-
pypolycontain.operations.
directed_Hausdorff_distance
(Q1, Q2, ball='infinty_norm', solver='gurobi')¶ - The optimization problem is:
- Minimize epsilon such that Q1 subset Q2+epsilon(Ball)
It is zero if and only if Q1 subset Q2. The method is based on
Sadraddini&Tedrake, 2019, CDC (available on ArXiv)- We solve the following problem:
- D*ball+Q1 subset Q2
We solve the following linear program: ..math:
\min D s.t. Lambda_1 H_1=H_2 Gamma_1 Lambda_2 H_1=H_ball Gamma_2 Lambda_1 h_1<=h_2 + H_2 beta_1 Lambda_2 h_2<=D h_ball + H_ball beta_2 x_2 - X_2 beta_1 - beta_2 = x_1 X_2 Gamma_1 + Gamma_2 = X_1
-
pypolycontain.operations.
directed_Hausdorff_hyperbox
(b1, b2)¶ The directed Hausdorff hyperbox min epsilon such that b1 in b2+epsilon
-
pypolycontain.operations.
distance_hyperbox
(b1, b2)¶ The distance between boxes
-
pypolycontain.operations.
distance_point_polytope
(P, x, ball='infinity', solver='Gurobi')¶ Computes the distance of point x from AH-polytope Q
-
pypolycontain.operations.
distance_polytopes
(Q1, Q2, ball='infinity', solver='gurobi')¶
-
pypolycontain.operations.
get_nonzero_cost_vectors
(cost)¶
-
pypolycontain.operations.
intersection
(P1, P2)¶ - Inputs:
- P1, P2: polytopic objects
- Output:
returns \(\mathbb{P}_1 \cap \mathbb{P}_2\) as an AH-polytope
If both objects are H-polytopes, return H-polytope
-
pypolycontain.operations.
intersection_old
(P1, P2)¶ - Inputs:
- P1, P2: AH_polytopes \(\mathbb{P}_1,\mathbb{P}_2\). Converted to AH-polytopes
- Output:
- returns \(\mathbb{P}_1 \cap \mathbb{P}_2\) as an AH-polytope
-
pypolycontain.operations.
make_ball
(n, norm)¶
-
pypolycontain.operations.
minkowski_sum
(P1, P2)¶ - Inputs:
- P1, P2: AH_polytopes
- Returns:
- returns the Mkinkowski sum \(P_1 \oplus P_2\) as an AH-polytope.
Background: The Minkowski sum of two sets is defined as:
\[A \oplus B = \{ a + b \big | a \in A, b \in B\}.\]
-
pypolycontain.operations.
pca_order_reduction
(zonotope, desired_order=1)¶ PCA method for zonotope order reduction inputs: input zonotope , order of the output zonotope output: zonotope
Based on Kopetzki, Anna-Kathrin, Bastian Schürmann, and Matthias Althoff. “Methods for order reduction of zonotopes.” 2017 IEEE 56th Annual Conference on Decision and Control (CDC). IEEE, 2017.
-
pypolycontain.operations.
point_membership
(Q, x, tol=1e-05, solver='gurobi')¶
-
pypolycontain.operations.
point_membership_fuzzy
(Q, x, tol=1e-05, solver='gurobi')¶ Fuzzy membership check. If x contains NaN, the entry is unconstrained @param Q: Polytope in R^n @param x: n*1 numpy array, may contain NaNs @param tol: @param solver: solver to use @return: boolean of whether x is in Q
-
pypolycontain.operations.
positive_matrix
(mathematical_program, Lambda)¶ All elements are non-negative
-
pypolycontain.operations.
sorting_generator
(G, desired_numberofcolumns)¶ The goal is deviding the generator into to parts. One part that is used for zonotope order reduction methods. And the other part which is used to enforce the reduced zonotope to have the desire order.
-
pypolycontain.operations.
translate
(t, P)¶ Shifts the polytope by t vector
Conversions¶
-
pypolycontain.conversions.
AH_to_H_old
(Q, P0, solver='Gurobi')¶ Converting Q to an H-polytope using an optimization-based method
WARNING: To be deprecated
-
pypolycontain.conversions.
AH_to_V
(P, N=360, epsilon=0.001, solver='Gurobi')¶ Returns the V-polytope form of a 2D pp.AH_polytope. The method is based on ray shooting.
- Inputs:
- P: AH-polytope
- N
defualt=360
: number of rays - solver:
default=Gurobi
. The linear-programming optimization solver.
- Returns:
- V: matrix
Note
This method only works for 2D AH-polytopes and its for visualization. For generic use, first use H-V on \(\mathbb{P}\) and then apply affine transformation. Note that H-V uses elimination-based vertex enumeration method that is not scalable.
-
pypolycontain.conversions.
H_to_V
(P)¶ Returns the vertices of an H_polytope.
- Inputs:
- P: H_polytope in \(\mathbb{R}^n\)
- Output:
- V: list of vertices. Each vertex is numpy.ndarray[float[n,1]]
- Method:
- The method is based on double description method, and is using pycddlib.
Warning
This method can be very slow or numerically unstable for polytopes in high dimensions and/or large number of hyperplanes
-
pypolycontain.conversions.
to_AH_polytope
(P)¶ Converts the polytopic object P into an AH-polytope. If applied on a AH-polytope, a deepcopy is returned
-
pypolycontain.conversions.
to_V
(P, N=500)¶ returns the vertices of the polytopic object $P$ in a vertical stack form.
-
pypolycontain.conversions.
vcube
(n)¶ \(2^n \times n\) array of vectors of vertices in unit cube in \(\mathbb{R^n}\)
-
pypolycontain.conversions.
zonotope_to_V
(Z)¶ Finds the vertices of a zonotope