ZonoOpt 2.5.0
Loading...
Searching...
No Matches
Functions
Set Operations

Set operations for ZonoOpt library. More...

Functions

std::unique_ptr< HybZono > ZonoOpt::affine_inclusion (const HybZono &Z, const IntervalMatrix &R, const Eigen::Vector< zono_float, -1 > &s=Eigen::Vector< zono_float, -1 >())
 Returns inclusion of zonotopic set for uncertain affine map R*Z + s.
 
Box ZonoOpt::affine_map (const Box &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 box Z.
 
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.
 
Box ZonoOpt::cartesian_product (const Box &Z1, const Box &Z2)
 Computes the Cartesian product of two boxes Z1 and Z2.
 
std::unique_ptr< HybZono > ZonoOpt::cartesian_product (const HybZono &Z1, HybZono &Z2)
 Computes the Cartesian product of two sets Z1 and Z2.
 
std::unique_ptr< HybZono > ZonoOpt::constrain (HybZono &Z, const Eigen::SparseMatrix< zono_float > &H, const Eigen::Vector< zono_float, -1 > &f, char direction, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >())
 Computes the generalized intersection of set Z with H*x <= f, H*x >= f, or H*x = f over matrix R.
 
std::unique_ptr< ConZono > ZonoOpt::convex_hull (const std::vector< std::shared_ptr< HybZono > > &Zs, bool exact=true)
 Computes convex hull of several sets.
 
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.
 
Box ZonoOpt::intersection (const Box &Z1, const Box &Z2, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >(), int contractor_iter=10)
 Computes the generalized intersection of boxes Z1 and Z2 over the matrix R.
 
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.
 
Box ZonoOpt::intersection_over_dims (const Box &Z1, const Box &Z2, const std::vector< int > &dims)
 Computes the intersection of boxes Z1 and Z2 over the specified dimensions.
 
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.
 
Box ZonoOpt::interval_hull (const Box &Z1, const Box &Z2)
 Computes the interval hull of two boxes.
 
Box ZonoOpt::interval_hull (const std::vector< Box > &boxes)
 Computes the interval hull of several boxes.
 
Box ZonoOpt::minkowski_sum (const Box &Z1, const Box &Z2)
 Computes the Minkowski sum of two boxes Z1 and Z2.
 
std::unique_ptr< HybZono > ZonoOpt::minkowski_sum (const HybZono &Z1, HybZono &Z2)
 Computes Minkowski sum of two sets Z1 and Z2.
 
Box ZonoOpt::pontry_diff (const Box &Z1, const Box &Z2)
 Computes the Pontryagin difference Z1 - Z2 of two boxes.
 
std::unique_ptr< HybZono > ZonoOpt::pontry_diff (HybZono &Z1, Zono &Z2, bool exact=true)
 Computes the Pontryagin difference Z1 - Z2.
 
Box ZonoOpt::project_onto_dims (const Box &Z, const std::vector< int > &dims)
 Projects box Z onto the dimensions specified in 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.
 
std::unique_ptr< HybZono > ZonoOpt::set_diff (const HybZono &Z1, HybZono &Z2, zono_float delta_m, bool remove_redundancy, const SolverSettings &settings=get_default_solver_settings(), std::shared_ptr< OptSolution > *solution=nullptr, int n_leaves=std::numeric_limits< int >::max(), int contractor_iter=10)
 
std::unique_ptr< HybZono > ZonoOpt::set_diff (const HybZono &Z1, HybZono &Z2, zono_float delta_m=100, const GetLeavesParams &get_leaves_params=GetLeavesParams{true}, const SolverSettings &settings=get_default_solver_settings(), std::shared_ptr< OptSolution > *solution=nullptr)
 Set difference Z1 \ Z2.
 
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.
 

Detailed Description

Set operations for ZonoOpt library.

Function Documentation

◆ affine_inclusion()

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

Returns inclusion of zonotopic set for uncertain affine map R*Z + s.

Parameters
Zzonotopic set
Rinterval matrix
svector offset
Returns
zonotopic set

This computes an over-approximation of the affine map using the method of Rego et. al. (2020) "Guaranteed methods based on constrained zonotopes for set-valued state estimation of nonlinear discrete-time systems" The SVD-based zonotope over-approximation method is used in this function when Z is a constrained zonotope. When Z is a hybrid zonotope, the convex relaxation is used to produce a constrained zonotope, and then the SVD-based method is applied.

Exceptions
std::invalid_argumentif R, s, and Z have inconsistent dimensions.

◆ affine_map() [1/2]

Box ZonoOpt::affine_map ( const Box &  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 box Z.

Parameters
Zbox
Raffine map matrix
svector offset
Returns
box
See also
Box::affine_map
Exceptions
std::invalid_argumentif R, s, and Z have inconsistent dimensions.

◆ affine_map() [2/2]

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
Exceptions
std::invalid_argumentif R, s, and Z have inconsistent dimensions.

◆ cartesian_product() [1/2]

Box ZonoOpt::cartesian_product ( const Box &  Z1,
const Box &  Z2 
)

Computes the Cartesian product of two boxes Z1 and Z2.

Parameters
Z1box
Z2box
Returns
box
See also
Box::cartesian_product
Note
Unlike the HybZono overload, Box::operator* does NOT compute the Cartesian product.

◆ cartesian_product() [2/2]

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 Eigen::SparseMatrix< zono_float > &  H,
const Eigen::Vector< zono_float, -1 > &  f,
char  direction,
const Eigen::SparseMatrix< zono_float > &  R = Eigen::SparseMatrix<zono_float>() 
)

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

Parameters
Zzonotopic set
Hconstraint matrix
fconstraint vector
direction'<' for <=, '>' for >=, '=' for =
Raffine map matrix, defaults to identity
Returns
zonotopic set
Exceptions
std::invalid_argumentif direction is not one of '<', '>', '=', or if Z, H, f, and R have inconsistent dimensions.

◆ convex_hull()

std::unique_ptr< ConZono > ZonoOpt::convex_hull ( const std::vector< std::shared_ptr< HybZono > > &  Zs,
bool  exact = true 
)

Computes convex hull of several sets.

Parameters
ZsSets for which convex hull is to be computed.
exactIf false and all sets are zonotopes, a zonotope outer approximation is returned.
Returns
constrained zonotope convex hull

Computes convex hull of sets {Z0, Z1, ..., Zn}. If Zi is a hybrid zonotope, it must be sharp or this function will throw an error. Zonotope outer approximations are computed using the method of Girard 2005, "Reachability of Uncertain Linear Systems Using Zonotopes".

Exceptions
std::invalid_argumentif Zs is empty, if any member is a non-sharp hybrid zonotope, or if the outer-approximation path encounters a non-zonotope input.

◆ 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

Calls constrain with '<'

Exceptions
std::invalid_argumentif Z, H, f, and R have inconsistent dimensions.

◆ intersection() [1/2]

Box ZonoOpt::intersection ( const Box &  Z1,
const Box &  Z2,
const Eigen::SparseMatrix< zono_float > &  R = Eigen::SparseMatrix<zono_float>(),
int  contractor_iter = 10 
)

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

Parameters
Z1box
Z2box
Raffine map matrix; if not provided, the identity map is used (R must then be square)
contractor_iternumber of interval contractor iterations to run when R is not the identity; ignored when R is left at its default value
Returns
box
See also
Box::intersect
Box::intersection_over_dims
Exceptions
std::invalid_argumentif R is provided and its dimensions are inconsistent with Z1 and Z2, or if R is omitted and Z1, Z2 have different dimensions.
Note
An interval contractor is used to compute the over-approximation of the generalized intersection when an exact intersection is not available.

◆ intersection() [2/2]

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
Exceptions
std::invalid_argumentif Z1, Z2, and R have inconsistent dimensions.

◆ intersection_over_dims() [1/2]

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

Computes the intersection of boxes Z1 and Z2 over the specified dimensions.

Parameters
Z1box
Z2box, must have size equal to dims.size()
dimsdimensions of Z1 over which the intersection is computed
Returns
box
See also
Box::intersection_over_dims
Exceptions
std::invalid_argumentif dims.size() does not equal Z2.size(), or if any entry in dims is not a valid dimension of Z1.

◆ intersection_over_dims() [2/2]

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
Exceptions
std::invalid_argumentif Z2.n does not match the number of dimensions, or if any entry in dims is not a valid dimension of Z1.

◆ interval_hull() [1/2]

Box ZonoOpt::interval_hull ( const Box &  Z1,
const Box &  Z2 
)

Computes the interval hull of two boxes.

Parameters
Z1box
Z2box
Returns
smallest box containing both Z1 and Z2
See also
Box::interval_hull
Exceptions
std::invalid_argumentif Z1 and Z2 have different dimensions.

◆ interval_hull() [2/2]

Box ZonoOpt::interval_hull ( const std::vector< Box > &  boxes)

Computes the interval hull of several boxes.

Parameters
boxesboxes for which the interval hull is to be computed
Returns
smallest box containing all boxes
Exceptions
std::invalid_argumentif boxes is empty or if its members have inconsistent dimensions.

◆ minkowski_sum() [1/2]

Box ZonoOpt::minkowski_sum ( const Box &  Z1,
const Box &  Z2 
)

Computes the Minkowski sum of two boxes Z1 and Z2.

Parameters
Z1box
Z2box
Returns
box
See also
Box::minkowski_sum
Exceptions
std::invalid_argumentif Z1 and Z2 have different dimensions.

◆ minkowski_sum() [2/2]

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
Exceptions
std::invalid_argumentif Z1 and Z2 have different dimensions.

◆ pontry_diff() [1/2]

Box ZonoOpt::pontry_diff ( const Box &  Z1,
const Box &  Z2 
)

Computes the Pontryagin difference Z1 - Z2 of two boxes.

Parameters
Z1minuend
Z2subtrahend
Returns
box
See also
Box::pontry_diff
Exceptions
std::invalid_argumentif Z1 and Z2 have different dimensions.

◆ pontry_diff() [2/2]

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

Computes the Pontryagin difference Z1 - Z2.

Parameters
Z1minuend
Z2subtrahend
exactrequire output to be exact, otherwise inner approximation will be returned (default true)
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.

Exceptions
std::invalid_argumentif Z1 and Z2 have different dimensions, or if the inexact difference is requested when the minuend is a hybrid zonotope.
std::runtime_errorif internal preconditions fail (e.g., redundancy-removal failure during the computation).

◆ project_onto_dims() [1/2]

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

Projects box Z onto the dimensions specified in dims.

Parameters
Zbox
dimsvector of dimensions
Returns
box
See also
Box::project_onto_dims
Exceptions
std::invalid_argumentif any entry in dims is not a valid dimension of Z.

◆ project_onto_dims() [2/2]

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
Exceptions
std::invalid_argumentif any entry in dims is not a valid dimension of Z.

◆ set_diff() [1/2]

std::unique_ptr< HybZono > ZonoOpt::set_diff ( const HybZono &  Z1,
HybZono &  Z2,
zono_float  delta_m,
bool  remove_redundancy,
const SolverSettings &  settings = get_default_solver_settings(),
std::shared_ptr< OptSolution > *  solution = nullptr,
int  n_leaves = std::numeric_limits<int>::max(),
int  contractor_iter = 10 
)
Deprecated:
use the overload taking GetLeavesParams instead

◆ set_diff() [2/2]

std::unique_ptr< HybZono > ZonoOpt::set_diff ( const HybZono &  Z1,
HybZono &  Z2,
zono_float  delta_m = 100,
const GetLeavesParams &  get_leaves_params = GetLeavesParams{true},
const SolverSettings &  settings = get_default_solver_settings(),
std::shared_ptr< OptSolution > *  solution = nullptr 
)

Set difference Z1 \ Z2.

Parameters
Z1zonotopic set
Z2zonotopic set
delta_mparameter defining range of complement
get_leaves_paramsparameters for get_leaves function call (remove_redundancy, n_leaves, contractor_iter)
settingsoptimization settings for get_leaves function call
solutionoptimization solution for get_leaves function call
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.

Exceptions
std::invalid_argumentif Zs is empty or if its members have inconsistent dimensions.