ZonoOpt v1.0.0
Loading...
Searching...
No Matches
HybZono.hpp
Go to the documentation of this file.
1#ifndef ZONOOPT_HYBZONO_HPP_
2#define ZONOOPT_HYBZONO_HPP_
3
16#include "MI_Solver.hpp"
17#include "MI_DataStructures.hpp"
18#include "Inequality.hpp"
19#include "Intervals.hpp"
20
21#include <stdexcept>
22#include <limits>
23#include <set>
24
25namespace ZonoOpt
26{
27
28using namespace detail;
29
30// forward declarations
31class Zono;
32class ConZono;
33
44{
45 public:
46
47 // constructors
48
53 HybZono() = default;
54
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,
69 const bool zero_one_form=false, const bool sharp=false)
70 {
71 set(Gc, Gb, c, Ac, Ab, b, zero_one_form, sharp);
72 }
73
74 // virtual destructor
75 virtual ~HybZono() = default;
76
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,
91 bool zero_one_form=false, bool sharp=false);
92
96 virtual HybZono* clone() const
97 {
98 return new HybZono(*this);
99 }
100
101 // get methods
102
108 virtual int get_n() const { return this->n; }
109
115 virtual int get_nC() const { return this->nC; }
116
122 virtual int get_nG() const { return this->nG; }
123
129 virtual int get_nGc() const { return this->nGc; }
130
136 virtual int get_nGb() const { return this->nGb; }
137
143 virtual Eigen::SparseMatrix<zono_float> get_Gc() const { return this->Gc; }
144
150 virtual Eigen::SparseMatrix<zono_float> get_Gb() const { return this->Gb; }
151
157 virtual Eigen::SparseMatrix<zono_float> get_G() const { return this->G; }
158
164 virtual Eigen::SparseMatrix<zono_float> get_Ac() const { return this->Ac; }
165
171 virtual Eigen::SparseMatrix<zono_float> get_Ab() const { return this->Ab; }
172
178 virtual Eigen::SparseMatrix<zono_float> get_A() const { return this->A; }
179
185 virtual Eigen::Vector<zono_float, -1> get_c() const { return this->c; }
186
192 virtual Eigen::Vector<zono_float, -1> get_b() const { return this->b; }
193
199 virtual bool is_0_1_form() const { return this->zero_one_form; }
200
208 bool is_sharp() const { return this->sharp; }
209
217 virtual void convert_form();
218
229 virtual void remove_redundancy(int contractor_iter=100);
230
239 virtual std::unique_ptr<ConZono> convex_relaxation() const;
240
258 virtual std::unique_ptr<HybZono> complement(const zono_float delta_m = 100, const bool remove_redundancy=true, const OptSettings &settings=OptSettings(),
259 OptSolution* solution=nullptr, const int n_leaves = std::numeric_limits<int>::max(), const int contractor_iter=100)
260 {
261 return do_complement(delta_m, remove_redundancy, settings, solution, n_leaves, contractor_iter);
262 }
263
264 // type checking
269 bool is_point() const;
270
275 bool is_zono() const;
276
281 bool is_conzono() const;
282
287 bool is_hybzono() const;
288
292 bool is_empty_set() const;
293
294 // display methods
299 virtual std::string print() const;
300
307 friend std::ostream& operator<<(std::ostream& os, const HybZono& Z);
308
309 // optimization
322 Eigen::Vector<zono_float, -1> optimize_over(
323 const Eigen::SparseMatrix<zono_float> &P, const Eigen::Vector<zono_float, -1> &q, zono_float c=0,
324 const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr) const
325 {
326 return do_optimize_over(P, q, c, settings, solution);
327 }
328
337 Eigen::Vector<zono_float, -1> project_point(const Eigen::Vector<zono_float, -1>& x,
338 const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr) const
339 {
340 return do_project_point(x, settings, solution);
341 }
342
351 bool is_empty(const OptSettings &settings=OptSettings(),
352 OptSolution* solution=nullptr) const
353 {
354 return do_is_empty(settings, solution);
355 }
356
367 zono_float support(const Eigen::Vector<zono_float, -1>& d, const OptSettings &settings=OptSettings(),
368 OptSolution* solution=nullptr)
369 {
370 return do_support(d, settings, solution);
371 }
372
383 bool contains_point(const Eigen::Vector<zono_float, -1>& x, const OptSettings &settings=OptSettings(),
384 OptSolution* solution=nullptr) const
385 {
386 return do_contains_point(x, settings, solution);
387 }
388
398 Box bounding_box(const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr)
399 {
400 return do_bounding_box(settings, solution);
401 }
402
418 std::vector<ConZono> get_leaves(bool remove_redundancy=true, const OptSettings &settings=OptSettings(),
419 OptSolution* solution=nullptr, int n_leaves = std::numeric_limits<int>::max(), int contractor_iter=100) const;
420
421 // friend function declarations
422 friend std::unique_ptr<HybZono> affine_map(const HybZono& Z,
423 const Eigen::SparseMatrix<zono_float>& R, const Eigen::Vector<zono_float, -1>& s);
424 friend std::unique_ptr<HybZono> project_onto_dims(const HybZono& Z, const std::vector<int>& dims);
425 friend std::unique_ptr<HybZono> minkowski_sum(const HybZono& Z1, HybZono& Z2);
426 friend std::unique_ptr<HybZono> pontry_diff(HybZono& Z1, HybZono& Z2, bool exact);
427 friend std::unique_ptr<HybZono> intersection(const HybZono& Z1, HybZono& Z2,
428 const Eigen::SparseMatrix<zono_float>& R);
429 friend std::unique_ptr<HybZono> intersection_over_dims(const HybZono& Z1, HybZono& Z2,
430 const std::vector<int>& dims);
431 friend std::unique_ptr<HybZono> halfspace_intersection(HybZono& Z, const Eigen::SparseMatrix<zono_float>& H,
432 const Eigen::Vector<zono_float, -1>& f, const Eigen::SparseMatrix<zono_float>& R);
433 friend std::unique_ptr<HybZono> union_of_many(const std::vector<HybZono*>& Zs, bool preserve_sharpness, bool expose_indicators);
434 friend std::unique_ptr<HybZono> cartesian_product(const HybZono& Z1, HybZono& Z2);
435 friend std::unique_ptr<HybZono> constrain(HybZono& Z, const std::vector<Inequality> &ineqs, const Eigen::SparseMatrix<zono_float>& R);
436 friend std::unique_ptr<HybZono> set_diff(const HybZono& Z1, HybZono& Z2, zono_float delta_m, bool remove_redundancy,
437 const OptSettings &settings, OptSolution* solution, int n_leaves, int contractor_iter);
438 friend std::unique_ptr<HybZono> vrep_2_hybzono(const std::vector<Eigen::Matrix<zono_float, -1, -1>> &Vpolys, bool expose_indicators);
439 friend std::unique_ptr<HybZono> zono_union_2_hybzono(std::vector<Zono> &Zs, bool expose_indicators);
440
441 protected:
442
443 // fields
444
446 Eigen::SparseMatrix<zono_float> G = Eigen::SparseMatrix<zono_float>(0, 0);
447
449 Eigen::SparseMatrix<zono_float> Gc = Eigen::SparseMatrix<zono_float>(0, 0);
450
452 Eigen::SparseMatrix<zono_float> Gb = Eigen::SparseMatrix<zono_float>(0, 0);
453
455 Eigen::SparseMatrix<zono_float> A = Eigen::SparseMatrix<zono_float>(0, 0);
456
458 Eigen::SparseMatrix<zono_float> Ac = Eigen::SparseMatrix<zono_float>(0, 0);
459
461 Eigen::SparseMatrix<zono_float> Ab = Eigen::SparseMatrix<zono_float>(0, 0);
462
464 Eigen::Vector<zono_float, -1> c = Eigen::Vector<zono_float, -1>(0);
465
467 Eigen::Vector<zono_float, -1> b = Eigen::Vector<zono_float, -1>(0);
468
470 int n = 0;
471
473 int nG = 0;
474
476 int nGc = 0;
477
479 int nGb = 0;
480
482 int nC = 0;
483
485 bool zero_one_form = false;
486
488 bool sharp = false;
489
490 // methods
491 virtual Eigen::Vector<zono_float, -1> do_optimize_over(
492 const Eigen::SparseMatrix<zono_float> &P, const Eigen::Vector<zono_float, -1> &q, zono_float c,
493 const OptSettings &settings, OptSolution* solution) const;
494
495 virtual Eigen::Vector<zono_float, -1> do_project_point(const Eigen::Vector<zono_float, -1>& x,
496 const OptSettings &settings, OptSolution* solution) const;
497
498 virtual bool do_is_empty(const OptSettings &settings, OptSolution* solution) const;
499
500 virtual zono_float do_support(const Eigen::Vector<zono_float, -1>& d, const OptSettings &settings,
501 OptSolution* solution);
502
503 virtual bool do_contains_point(const Eigen::Vector<zono_float, -1>& x, const OptSettings &settings,
504 OptSolution* solution) const;
505
506 virtual Box do_bounding_box(const OptSettings &settings, OptSolution* solution);
507
508 virtual std::unique_ptr<HybZono> do_complement(zono_float, bool remove_redundancy, const OptSettings &settings,
509 OptSolution* solution, int n_leaves, int contractor_iter);
510
511
512 static void remove_generators(Eigen::SparseMatrix<zono_float>& G, Eigen::SparseMatrix<zono_float>& A, const std::set<int>& idx_to_remove);
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,
516 const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr) const;
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,
519 const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr) const;
520
521 private:
522
523 void make_G_A();
524 void set_Ac_Ab_from_A();
525 std::vector<Eigen::Vector<zono_float, -1>> get_bin_leaves(const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr,
526 int n_leaves = std::numeric_limits<int>::max()) const;
527};
528
529// forward delcarations
539std::unique_ptr<HybZono> affine_map(const HybZono& Z,
540 const Eigen::SparseMatrix<zono_float>& R, const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>());
541
550std::unique_ptr<HybZono> project_onto_dims(const HybZono& Z, const std::vector<int>& dims);
551
560std::unique_ptr<HybZono> minkowski_sum(const HybZono& Z1, HybZono& Z2);
561
580std::unique_ptr<HybZono> pontry_diff(HybZono& Z1, HybZono& Z2, bool exact=false);
581
591std::unique_ptr<HybZono> intersection(const HybZono& Z1, HybZono& Z2,
592 const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
593
603std::unique_ptr<HybZono> intersection_over_dims(const HybZono& Z1, HybZono& Z2,
604 const std::vector<int>& dims);
605
616std::unique_ptr<HybZono> halfspace_intersection(HybZono& Z, const Eigen::SparseMatrix<zono_float>& H,
617 const Eigen::Vector<zono_float, -1>& f, const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
618
632std::unique_ptr<HybZono> union_of_many(const std::vector<HybZono*>& Zs, bool preserve_sharpness=false, bool expose_indicators=false);
633
642std::unique_ptr<HybZono> cartesian_product(const HybZono& Z1, HybZono& Z2);
643
658std::unique_ptr<HybZono> constrain(HybZono& Z, const std::vector<Inequality> &ineqs, const Eigen::SparseMatrix<zono_float>& R=Eigen::SparseMatrix<zono_float>());
659
674std::unique_ptr<HybZono> set_diff(const HybZono& Z1, HybZono& Z2, zono_float delta_m = 100, bool remove_redundancy=true,
675 const OptSettings &settings=OptSettings(), OptSolution* solution=nullptr, int n_leaves = std::numeric_limits<int>::max(), int contractor_iter = 100);
676
677
693std::unique_ptr<HybZono> vrep_2_hybzono(const std::vector<Eigen::Matrix<zono_float, -1, -1>> &Vpolys, bool expose_indicators=false);
694
695
709std::unique_ptr<HybZono> zono_union_2_hybzono(std::vector<Zono> &Zs, bool expose_indicators=false);
710
711
712// implementation
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)
716{
717 // check dimensions
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())
720 {
721 throw std::invalid_argument("HybZono: inconsistent dimensions.");
722 }
723
724 this->Gc = Gc;
725 this->Gb = Gb;
726 this->Ac = Ac;
727 this->Ab = Ab;
728 this->c = c;
729 this->b = b;
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());
734 this->zero_one_form = zero_one_form;
735
736 make_G_A();
737
738 this->sharp = sharp;
739}
740
742{
743 Eigen::Vector<zono_float, -1> c, b;
744 Eigen::SparseMatrix<zono_float> Gb, Ab, Ac, Gc;
745
746 if (!this->zero_one_form) // convert to [0,1] generators
747 {
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);
750 Gb = 2.0*this->Gb;
751 Ab = 2.0*this->Ab;
752 Gc = 2.0*this->Gc;
753 Ac = 2.0*this->Ac;
754
755 set(Gc, Gb, c, Ac, Ab, b, true);
756 }
757 else // convert to [-1,1] generators
758 {
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);
761 Gb = 0.5*this->Gb;
762 Ab = 0.5*this->Ab;
763 Gc = 0.5*this->Gc;
764 Ac = 0.5*this->Ac;
765
766 set(Gc, Gb, c, Ac, Ab, b, false);
767 }
768}
769
770inline void HybZono::remove_redundancy(const int contractor_iter)
771{
772 // declare vars
773 std::set<int> idx_c_to_remove, idx_b_to_remove;
774
775 // lambda to remove generators
776 auto remove_all_generators = [this](const std::set<int>& idx_c, const std::set<int>& idx_b) -> void
777 {
778 // remove generators
779 if (!idx_c.empty()) {
780 remove_generators(this->Gc, this->Ac, idx_c);
781 }
782 if (!idx_b.empty()) {
783 remove_generators(this->Gb, this->Ab, idx_b);
784 }
785
786 // update number of generators (needs to happen before call to make_G_A())
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());
790
791 // update equivalent matrices
792 make_G_A();
793 };
794
795 // apply interval contractor
796 Eigen::Vector<zono_float, -1> x_l (this->nG);
797 Eigen::Vector<zono_float, -1> x_u (this->nG);
798 if (this->zero_one_form)
799 {
800 x_l.setZero();
801 }
802 else
803 {
804 x_l.setConstant(-1);
805 }
806 x_u.setOnes();
807 Box box (x_l, x_u);
808 box.contract(this->A, this->b, contractor_iter);
809
810 // find any variables whose values are fixed
811 std::vector<std::pair<int, zono_float>> fixed_vars;
812 for (int i=0; i<this->nG; ++i)
813 {
814 if (box[i].is_single_valued())
815 {
816 fixed_vars.emplace_back(i, box[i].get_y_max());
817 if (i < this->nGc)
818 {
819 idx_c_to_remove.insert(i);
820 }
821 else
822 {
823 idx_b_to_remove.insert(i-this->nGc);
824 }
825 }
826 }
827
828 // get updates to c and b
829 Eigen::Vector<zono_float, -1> dc (this->n);
830 Eigen::Vector<zono_float, -1> db (this->nC);
831 Eigen::Vector<zono_float, -1> dc_k (this->n);
832 Eigen::Vector<zono_float, -1> db_k (this->nC);
833 dc.setZero();
834 db.setZero();
835 for (auto& [k, val] : fixed_vars)
836 {
837 dc_k.setZero();
838 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(this->G, k); it; ++it)
839 {
840 dc_k(it.row()) = it.value()*val;
841 }
842 dc += dc_k;
843
844 db_k.setZero();
845 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(this->A, k); it; ++it)
846 {
847 db_k(it.row()) = it.value()*val;
848 }
849 db -= db_k;
850 }
851
852 // set center and constraint vector
853 this->c += dc;
854 this->b += db;
855
856 // remove generators
858
859 // remove redundant constraints
861 this->nC = static_cast<int>(this->A.rows());
862
863 // update Ac, Ab
864 set_Ac_Ab_from_A();
865
866 // identify any unused generators
867 idx_c_to_remove = find_unused_generators(this->Gc, this->Ac);
868 idx_b_to_remove = find_unused_generators(this->Gb, this->Ab);
869
870 // remove
872}
873
874inline std::string HybZono::print() const
875{
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;
890 return ss.str();
891}
892
893inline std::ostream& operator<<(std::ostream& os, const HybZono& Z)
894{
895 os << Z.print();
896 return os;
897}
898
899inline Eigen::Vector<zono_float, -1> HybZono::do_optimize_over(
900 const Eigen::SparseMatrix<zono_float> &P, const Eigen::Vector<zono_float, -1> &q, const zono_float c,
901 const OptSettings &settings, OptSolution* solution) const
902{
903 // check dimensions
904 if (P.rows() != this->n || P.cols() != this->n || q.size() != this->n)
905 {
906 throw std::invalid_argument("Optimize over: inconsistent dimensions.");
907 }
908
909 // cost
910 Eigen::SparseMatrix<zono_float> P_fact = this->G.transpose()*P*this->G;
911 Eigen::Vector<zono_float, -1> q_fact = this->G.transpose()*(P*this->c + q);
912 zono_float delta_c = (0.5*this->c.transpose()*P*this->c + q.transpose()*this->c)(0);
913
914 // solve MIQP
915 OptSolution sol = this->mi_opt(P_fact, q_fact, c+delta_c, this->A, this->b, settings, solution);
916 if (sol.infeasible)
917 return Eigen::Vector<zono_float, -1>(this->nG);
918 else
919 return this->G*sol.z + this->c;
920}
921
922inline Eigen::Vector<zono_float, -1> HybZono::do_project_point(const Eigen::Vector<zono_float, -1>& x,
923 const OptSettings &settings, OptSolution* solution) const
924{
925 // check dimensions
926 if (this->n != x.size())
927 {
928 throw std::invalid_argument("Point projection: inconsistent dimensions.");
929 }
930
931 // cost
932 Eigen::SparseMatrix<zono_float> P = this->G.transpose()*this->G;
933 Eigen::Vector<zono_float, -1> q = this->G.transpose()*(this->c-x);
934
935 // solve MIQP
936 const OptSolution sol = this->mi_opt(P, q, 0, this->A, this->b, settings, solution);
937 if (sol.infeasible)
938 throw std::runtime_error("Point projection: infeasible");
939
940 return this->G*sol.z + this->c;
941}
942
943inline bool HybZono::do_is_empty(const OptSettings &settings, OptSolution* solution) const
944{
945 // trivial case
946 if (this->n == 0)
947 return true;
948
949 // optimize over P=I, q=0
950 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
951 P.setIdentity();
952 Eigen::Vector<zono_float, -1> q = Eigen::Vector<zono_float, -1>::Zero(this->nG);
953
954 // solve
955 const std::vector<OptSolution> sol_vec = this->mi_opt_multisol(P, q, 0, this->A, this->b, 1, settings, solution);
956 if (sol_vec.size() > 0)
957 return sol_vec[0].infeasible;
958 else
959 return true;
960}
961
962inline bool HybZono::do_contains_point(const Eigen::Vector<zono_float, -1>& x, const OptSettings &settings,
963 OptSolution* solution) const
964{
965 // check dimensions
966 if (this->n != x.size())
967 {
968 throw std::invalid_argument("Contains point: inconsistent dimensions.");
969 }
970
971 // cost and constraints
972 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
973 P.setIdentity();
974 Eigen::Vector<zono_float, -1> q (this->nG);
975 q.setZero(); // zeros
976 Eigen::SparseMatrix<zono_float> A = vcat<zono_float>(this->A, this->G);
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;
980
981 // solve MIQP
982 const OptSolution sol = this->mi_opt(P, q, 0, A, b, settings, solution);
983 return !(sol.infeasible);
984}
985
986
987inline OptSolution HybZono::mi_opt(const Eigen::SparseMatrix<zono_float>& P, const Eigen::Vector<zono_float, -1>& q,
988 const zono_float c, const Eigen::SparseMatrix<zono_float>& A, const Eigen::Vector<zono_float, -1>& b,
989 const OptSettings &settings, OptSolution* solution) const
990{
991 // QP data
992 Eigen::Vector<zono_float, -1> xi_lb (this->nG);
993 if (this->zero_one_form)
994 xi_lb.setZero();
995 else
996 xi_lb.setConstant(-1);
997 const Eigen::Vector<zono_float, -1> xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
998
999 const auto admm_data = std::make_shared<ADMM_data>(P, q, A, b, xi_lb, xi_ub, c, settings);
1000
1001 // mixed integer data
1002 MI_data mi_data;
1003 mi_data.admm_data = admm_data;
1004 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1005 mi_data.zero_one_form = this->zero_one_form;
1006
1007 // build MI_ADMM_solver object
1008 MI_solver mi_solver(mi_data);
1009
1010 // solve optimization problem
1011 OptSolution sol = mi_solver.solve();
1012
1013 if (solution != nullptr)
1014 *solution = sol;
1015 return sol;
1016}
1017
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,
1020 const OptSettings &settings, OptSolution* solution) const
1021{
1022 // ADMM data
1023 Eigen::Vector<zono_float, -1> xi_lb (this->nG);
1024 if (this->zero_one_form)
1025 xi_lb.setZero();
1026 else
1027 xi_lb.setConstant(-1);
1028 const Eigen::Vector<zono_float, -1> xi_ub = Eigen::Vector<zono_float, -1>::Ones(this->nG);
1029
1030 const auto admm_data = std::make_shared<ADMM_data>(P, q, A, b, xi_lb, xi_ub, c, settings);
1031
1032 // mixed integer data
1033 MI_data mi_data;
1034 mi_data.admm_data = admm_data;
1035 mi_data.idx_b = std::make_pair(this->nGc, this->nGb);
1036 mi_data.zero_one_form = this->zero_one_form;
1037
1038 // build MI_ADMM_solver object
1039 MI_solver mi_solver(mi_data);
1040
1041 // solve optimization problem
1042 auto [fst, snd] = mi_solver.multi_solve(n_sols);
1043 if (solution != nullptr)
1044 *solution = snd;
1045 return fst;
1046}
1047
1048
1049inline void HybZono::remove_generators(Eigen::SparseMatrix<zono_float>& G, Eigen::SparseMatrix<zono_float>& A, const std::set<int>& idx_to_remove)
1050{
1051 // declare triplets
1052 std::vector<Eigen::Triplet<zono_float>> triplets;
1053
1054 // update G
1055 int delta_ind = 0;
1056 for (int k=0; k<G.outerSize(); k++)
1057 {
1058 if (idx_to_remove.count(k))
1059 {
1060 ++delta_ind;
1061 }
1062 else
1063 {
1064 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(G, k); it; ++it)
1065 {
1066 triplets.emplace_back(static_cast<int>(it.row()), k-delta_ind, it.value());
1067 }
1068 }
1069 }
1070 G.resize(G.rows(), G.cols() - delta_ind);
1071 G.setFromTriplets(triplets.begin(), triplets.end());
1072
1073 // update A
1074 triplets.clear();
1075 delta_ind = 0;
1076 for (int k=0; k<A.outerSize(); k++)
1077 {
1078 if (idx_to_remove.count(k))
1079 {
1080 ++delta_ind;
1081 }
1082 else
1083 {
1084 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(A, k); it; ++it)
1085 {
1086 triplets.emplace_back(static_cast<int>(it.row()), k-delta_ind, it.value());
1087 }
1088 }
1089 }
1090 A.resize(A.rows(), A.cols() - delta_ind);
1091 A.setFromTriplets(triplets.begin(), triplets.end());
1092}
1093
1094inline std::set<int> HybZono::find_unused_generators(const Eigen::SparseMatrix<zono_float>& G, const Eigen::SparseMatrix<zono_float>& A)
1095{
1096 std::set<int> idx_no_cons;
1097 for (int k=0; k<A.outerSize(); k++)
1098 {
1099 bool is_unused = true;
1100 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(A, k); it; ++it)
1101 {
1102 if (std::abs(it.value()) > zono_eps)
1103 {
1104 is_unused = false;
1105 break;
1106 }
1107 }
1108
1109 if (is_unused)
1110 {
1111 idx_no_cons.insert(k);
1112 }
1113 }
1114
1115 // check if any of idx_no_cons multiply only zeros
1116 std::set<int> idx_to_remove;
1117 for (int idx_no_con : idx_no_cons)
1118 {
1119 bool is_zero = true;
1120 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(G, idx_no_con); it; ++it)
1121 {
1122 if (std::abs(it.value()) > zono_eps)
1123 {
1124 is_zero = false;
1125 break;
1126 }
1127 }
1128
1129 if (is_zero)
1130 {
1131 idx_to_remove.insert(idx_no_con);
1132 }
1133 }
1134
1135 return idx_to_remove;
1136}
1137
1138inline void HybZono::make_G_A()
1139{
1140 std::vector<Eigen::Triplet<zono_float>> tripvec;
1142 get_triplets_offset<zono_float>(this->Gb, tripvec, 0, this->nGc);
1143 this->G.resize(this->n, this->nGc + this->nGb);
1144 this->G.setFromTriplets(tripvec.begin(), tripvec.end());
1145
1146 tripvec.clear();
1148 get_triplets_offset<zono_float>(this->Ab, tripvec, 0, this->nGc);
1149 this->A.resize(this->nC, this->nGc + this->nGb);
1150 this->A.setFromTriplets(tripvec.begin(), tripvec.end());
1151
1152 this->nG = this->nGc + this->nGb;
1153}
1154
1155inline void HybZono::set_Ac_Ab_from_A()
1156{
1157 std::vector<Eigen::Triplet<zono_float>> triplets_Ac, triplets_Ab;
1158
1159 // iterate over A
1160 for (int k=0; k<this->A.outerSize(); ++k)
1161 {
1162 for (Eigen::SparseMatrix<zono_float>::InnerIterator it(this->A, k); it; ++it)
1163 {
1164 if (it.col() < this->nGc)
1165 {
1166 triplets_Ac.emplace_back(static_cast<int>(it.row()), static_cast<int>(it.col()), it.value());
1167 }
1168 else
1169 {
1170 triplets_Ab.emplace_back(static_cast<int>(it.row()), static_cast<int>(it.col())-this->nGc, it.value());
1171 }
1172 }
1173 }
1174
1175 // set Ac, Ab
1176 this->Ac.resize(this->nC, this->nGc);
1177 this->Ac.setFromTriplets(triplets_Ac.begin(), triplets_Ac.end());
1178 this->Ab.resize(this->nC, this->nGb);
1179 this->Ab.setFromTriplets(triplets_Ab.begin(), triplets_Ab.end());
1180}
1181
1182inline std::vector<Eigen::Vector<zono_float, -1>> HybZono::get_bin_leaves(const OptSettings &settings, OptSolution* solution, const int n_leaves) const
1183{
1184 // optimize over P=I, q=0
1185 Eigen::SparseMatrix<zono_float> P (this->nG, this->nG);
1186 P.setIdentity();
1187 const Eigen::Vector<zono_float, -1> q = Eigen::Vector<zono_float, -1>::Zero(this->nG);
1188
1189 // solve
1190 std::vector<OptSolution> sol_vec = this->mi_opt_multisol(P, q, 0, this->A, this->b, n_leaves, settings, solution);
1191
1192 // get leaves as conzonos
1193 std::vector<Eigen::Vector<zono_float, -1>> bin_leaves;
1194 for (auto &sol : sol_vec)
1195 {
1196 bin_leaves.emplace_back(sol.z.segment(this->nGc, this->nGb));
1197 }
1198
1199 return bin_leaves;
1200}
1201
1202} // end namespace ZonoOpt
1203
1204#endif
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
Definition ADMM.hpp:41
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