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();
526 int n_leaves = std::numeric_limits<int>::max())
const;
540 const Eigen::SparseMatrix<zono_float>& R,
const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>());
592 const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
604 const std::vector<int>& dims);
617 const Eigen::Vector<zono_float, -1>& f,
const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
632std::unique_ptr<HybZono>
union_of_many(
const std::vector<HybZono*>& Zs,
bool preserve_sharpness=
false,
bool expose_indicators=
false);
658std::unique_ptr<HybZono>
constrain(
HybZono& Z,
const std::vector<Inequality> &ineqs,
const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
693std::unique_ptr<HybZono>
vrep_2_hybzono(
const std::vector<Eigen::Matrix<zono_float, -1, -1>> &Vpolys,
bool expose_indicators=
false);
709std::unique_ptr<HybZono>
zono_union_2_hybzono(std::vector<Zono> &Zs,
bool expose_indicators=
false);
713inline void HybZono::set(
const Eigen::SparseMatrix<zono_float>& Gc,
const Eigen::SparseMatrix<zono_float>& Gb,
const Eigen::Vector<zono_float, -1>& c,
714 const Eigen::SparseMatrix<zono_float>& Ac,
const Eigen::SparseMatrix<zono_float>& Ab,
const Eigen::Vector<zono_float, -1>& b,
715 const bool zero_one_form,
const bool sharp)
718 if (
Gc.rows() !=
c.size() ||
Gb.rows() !=
c.size() ||
Gc.cols() !=
Ac.cols()
719 ||
Gb.cols() !=
Ab.cols() ||
Ac.rows() !=
b.size() ||
Ab.rows() !=
b.size())
721 throw std::invalid_argument(
"HybZono: inconsistent dimensions.");
730 this->nGc =
static_cast<int>(
Gc.cols());
731 this->nGb =
static_cast<int>(
Gb.cols());
732 this->nC =
static_cast<int>(
Ac.rows());
733 this->n =
static_cast<int>(
Gc.rows());
744 Eigen::SparseMatrix<zono_float>
Gb,
Ab,
Ac,
Gc;
746 if (!this->zero_one_form)
748 c = this->c - this->G*Eigen::Vector<zono_float, -1>::Ones(this->nG);
749 b = this->b + this->A*Eigen::Vector<zono_float, -1>::Ones(this->nG);
759 c = this->c + 0.5*this->G*Eigen::Vector<zono_float, -1>::Ones(this->nG);
760 b = this->b - 0.5*this->A*Eigen::Vector<zono_float, -1>::Ones(this->nG);
779 if (!
idx_c.empty()) {
782 if (!idx_b.empty()) {
787 this->nG =
static_cast<int>(this->G.cols());
788 this->nGc =
static_cast<int>(this->Gc.cols());
789 this->nGb =
static_cast<int>(this->Gb.cols());
798 if (this->zero_one_form)
808 box.contract(this->A, this->b, contractor_iter);
811 std::vector<std::pair<int, zono_float>>
fixed_vars;
812 for (
int i=0;
i<this->
nG; ++
i)
814 if (box[
i].is_single_valued())
838 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->G,
k);
it; ++
it)
845 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->A,
k);
it; ++
it)
861 this->nC =
static_cast<int>(this->A.rows());
876 std::stringstream
ss;
877 ss <<
"HybZono: " << std::endl;
878 ss <<
"n: " << this->n << std::endl;
879 ss <<
"nGc: " << this->nGc << std::endl;
880 ss <<
"nGb: " << this->nGb << std::endl;
881 ss <<
"nC: " << this->nC << std::endl;
882 ss <<
"Gc: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Gc) << std::endl;
883 ss <<
"Gb: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Gb) << std::endl;
884 ss <<
"c: " << this->c << std::endl;
885 ss <<
"Ac: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Ac) << std::endl;
886 ss <<
"Ab: " << Eigen::Matrix<
zono_float, -1, -1>(this->
Ab) << std::endl;
887 ss <<
"b: " << this->b << std::endl;
888 ss <<
"zero_one_form: " << this->zero_one_form << std::endl;
889 ss <<
"sharp: " << this->
sharp;
900 const Eigen::SparseMatrix<zono_float> &P,
const Eigen::Vector<zono_float, -1> &q,
const zono_float c,
904 if (P.rows() !=
this->n || P.cols() !=
this->n || q.size() !=
this->n)
906 throw std::invalid_argument(
"Optimize over: inconsistent dimensions.");
910 Eigen::SparseMatrix<zono_float>
P_fact = this->G.transpose()*P*this->
G;
919 return this->G*
sol.z + this->
c;
926 if (this->n != x.size())
928 throw std::invalid_argument(
"Point projection: inconsistent dimensions.");
932 Eigen::SparseMatrix<zono_float> P = this->G.transpose()*this->
G;
933 Eigen::Vector<
zono_float, -1> q = this->G.transpose()*(this->c-x);
938 throw std::runtime_error(
"Point projection: infeasible");
940 return this->G*
sol.z + this->
c;
950 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
952 Eigen::Vector<
zono_float, -1> q = Eigen::Vector<zono_float, -1>::Zero(this->nG);
955 const std::vector<OptSolution>
sol_vec = this->
mi_opt_multisol(P, q, 0, this->A, this->b, 1, settings, solution);
966 if (this->n != x.size())
968 throw std::invalid_argument(
"Contains point: inconsistent dimensions.");
972 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
977 Eigen::Vector<
zono_float, -1>
b (this->nC + this->n);
978 b.segment(0, this->nC) = this->
b;
979 b.segment(this->nC, this->n) = x-this->
c;
983 return !(
sol.infeasible);
988 const zono_float c,
const Eigen::SparseMatrix<zono_float>& A,
const Eigen::Vector<zono_float, -1>& b,
993 if (this->zero_one_form)
996 xi_lb.setConstant(-1);
997 const Eigen::Vector<
zono_float, -1>
xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
999 const auto admm_data = std::make_shared<ADMM_data>(P, q,
A,
b,
xi_lb,
xi_ub,
c, settings);
1003 mi_data.admm_data = admm_data;
1004 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1013 if (solution !=
nullptr)
1018inline std::vector<OptSolution>
HybZono::mi_opt_multisol(
const Eigen::SparseMatrix<zono_float>& P,
const Eigen::Vector<zono_float, -1>& q,
1019 const zono_float c,
const Eigen::SparseMatrix<zono_float>& A,
const Eigen::Vector<zono_float, -1>& b,
int n_sols,
1024 if (this->zero_one_form)
1027 xi_lb.setConstant(-1);
1028 const Eigen::Vector<
zono_float, -1>
xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
1030 const auto admm_data = std::make_shared<ADMM_data>(P, q,
A,
b,
xi_lb,
xi_ub,
c, settings);
1034 mi_data.admm_data = admm_data;
1035 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1043 if (solution !=
nullptr)
1049inline void HybZono::remove_generators(Eigen::SparseMatrix<zono_float>& G, Eigen::SparseMatrix<zono_float>& A,
const std::set<int>& idx_to_remove)
1052 std::vector<Eigen::Triplet<zono_float>>
triplets;
1056 for (
int k=0;
k<
G.outerSize();
k++)
1064 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
G,
k);
it; ++
it)
1076 for (
int k=0;
k<
A.outerSize();
k++)
1084 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
A,
k);
it; ++
it)
1097 for (
int k=0;
k<
A.outerSize();
k++)
1100 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
A,
k);
it; ++
it)
1120 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(
G,
idx_no_con);
it; ++
it)
1138inline void HybZono::make_G_A()
1140 std::vector<Eigen::Triplet<zono_float>>
tripvec;
1143 this->G.resize(this->n, this->nGc + this->nGb);
1149 this->A.resize(this->nC, this->nGc + this->nGb);
1152 this->nG = this->nGc + this->
nGb;
1155inline void HybZono::set_Ac_Ab_from_A()
1160 for (
int k=0;
k<this->A.outerSize(); ++
k)
1162 for (Eigen::SparseMatrix<zono_float>::InnerIterator
it(this->A,
k);
it; ++
it)
1164 if (
it.col() <
this->nGc)
1166 triplets_Ac.emplace_back(
static_cast<int>(
it.row()),
static_cast<int>(
it.col()),
it.value());
1170 triplets_Ab.emplace_back(
static_cast<int>(
it.row()),
static_cast<int>(
it.col())-
this->nGc,
it.value());
1176 this->Ac.resize(this->nC, this->nGc);
1178 this->Ab.resize(this->nC, this->nGb);
1182inline std::vector<Eigen::Vector<
zono_float, -1>> HybZono::get_bin_leaves(
const OptSettings &settings, OptSolution* solution,
const int n_leaves)
const
1185 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
1187 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:718
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:71
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:1018
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:808
int n
set dimension
Definition HybZono.hpp:470
virtual bool do_is_empty(const OptSettings &settings, OptSolution *solution) const
Definition HybZono.hpp:943
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:143
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:273
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:987
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:56
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:1411
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:922
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:899
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:741
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:874
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:47
virtual Box do_bounding_box(const OptSettings &settings, OptSolution *solution)
Definition PolymorphicFunctions.hpp:1633
virtual zono_float do_support(const Eigen::Vector< zono_float, -1 > &d, const OptSettings &settings, OptSolution *solution)
Definition PolymorphicFunctions.hpp:1700
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:304
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:1264
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:713
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:1630
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:770
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:1049
HybZono()=default
Default constructor for HybZono class.
bool is_zono() const
Polymorphic type checking: true if set is a zonotope.
Definition PolymorphicFunctions.hpp:40
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:1094
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:962
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:989
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:867
friend std::ostream & operator<<(std::ostream &os, const HybZono &Z)
Displays set information to the given output stream.
Definition HybZono.hpp:893
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:114
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:198
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:516
bool is_empty_set() const
Polymorphic type checking: true if set is empty set object.
Definition PolymorphicFunctions.hpp:64
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:1730
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:334
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:1248
#define zono_float
Defines the floating-point type used in ZonoOpt.
Definition ZonoOpt.hpp:43
#define zono_eps
Defines the precision used for floating point comparisons in ZonoOpt.
Definition ZonoOpt.hpp:51
std::unique_ptr< HybZono > cartesian_product(const HybZono &Z1, HybZono &Z2)
Computes the Cartesian product of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:808
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:1248
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:516
std::unique_ptr< HybZono > minkowski_sum(const HybZono &Z1, HybZono &Z2)
Computes Minkowski sum of two sets Z1 and Z2.
Definition PolymorphicFunctions.hpp:143
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:114
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:71
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:198
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:304
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:273
std::unique_ptr< HybZono > pontry_diff(HybZono &Z1, HybZono &Z2, bool exact=false)
Computes the Pontryagin difference Z1 - Z2.
Definition PolymorphicFunctions.hpp:334
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:867
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:1411
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:1264
std::ostream & operator<<(std::ostream &os, const HybZono &Z)
Definition HybZono.hpp:893
Settings for optimization routines in ZonoOpt library.
Definition SolverDataStructures.hpp:26
Solution data structure for optimization routines in ZonoOpt library.
Definition SolverDataStructures.hpp:153