ZonoOpt v2.0.1
Loading...
Searching...
No Matches
Functions
Set Operations

Set operations for ZonoOpt library. More...

Functions

std::unique_ptr< HybZonoZonoOpt::affine_map (const HybZono &Z, const Eigen::SparseMatrix< zono_float > &R, const Eigen::Vector< zono_float, -1 > &s=Eigen::Vector< zono_float, -1 >())
 Returns affine map R*Z + s of set Z.
 
std::unique_ptr< HybZonoZonoOpt::project_onto_dims (const HybZono &Z, const std::vector< int > &dims)
 Projects set Z onto the dimensions specified in dims.
 
std::unique_ptr< HybZonoZonoOpt::minkowski_sum (const HybZono &Z1, HybZono &Z2)
 Computes Minkowski sum of two sets Z1 and Z2.
 
std::unique_ptr< HybZonoZonoOpt::pontry_diff (HybZono &Z1, HybZono &Z2, bool exact=false)
 Computes the Pontryagin difference Z1 - Z2.
 
std::unique_ptr< HybZonoZonoOpt::intersection (const HybZono &Z1, HybZono &Z2, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >())
 Computes the generalized intersection of sets Z1 and Z2 over the matrix R.
 
std::unique_ptr< HybZonoZonoOpt::intersection_over_dims (const HybZono &Z1, HybZono &Z2, const std::vector< int > &dims)
 Computes the generalized intersection of sets Z1 and Z2 over the specified dimensions.
 
std::unique_ptr< HybZonoZonoOpt::halfspace_intersection (HybZono &Z, const Eigen::SparseMatrix< zono_float > &H, const Eigen::Vector< zono_float, -1 > &f, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >())
 Computes the intersection generalized intersection of set Z with halfspace H*x <= f over matrix R.
 
std::unique_ptr< HybZonoZonoOpt::union_of_many (const std::vector< std::shared_ptr< HybZono > > &Zs, bool preserve_sharpness=false, bool expose_indicators=false)
 Computes union of several sets.
 
std::unique_ptr< HybZonoZonoOpt::cartesian_product (const HybZono &Z1, HybZono &Z2)
 Computes the Cartesian product of two sets Z1 and Z2.
 
std::unique_ptr< HybZonoZonoOpt::constrain (HybZono &Z, const std::vector< Inequality > &ineqs, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >())
 Applies inequalities to set.
 
std::unique_ptr< HybZonoZonoOpt::set_diff (const HybZono &Z1, HybZono &Z2, zono_float delta_m=100, bool remove_redundancy=true, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr, int n_leaves=std::numeric_limits< int >::max(), int contractor_iter=100)
 Set difference Z1 \ Z2.
 

Detailed Description

Set operations for ZonoOpt library.

Function Documentation

◆ affine_map()

std::unique_ptr< HybZono > ZonoOpt::affine_map ( const HybZono Z,
const Eigen::SparseMatrix< zono_float > &  R,
const Eigen::Vector< zono_float, -1 > &  s = Eigen::Vector<zono_float, -1>() 
)

Returns affine map R*Z + s of set Z.

Parameters
Zzonotopic set
Raffine map matrix
svector offset
Returns
zonotopic set

◆ cartesian_product()

std::unique_ptr< HybZono > ZonoOpt::cartesian_product ( const HybZono Z1,
HybZono Z2 
)

Computes the Cartesian product of two sets Z1 and Z2.

Parameters
Z1zonotopic set
Z2zonotopic set
Returns
zonotopic set

◆ constrain()

std::unique_ptr< HybZono > ZonoOpt::constrain ( HybZono Z,
const std::vector< Inequality > &  ineqs,
const Eigen::SparseMatrix< zono_float > &  R = Eigen::SparseMatrix<zono_float>() 
)

Applies inequalities to set.

Parameters
ZSet for inequalities to be applied to.
ineqsVector of inequalities.
RFor generalized intersection with the inequalities. Defaults to identity.
Returns
zonotopic set

Constrains set Z by applying the given inequalities to the set. For example, given a set Z with states z0, z1, z2, the constraint z0 + z1 - z2 <= 2 could be added via an inequality object. R is used for generalized intersection-like operations. For instance, when all the inequalities are <= inequalities, this function returns Z int_R (Hx<=f) where H is the halfspace represented by the inequalities.

◆ halfspace_intersection()

std::unique_ptr< HybZono > ZonoOpt::halfspace_intersection ( HybZono Z,
const Eigen::SparseMatrix< zono_float > &  H,
const Eigen::Vector< zono_float, -1 > &  f,
const Eigen::SparseMatrix< zono_float > &  R = Eigen::SparseMatrix<zono_float>() 
)

Computes the intersection generalized intersection of set Z with halfspace H*x <= f over matrix R.

Parameters
Zzonotopic set
Hhalfspace matrix
fhalfspace vector
Raffine map matrix
Returns
zonotopic set

◆ intersection()

std::unique_ptr< HybZono > ZonoOpt::intersection ( const HybZono Z1,
HybZono Z2,
const Eigen::SparseMatrix< zono_float > &  R = Eigen::SparseMatrix<zono_float>() 
)

Computes the generalized intersection of sets Z1 and Z2 over the matrix R.

Parameters
Z1zonotopic set
Z2zonotopic set
Raffine map matrix
Returns
zonotopic set

◆ intersection_over_dims()

std::unique_ptr< HybZono > ZonoOpt::intersection_over_dims ( const HybZono Z1,
HybZono Z2,
const std::vector< int > &  dims 
)

Computes the generalized intersection of sets Z1 and Z2 over the specified dimensions.

Parameters
Z1zonotopic set
Z2zonotopic set
dimsvector of dimensions
Returns
zonotopic set

◆ minkowski_sum()

std::unique_ptr< HybZono > ZonoOpt::minkowski_sum ( const HybZono Z1,
HybZono Z2 
)

Computes Minkowski sum of two sets Z1 and Z2.

Parameters
Z1zonotopic set
Z2zonotopic set
Returns
zonotopic set

◆ pontry_diff()

std::unique_ptr< HybZono > ZonoOpt::pontry_diff ( HybZono Z1,
HybZono Z2,
bool  exact = false 
)

Computes the Pontryagin difference Z1 - Z2.

Parameters
Z1minuend
Z2subtrahend
exactrequire output to be exact, otherwise inner approximation will be returned
Returns
zonotopic set

For inner approximations (exact = false), the algorithm from Vinod et. al. 2025 is used. Note that this algorithm is exact when the minuend is a constrained zonotope and the matrix [G;A] is invertible. Exact Pontryagin difference can only be computed when the subtrahend is a zonotope. If subtrahend is a constrained zonotope, it will first be over-approximated as a zonotope. If subtrahend is a hybrid zonotope, a get_leaves operation will first be performed to produce a union of constrained zonotopes. If the minuend is a hybrid zonotope and exact is false, a get_leaves operation will be performed for Z1 to reduce the number of leaves in the resulting set.

◆ project_onto_dims()

std::unique_ptr< HybZono > ZonoOpt::project_onto_dims ( const HybZono Z,
const std::vector< int > &  dims 
)

Projects set Z onto the dimensions specified in dims.

Parameters
Zzonotopic set
dimsvector of dimensions
Returns
zonotopic set

◆ set_diff()

std::unique_ptr< HybZono > ZonoOpt::set_diff ( const HybZono Z1,
HybZono Z2,
zono_float  delta_m = 100,
bool  remove_redundancy = true,
const OptSettings settings = OptSettings(),
OptSolution solution = nullptr,
int  n_leaves = std::numeric_limits<int>::max(),
int  contractor_iter = 100 
)

Set difference Z1 \ Z2.

Parameters
Z1zonotopic set
Z2zonotopic set
delta_mparameter defining range of complement
remove_redundancyremove redundant constraints and unused generators in get_leaves function call
settingsoptimization settings for get_leaves function call
solutionoptimization solution for get_leaves function call
n_leavesmaximum number of leaves to return in get_leaves function call
contractor_iternumber of interval contractor iterations to run if using remove_redundancy
Returns
zonotopic set

◆ union_of_many()

std::unique_ptr< HybZono > ZonoOpt::union_of_many ( const std::vector< std::shared_ptr< HybZono > > &  Zs,
bool  preserve_sharpness = false,
bool  expose_indicators = false 
)

Computes union of several sets.

Parameters
ZsSets to be unioned.
preserve_sharpnessFlag to preserve sharpness of the union at expense of complexity.
expose_indicatorsFlag to append indicator set to the union.
Returns
zonotopic set

Computes union of sets {Z0, Z1, ..., Zn}. If expose_indicators is true, returns union({Z0, ..., Zn}) x I where I is the indicator set for the union. Specifically, each dimension of I corresponds to one of the Zi in the union. So for union_of_many({Z0, Z1, Z2}, true) with Z0, Z1, Z2 not intersecting, if a vector [z, i] is in union({Z0, Z1, Z2}) x I, then i = [1, 0, 0] if z is in Z0, etc.