1#ifndef ZONOOPT_HYBZONO_HPP_
2#define ZONOOPT_HYBZONO_HPP_
28using namespace detail;
67 HybZono(
const Eigen::SparseMatrix<zono_float>&
Gc,
const Eigen::SparseMatrix<zono_float>&
Gb,
const Eigen::Vector<zono_float, -1>&
c,
68 const Eigen::SparseMatrix<zono_float>&
Ac,
const Eigen::SparseMatrix<zono_float>&
Ab,
const Eigen::Vector<zono_float, -1>&
b,
89 void set(
const Eigen::SparseMatrix<zono_float>&
Gc,
const Eigen::SparseMatrix<zono_float>&
Gb,
const Eigen::Vector<zono_float, -1>&
c,
90 const Eigen::SparseMatrix<zono_float>&
Ac,
const Eigen::SparseMatrix<zono_float>&
Ab,
const Eigen::Vector<zono_float, -1>&
b,
108 virtual int get_n()
const {
return this->
n; }
143 virtual Eigen::SparseMatrix<zono_float>
get_Gc()
const {
return this->
Gc; }
150 virtual Eigen::SparseMatrix<zono_float>
get_Gb()
const {
return this->
Gb; }
157 virtual Eigen::SparseMatrix<zono_float>
get_G()
const {
return this->
G; }
164 virtual Eigen::SparseMatrix<zono_float>
get_Ac()
const {
return this->
Ac; }
171 virtual Eigen::SparseMatrix<zono_float>
get_Ab()
const {
return this->
Ab; }
178 virtual Eigen::SparseMatrix<zono_float>
get_A()
const {
return this->
A; }
259 OptSolution* solution=
nullptr,
const int n_leaves = std::numeric_limits<int>::max(),
const int contractor_iter=100)
299 virtual std::string
print()
const;
323 const Eigen::SparseMatrix<zono_float> &P,
const Eigen::Vector<zono_float, -1> &q,
zono_float c=0,
419 OptSolution* solution=
nullptr,
int n_leaves = std::numeric_limits<int>::max(),
int contractor_iter=100)
const;
423 const Eigen::SparseMatrix<zono_float>& R,
const Eigen::Vector<zono_float, -1>&
s);
428 const Eigen::SparseMatrix<zono_float>& R);
430 const std::vector<int>&
dims);
432 const Eigen::Vector<zono_float, -1>&
f,
const Eigen::SparseMatrix<zono_float>& R);
435 friend std::unique_ptr<HybZono>
constrain(
HybZono&
Z,
const std::vector<Inequality> &
ineqs,
const Eigen::SparseMatrix<zono_float>& R);
446 Eigen::SparseMatrix<zono_float>
G = Eigen::SparseMatrix<zono_float>(0, 0);
449 Eigen::SparseMatrix<zono_float>
Gc = Eigen::SparseMatrix<zono_float>(0, 0);
452 Eigen::SparseMatrix<zono_float>
Gb = Eigen::SparseMatrix<zono_float>(0, 0);
455 Eigen::SparseMatrix<zono_float>
A = Eigen::SparseMatrix<zono_float>(0, 0);
458 Eigen::SparseMatrix<zono_float>
Ac = Eigen::SparseMatrix<zono_float>(0, 0);
461 Eigen::SparseMatrix<zono_float>
Ab = Eigen::SparseMatrix<zono_float>(0, 0);
492 const Eigen::SparseMatrix<zono_float> &P,
const Eigen::Vector<zono_float, -1> &q,
zono_float c,
513 static std::set<int>
find_unused_generators(
const Eigen::SparseMatrix<zono_float>&
G,
const Eigen::SparseMatrix<zono_float>&
A);
514 OptSolution mi_opt(
const Eigen::SparseMatrix<zono_float>& P,
const Eigen::Vector<zono_float, -1>& q,
515 zono_float c,
const Eigen::SparseMatrix<zono_float>&
A,
const Eigen::Vector<zono_float, -1>&
b,
517 std::vector<OptSolution>
mi_opt_multisol(
const Eigen::SparseMatrix<zono_float>& P,
const Eigen::Vector<zono_float, -1>& q,
518 zono_float c,
const Eigen::SparseMatrix<zono_float>&
A,
const Eigen::Vector<zono_float, -1>&
b,
int n_sols,
524 void set_Ac_Ab_from_A();
527 int n_leaves = std::numeric_limits<int>::max())
const;
541 const Eigen::SparseMatrix<zono_float>& R,
const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>());
593 const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
605 const std::vector<int>& dims);
618 const Eigen::Vector<zono_float, -1>& f,
const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
633std::unique_ptr<HybZono>
union_of_many(
const std::vector<HybZono*>& Zs,
bool preserve_sharpness=
false,
bool expose_indicators=
false);
659std::unique_ptr<HybZono>
constrain(
HybZono& Z,
const std::vector<Inequality> &ineqs,
const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
694std::unique_ptr<HybZono>
vrep_2_hybzono(
const std::vector<Eigen::Matrix<zono_float, -1, -1>> &Vpolys,
bool expose_indicators=
false);
710std::unique_ptr<HybZono>
zono_union_2_hybzono(std::vector<Zono> &Zs,
bool expose_indicators=
false);
714inline void HybZono::set(
const Eigen::SparseMatrix<zono_float>& Gc,
const Eigen::SparseMatrix<zono_float>& Gb,
const Eigen::Vector<zono_float, -1>& c,
715 const Eigen::SparseMatrix<zono_float>& Ac,
const Eigen::SparseMatrix<zono_float>& Ab,
const Eigen::Vector<zono_float, -1>& b,
716 const bool zero_one_form,
const bool sharp)
719 if (
Gc.rows() !=
c.size() ||
Gb.rows() !=
c.size() ||
Gc.cols() !=
Ac.cols()
720 ||
Gb.cols() !=
Ab.cols() ||
Ac.rows() !=
b.size() ||
Ab.rows() !=
b.size())
722 throw std::invalid_argument(
"HybZono: inconsistent dimensions.");
731 this->nGc =
static_cast<int>(
Gc.cols());
732 this->nGb =
static_cast<int>(
Gb.cols());
733 this->nC =
static_cast<int>(
Ac.rows());
734 this->n =
static_cast<int>(
Gc.rows());
745 Eigen::SparseMatrix<zono_float>
Gb,
Ab,
Ac,
Gc;
747 if (!this->zero_one_form)
749 c = this->c - this->G*Eigen::Vector<zono_float, -1>::Ones(this->nG);
750 b = this->b + this->A*Eigen::Vector<zono_float, -1>::Ones(this->nG);
760 c = this->c + 0.5*this->G*Eigen::Vector<zono_float, -1>::Ones(this->nG);
761 b = this->b - 0.5*this->A*Eigen::Vector<zono_float, -1>::Ones(this->nG);
780 if (!
idx_c.empty()) {
783 if (!idx_b.empty()) {
788 this->nG =
static_cast<int>(this->G.cols());
789 this->nGc =
static_cast<int>(this->Gc.cols());
790 this->nGb =
static_cast<int>(this->Gb.cols());
799 if (this->zero_one_form)
809 box.contract(this->A, this->b, contractor_iter);
812 std::vector<std::pair<int, zono_float>>
fixed_vars;
813 for (
int i=0;
i<this->
nG; ++
i)
815 if (box[
i].is_single_valued())
839 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->G,
k);
it; ++
it)
846 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->A,
k);
it; ++
it)
862 this->nC =
static_cast<int>(this->A.rows());
877 std::stringstream
ss;
878 ss <<
"HybZono: " << std::endl;
879 ss <<
"n: " << this->n << std::endl;
880 ss <<
"nGc: " << this->nGc << std::endl;
881 ss <<
"nGb: " << this->nGb << std::endl;
882 ss <<
"nC: " << this->nC << std::endl;
883 ss <<
"Gc: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Gc) << std::endl;
884 ss <<
"Gb: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Gb) << std::endl;
885 ss <<
"c: " << this->c << std::endl;
886 ss <<
"Ac: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Ac) << std::endl;
887 ss <<
"Ab: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Ab) << std::endl;
888 ss <<
"b: " << this->b << std::endl;
889 ss <<
"zero_one_form: " << this->zero_one_form << std::endl;
890 ss <<
"sharp: " << this->
sharp;
901 const Eigen::SparseMatrix<zono_float> &P,
const Eigen::Vector<zono_float, -1> &q,
const zono_float c,
905 if (P.rows() !=
this->n || P.cols() !=
this->n || q.size() !=
this->n)
907 throw std::invalid_argument(
"Optimize over: inconsistent dimensions.");
911 Eigen::SparseMatrix<zono_float>
P_fact = this->G.transpose()*P*this->
G;
920 return this->G*
sol.z + this->
c;
927 if (this->n != x.size())
929 throw std::invalid_argument(
"Point projection: inconsistent dimensions.");
933 Eigen::SparseMatrix<zono_float> P = this->G.transpose()*this->
G;
934 Eigen::Vector<
zono_float, -1> q = this->G.transpose()*(this->c-x);
939 throw std::runtime_error(
"Point projection: infeasible");
941 return this->G*
sol.z + this->
c;
951 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
953 Eigen::Vector<
zono_float, -1> q = Eigen::Vector<zono_float, -1>::Zero(this->nG);
956 const std::vector<OptSolution>
sol_vec = this->
mi_opt_multisol(P, q, 0, this->A, this->b, 1, settings, solution);
967 if (this->n != x.size())
969 throw std::invalid_argument(
"Contains point: inconsistent dimensions.");
973 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
978 Eigen::Vector<
zono_float, -1>
b (this->nC + this->n);
979 b.segment(0, this->nC) = this->
b;
980 b.segment(this->nC, this->n) = x-this->
c;
984 return !(
sol.infeasible);
989 const zono_float c,
const Eigen::SparseMatrix<zono_float>& A,
const Eigen::Vector<zono_float, -1>& b,
994 if (this->zero_one_form)
997 xi_lb.setConstant(-1);
998 const Eigen::Vector<
zono_float, -1>
xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
1000 const auto admm_data = std::make_shared<ADMM_data>(P, q,
A,
b,
xi_lb,
xi_ub,
c, settings);
1004 mi_data.admm_data = admm_data;
1005 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1014 if (solution !=
nullptr)
1019inline std::vector<OptSolution>
HybZono::mi_opt_multisol(
const Eigen::SparseMatrix<zono_float>& P,
const Eigen::Vector<zono_float, -1>& q,
1020 const zono_float c,
const Eigen::SparseMatrix<zono_float>& A,
const Eigen::Vector<zono_float, -1>& b,
int n_sols,
1025 if (this->zero_one_form)
1028 xi_lb.setConstant(-1);
1029 const Eigen::Vector<
zono_float, -1>
xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
1031 const auto admm_data = std::make_shared<ADMM_data>(P, q,
A,
b,
xi_lb,
xi_ub,
c, settings);
1035 mi_data.admm_data = admm_data;
1036 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1044 if (solution !=
nullptr)
1050inline void HybZono::remove_generators(Eigen::SparseMatrix<zono_float>& G, Eigen::SparseMatrix<zono_float>& A,
const std::set<int>& idx_to_remove)
1053 std::vector<Eigen::Triplet<zono_float>>
triplets;
1057 for (
int k=0;
k<
G.outerSize();
k++)
1065 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
G,
k);
it; ++
it)
1077 for (
int k=0;
k<
A.outerSize();
k++)
1085 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
A,
k);
it; ++
it)
1098 for (
int k=0;
k<
A.outerSize();
k++)
1101 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
A,
k);
it; ++
it)
1103 if (
it.value() != 0)
1121 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
G,
idx_no_con);
it; ++
it)
1123 if (
it.value() != 0)
1139inline void HybZono::make_G_A()
1141 std::vector<Eigen::Triplet<zono_float>>
tripvec;
1144 this->G.resize(this->n, this->nGc + this->nGb);
1150 this->A.resize(this->nC, this->nGc + this->nGb);
1153 this->nG = this->nGc + this->
nGb;
1156inline void HybZono::set_Ac_Ab_from_A()
1161 for (
int k=0;
k<this->A.outerSize(); ++
k)
1163 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->A,
k);
it; ++
it)
1165 if (
it.col() <
this->nGc)
1177 this->Ac.resize(this->nC, this->nGc);
1179 this->Ab.resize(this->nC, this->nGb);
1183inline std::vector<Eigen::Vector<
zono_float, -1>> HybZono::get_bin_leaves(
bool remove_redundancy,
1184 const OptSettings &settings, OptSolution* solution,
const int n_leaves)
const
1187 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
1189 const Eigen::Vector<
zono_float, -1> q = Eigen::Vector<zono_float, -1>::Zero(this->nG);
Class definitions for zero-one inequalities.
Interval and box classes.
Data structures for mixed-integer optimization in ZonoOpt library.
Internal mixed-integer optimization routines for ZonoOpt library.
Utilities for sparse matrix operations in ZonoOpt library.
Box (i.e., interval vector) class.
Definition Intervals.hpp:720
Hybrid zonotope class.
Definition HybZono.hpp:44
friend std::unique_ptr< HybZono > affine_map(const HybZono &Z, const Eigen::SparseMatrix< zono_float > &R, const Eigen::Vector< zono_float, -1 > &s)
Returns affine map R*Z + s of set Z.
Definition PolymorphicFunctions.hpp:61
virtual bool is_0_1_form() const
Returns true if factors are in range [0,1], false if they are in range [-1,1].
Definition HybZono.hpp:199
int nC
number of constraints
Definition HybZono.hpp:482
virtual int get_n() const
Returns dimension of set.
Definition HybZono.hpp:108
bool is_empty(const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Returns true if the set is provably empty, false otherwise.
Definition HybZono.hpp:351
std::vector< OptSolution > mi_opt_multisol(const Eigen::SparseMatrix< zono_float > &P, const Eigen::Vector< zono_float, -1 > &q, zono_float c, const Eigen::SparseMatrix< zono_float > &A, const Eigen::Vector< zono_float, -1 > &b, int n_sols, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Definition HybZono.hpp:1019
bool is_sharp() const
Returns true if set is known to be sharp.
Definition HybZono.hpp:208
friend std::unique_ptr< HybZono > cartesian_product(const HybZono &Z1, HybZono &Z2)
Computes the Cartesian product of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:798
int n
set dimension
Definition HybZono.hpp:470
virtual bool do_is_empty(const OptSettings &settings, OptSolution *solution) const
Definition HybZono.hpp:944
virtual Eigen::SparseMatrix< zono_float > get_Gc() const
Returns continuous generator matrix.
Definition HybZono.hpp:143
friend std::unique_ptr< HybZono > minkowski_sum(const HybZono &Z1, HybZono &Z2)
Computes Minkowski sum of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:133
friend std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:263
OptSolution mi_opt(const Eigen::SparseMatrix< zono_float > &P, const Eigen::Vector< zono_float, -1 > &q, zono_float c, const Eigen::SparseMatrix< zono_float > &A, const Eigen::Vector< zono_float, -1 > &b, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Definition HybZono.hpp:988
Eigen::Vector< zono_float, -1 > project_point(const Eigen::Vector< zono_float, -1 > &x, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Returns the projection of the point x onto the set object.
Definition HybZono.hpp:337
bool is_hybzono() const
Polymorphic type checking: true if set is a hybrid zonotope.
Definition PolymorphicFunctions.hpp:49
virtual int get_nC() const
Returns number of constraints in set definition.
Definition HybZono.hpp:115
friend std::unique_ptr< HybZono > vrep_2_hybzono(const std::vector< Eigen::Matrix< zono_float, -1, -1 > > &Vpolys, bool expose_indicators)
Computes a hybrid zonotope from a union of vertex representation polytopes.
Definition PolymorphicFunctions.hpp:1402
virtual Eigen::Vector< zono_float, -1 > do_project_point(const Eigen::Vector< zono_float, -1 > &x, const OptSettings &settings, OptSolution *solution) const
Definition HybZono.hpp:923
virtual int get_nGb() const
Returns number of binary generators in set definition.
Definition HybZono.hpp:136
virtual Eigen::Vector< zono_float, -1 > do_optimize_over(const Eigen::SparseMatrix< zono_float > &P, const Eigen::Vector< zono_float, -1 > &q, zono_float c, const OptSettings &settings, OptSolution *solution) const
Definition HybZono.hpp:900
bool zero_one_form
flag to indicate whether the set is in 0-1 or -1-1 form
Definition HybZono.hpp:485
Eigen::SparseMatrix< zono_float > Gc
continuous generator matrix
Definition HybZono.hpp:449
zono_float support(const Eigen::Vector< zono_float, -1 > &d, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr)
Computes support function of the set in the direction d.
Definition HybZono.hpp:367
virtual void convert_form()
Converts the set representation between -1-1 and 0-1 forms.
Definition HybZono.hpp:742
bool contains_point(const Eigen::Vector< zono_float, -1 > &x, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Checks whether the point x is contained in the set object.
Definition HybZono.hpp:383
virtual std::string print() const
Returns set information as a string.
Definition HybZono.hpp:875
Eigen::SparseMatrix< zono_float > Gb
binary generator matrix
Definition HybZono.hpp:452
int nG
total number of factors. nG = nGc + nGb
Definition HybZono.hpp:473
bool is_conzono() const
Polymorphic type checking: true if set is a constrained zonotope.
Definition PolymorphicFunctions.hpp:44
virtual Box do_bounding_box(const OptSettings &settings, OptSolution *solution)
Definition PolymorphicFunctions.hpp:1624
virtual zono_float do_support(const Eigen::Vector< zono_float, -1 > &d, const OptSettings &settings, OptSolution *solution)
Definition PolymorphicFunctions.hpp:1691
friend std::unique_ptr< HybZono > halfspace_intersection(HybZono &Z, const Eigen::SparseMatrix< zono_float > &H, const Eigen::Vector< zono_float, -1 > &f, const Eigen::SparseMatrix< zono_float > &R)
Computes the intersection generalized intersection of set Z with halfspace H*x <= f over matrix R.
Definition PolymorphicFunctions.hpp:294
virtual Eigen::Vector< zono_float, -1 > get_c() const
Returns center vector.
Definition HybZono.hpp:185
bool is_point() const
Polymorphic type checking: true if set is a point.
Definition PolymorphicFunctions.hpp:34
virtual HybZono * clone() const
Clone method for polymorphic behavior.
Definition HybZono.hpp:96
virtual ~HybZono()=default
virtual int get_nGc() const
Returns number of continuous generators in set definition.
Definition HybZono.hpp:129
HybZono(const Eigen::SparseMatrix< zono_float > &Gc, const Eigen::SparseMatrix< zono_float > &Gb, const Eigen::Vector< zono_float, -1 > &c, const Eigen::SparseMatrix< zono_float > &Ac, const Eigen::SparseMatrix< zono_float > &Ab, const Eigen::Vector< zono_float, -1 > &b, const bool zero_one_form=false, const bool sharp=false)
HybZono constructor.
Definition HybZono.hpp:67
friend std::unique_ptr< HybZono > zono_union_2_hybzono(std::vector< Zono > &Zs, bool expose_indicators)
Computes a hybrid zonotope from a union of zonotopes.
Definition PolymorphicFunctions.hpp:1255
void set(const Eigen::SparseMatrix< zono_float > &Gc, const Eigen::SparseMatrix< zono_float > &Gb, const Eigen::Vector< zono_float, -1 > &c, const Eigen::SparseMatrix< zono_float > &Ac, const Eigen::SparseMatrix< zono_float > &Ab, const Eigen::Vector< zono_float, -1 > &b, bool zero_one_form=false, bool sharp=false)
Reset hybrid zonotope object with the given parameters.
Definition HybZono.hpp:714
virtual Eigen::SparseMatrix< zono_float > get_Ab() const
Returns binary constraint matrix.
Definition HybZono.hpp:171
virtual std::unique_ptr< ConZono > convex_relaxation() const
Returns convex relaxation of the hybrid zonotope.
Definition PolymorphicFunctions.hpp:1621
virtual Eigen::SparseMatrix< zono_float > get_A() const
Returns constraint matrix.
Definition HybZono.hpp:178
Eigen::Vector< zono_float, -1 > optimize_over(const Eigen::SparseMatrix< zono_float > &P, const Eigen::Vector< zono_float, -1 > &q, zono_float c=0, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr) const
Solves optimization problem with quadratic objective over the current set.
Definition HybZono.hpp:322
bool sharp
flag to indicate whether the set is known to be sharp (i.e., convex relaxation = convex hull)
Definition HybZono.hpp:488
virtual void remove_redundancy(int contractor_iter=100)
Removes redundant constraints and any unused generators.
Definition HybZono.hpp:771
Eigen::Vector< zono_float, -1 > c
center vector
Definition HybZono.hpp:464
int nGb
number of binary factors
Definition HybZono.hpp:479
static void remove_generators(Eigen::SparseMatrix< zono_float > &G, Eigen::SparseMatrix< zono_float > &A, const std::set< int > &idx_to_remove)
Definition HybZono.hpp:1050
HybZono()=default
Default constructor for HybZono class.
bool is_zono() const
Polymorphic type checking: true if set is a zonotope.
Definition PolymorphicFunctions.hpp:39
virtual Eigen::Vector< zono_float, -1 > get_b() const
Returns constraint vector.
Definition HybZono.hpp:192
Box bounding_box(const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr)
Computes a bounding box of the set object as a Box object.
Definition HybZono.hpp:398
static std::set< int > find_unused_generators(const Eigen::SparseMatrix< zono_float > &G, const Eigen::SparseMatrix< zono_float > &A)
Definition HybZono.hpp:1095
virtual int get_nG() const
Returns number of generators in set definition.
Definition HybZono.hpp:122
virtual bool do_contains_point(const Eigen::Vector< zono_float, -1 > &x, const OptSettings &settings, OptSolution *solution) const
Definition HybZono.hpp:963
Eigen::SparseMatrix< zono_float > A
constraint matrix A = [Ac, Ab]
Definition HybZono.hpp:455
Eigen::Vector< zono_float, -1 > b
constraint vector
Definition HybZono.hpp:467
virtual std::unique_ptr< HybZono > do_complement(zono_float, bool remove_redundancy, const OptSettings &settings, OptSolution *solution, int n_leaves, int contractor_iter)
Definition PolymorphicFunctions.hpp:979
friend std::unique_ptr< HybZono > constrain(HybZono &Z, const std::vector< Inequality > &ineqs, const Eigen::SparseMatrix< zono_float > &R)
Applies inequalities to set.
Definition PolymorphicFunctions.hpp:857
friend std::ostream & operator<<(std::ostream &os, const HybZono &Z)
Displays set information to the given output stream.
Definition HybZono.hpp:894
friend std::unique_ptr< HybZono > project_onto_dims(const HybZono &Z, const std::vector< int > &dims)
Projects set Z onto the dimensions specified in dims.
Definition PolymorphicFunctions.hpp:104
friend std::unique_ptr< HybZono > intersection(const HybZono &Z1, HybZono &Z2, const Eigen::SparseMatrix< zono_float > &R)
Computes the generalized intersection of sets Z1 and Z2 over the matrix R.
Definition PolymorphicFunctions.hpp:188
friend std::unique_ptr< HybZono > union_of_many(const std::vector< HybZono * > &Zs, bool preserve_sharpness, bool expose_indicators)
Computes union of several sets.
Definition PolymorphicFunctions.hpp:506
bool is_empty_set() const
Polymorphic type checking: true if set is empty set object.
Definition PolymorphicFunctions.hpp:55
std::vector< ConZono > get_leaves(bool remove_redundancy=true, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr, int n_leaves=std::numeric_limits< int >::max(), int contractor_iter=100) const
Computes individual constrained zonotopes whose union is the hybrid zonotope object.
Definition PolymorphicFunctions.hpp:1721
Eigen::SparseMatrix< zono_float > Ab
binary constraint matrix
Definition HybZono.hpp:461
virtual Eigen::SparseMatrix< zono_float > get_G() const
Returns generator matrix.
Definition HybZono.hpp:157
Eigen::SparseMatrix< zono_float > Ac
continuous constraint matrix
Definition HybZono.hpp:458
virtual Eigen::SparseMatrix< zono_float > get_Gb() const
Returns binary generator matrix.
Definition HybZono.hpp:150
Eigen::SparseMatrix< zono_float > G
generator matrix G = [Gc, Gb]
Definition HybZono.hpp:446
friend std::unique_ptr< HybZono > pontry_diff(HybZono &Z1, HybZono &Z2, bool exact)
Computes the Pontryagin difference Z1 - Z2.
Definition PolymorphicFunctions.hpp:324
int nGc
number of continuous factors
Definition HybZono.hpp:476
virtual Eigen::SparseMatrix< zono_float > get_Ac() const
Returns continuous constraint matrix.
Definition HybZono.hpp:164
virtual std::unique_ptr< HybZono > complement(const zono_float delta_m=100, const bool remove_redundancy=true, const OptSettings &settings=OptSettings(), OptSolution *solution=nullptr, const int n_leaves=std::numeric_limits< int >::max(), const int contractor_iter=100)
Computes the complement of the set Z.
Definition HybZono.hpp:258
friend std::unique_ptr< HybZono > set_diff(const HybZono &Z1, HybZono &Z2, zono_float delta_m, bool remove_redundancy, const OptSettings &settings, OptSolution *solution, int n_leaves, int contractor_iter)
Set difference Z1 \ Z2.
Definition PolymorphicFunctions.hpp:1239
#define zono_float
Defines the floating-point type used in ZonoOpt.
Definition ZonoOpt.hpp:43
std::unique_ptr< HybZono > cartesian_product(const HybZono &Z1, HybZono &Z2)
Computes the Cartesian product of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:798
std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:1239
std::unique_ptr< HybZono > union_of_many(const std::vector< HybZono * > &Zs, bool preserve_sharpness=false, bool expose_indicators=false)
Computes union of several sets.
Definition PolymorphicFunctions.hpp:506
std::unique_ptr< HybZono > minkowski_sum(const HybZono &Z1, HybZono &Z2)
Computes Minkowski sum of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:133
std::unique_ptr< HybZono > project_onto_dims(const HybZono &Z, const std::vector< int > &dims)
Projects set Z onto the dimensions specified in dims.
Definition PolymorphicFunctions.hpp:104
std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:61
std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:188
std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:294
std::unique_ptr< HybZono > 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.
Definition PolymorphicFunctions.hpp:263
std::unique_ptr< HybZono > pontry_diff(HybZono &Z1, HybZono &Z2, bool exact=false)
Computes the Pontryagin difference Z1 - Z2.
Definition PolymorphicFunctions.hpp:324
std::unique_ptr< HybZono > constrain(HybZono &Z, const std::vector< Inequality > &ineqs, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >())
Applies inequalities to set.
Definition PolymorphicFunctions.hpp:857
std::unique_ptr< HybZono > vrep_2_hybzono(const std::vector< Eigen::Matrix< zono_float, -1, -1 > > &Vpolys, bool expose_indicators=false)
Computes a hybrid zonotope from a union of vertex representation polytopes.
Definition PolymorphicFunctions.hpp:1402
std::unique_ptr< HybZono > zono_union_2_hybzono(std::vector< Zono > &Zs, bool expose_indicators=false)
Computes a hybrid zonotope from a union of zonotopes.
Definition PolymorphicFunctions.hpp:1255
std::ostream & operator<<(std::ostream &os, const HybZono &Z)
Definition HybZono.hpp:894
Settings for optimization routines in ZonoOpt library.
Definition SolverDataStructures.hpp:26
Solution data structure for optimization routines in ZonoOpt library.
Definition SolverDataStructures.hpp:153