20#include "Eigen/Sparse"
27 using namespace detail;
59 explicit Box(
const size_t size);
65 explicit Box(
const std::vector<Interval>& vals);
71 explicit Box(
const Eigen::Vector<Interval, -1>& vals);
79 Box(
const Eigen::Vector<zono_float, -1>&
x_lb,
const Eigen::Vector<zono_float, -1>&
x_ub);
86 std::vector<Interval>
to_array()
const;
140 virtual void project(Eigen::Ref<Eigen::Vector<zono_float, -1>> x)
const;
234 bool contains(
const Eigen::Vector<zono_float, -1>& v);
317 Box operator+(
const Eigen::Vector<zono_float, -1>& v)
const;
325 void operator+=(
const Eigen::Vector<zono_float, -1>& v);
334 friend Box operator+(
const Eigen::Vector<zono_float, -1>& v,
const Box& box);
357 Box operator-(
const Eigen::Vector<zono_float, -1>& v)
const;
364 void operator-=(
const Eigen::Vector<zono_float, -1>& v);
373 friend Box operator-(
const Eigen::Vector<zono_float, -1>& v,
const Box& box);
417 Box operator*(
const Eigen::Vector<zono_float, -1>& v)
const;
424 void operator*=(
const Eigen::Vector<zono_float, -1>& v);
433 friend Box operator*(
const Eigen::Vector<zono_float, -1>& v,
const Box& box);
461 friend Box operator*(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
const Box& box);
468 friend Box operator*(
const Eigen::Matrix<zono_float, -1, -1>& A,
const Box& box);
590 bool contract(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
const Eigen::Vector<zono_float, -1>& b,
609 const Eigen::Vector<zono_float, -1>& b,
int iter,
610 const Eigen::SparseMatrix<zono_float>& A,
const std::set<int>& inds,
611 int tree_search_depth);
619 Box linear_map(
const Eigen::Matrix<zono_float, -1, -1>& A)
const;
627 Box linear_map(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A)
const;
635 Box linear_map(
const Eigen::SparseMatrix<zono_float>& A)
const;
645 const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>())
const;
654 Box affine_map(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& R,
655 const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>())
const;
665 const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>())
const;
673 Interval dot(
const Eigen::Vector<zono_float, -1>& x)
const;
693 void permute(
const Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic>& P);
699 std::string
print()
const;
707 friend std::ostream&
operator<<(std::ostream& os,
const Box& box);
728 virtual bool contract_helper(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
729 const Eigen::Vector<zono_float, -1>& b,
const int iter,
730 const std::set<int>& constraints);
739 bool contract_forward(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
740 const Eigen::Vector<zono_float, -1>& b,
const std::set<int>& constraints);
748 void contract_backward(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
749 const Eigen::Vector<zono_float, -1>& b,
const std::set<int>& constraints);
761 static void get_vars_cons(
const Eigen::SparseMatrix<zono_float>& A,
762 const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>&
A_rm,
763 std::set<int>& constraints, std::set<int>&
vars,
const std::set<int>& new_vars,
764 int depth,
int max_depth);
784 class MI_Box final :
public Box
803 MI_Box(
const Eigen::Vector<zono_float, -1>&
x_lb,
const Eigen::Vector<zono_float, -1>&
x_ub,
804 const std::pair<int, int>& idx_b,
bool zero_one_form);
813 MI_Box(
const std::vector<Interval>& intervals,
const std::pair<int, int>& idx_b,
bool zero_one_form);
816 Box* clone()
const override;
819 void project(Eigen::Ref<Eigen::Vector<zono_float, -1>> x)
const override;
826 const std::pair<int, int>& binary_indices()
const {
return idx_b; }
829 zono_float get_bin_low()
const {
return bin_low; }
830 zono_float get_bin_high()
const {
return bin_high; }
833 bool contract_helper(
const Eigen::SparseMatrix<zono_float, Eigen::RowMajor>& A,
834 const Eigen::Vector<zono_float, -1>& b,
const int iter,
835 const std::set<int>& constraints)
override;
839 std::pair<int, int> idx_b;
907 Box
affine_map(
const Box& Z,
const Eigen::SparseMatrix<zono_float>& R,
908 const Eigen::Vector<zono_float, -1>& s = Eigen::Vector<zono_float, -1>());
952 const Eigen::SparseMatrix<zono_float>& R = Eigen::SparseMatrix<zono_float>(),
953 int contractor_iter = 10);
Defines for ZonoOpt library.
Eigen::SparseMatrix< double, Eigen::RowMajor > A_rm
Definition GurobiSolver.cpp:370
std::vector< ScopedVar > vars
Definition SCIPSolver.cpp:250
Box (i.e., interval vector) class.
Definition Box.hpp:46
zono_float support(const Eigen::Vector< zono_float, -1 > &d) const
Computes the support function of the box in the direction d.
Definition Box.cpp:701
std::vector< Interval > to_array() const
Convert to vector of intervals.
Definition Box.cpp:116
Interval dot(const Eigen::Vector< zono_float, -1 > &x) const
Linear map with vector.
Definition Box.cpp:686
std::string print() const
Print method.
Definition Box.cpp:717
void operator/=(const Box &other)
Elementwise division in-place.
Definition Box.cpp:480
bool operator==(const Box &other) const
Set equality operator.
Definition Box.cpp:565
void operator+=(const Box &other)
Elementwise addition in-place.
Definition Box.cpp:320
friend Box operator/(zono_float alpha, const Box &box)
Elementwise division with scalar.
Definition Box.cpp:500
Box linear_map(const Eigen::Matrix< zono_float, -1, -1 > &A) const
Linear map of box based on interval arithmetic.
Definition Box.cpp:606
Eigen::Vector< zono_float, -1 > x_ub
vector of upper bounds
Definition Box.hpp:715
bool contains_set(const Box &other) const
Check set containment.
Definition Box.cpp:245
Box intersection_over_dims(const Box &other, const std::vector< int > &dims) const
Box intersection over a subset of dimensions.
Definition Box.cpp:212
Box cartesian_product(const Box &other) const
Cartesian product of this box and other.
Definition Box.cpp:257
Eigen::Vector< zono_float, -1 > x_lb
vector of lower bounds
Definition Box.hpp:712
bool contains(const Eigen::Vector< zono_float, -1 > &v)
Check vector continment.
Definition Box.cpp:233
Box affine_map(const Eigen::Matrix< zono_float, -1, -1 > &R, const Eigen::Vector< zono_float, -1 > &s=Eigen::Vector< zono_float, -1 >()) const
Affine map R*[x] + s of the box based on interval arithmetic.
Definition Box.cpp:671
Box intersect(const Box &other) const
Box intersection.
Definition Box.cpp:188
Box & operator=(const Box &other)
Copy assignment.
Definition Box.cpp:100
Box()=default
Default constructor.
virtual void project(Eigen::Ref< Eigen::Vector< zono_float, -1 > > x) const
Projects vector onto the Box.
Definition Box.cpp:146
const Eigen::Vector< zono_float, -1 > & upper() const
Get upper bounds.
Definition Box.hpp:159
bool contract_subset(const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &A_rm, const Eigen::Vector< zono_float, -1 > &b, int iter, const Eigen::SparseMatrix< zono_float > &A, const std::set< int > &inds, int tree_search_depth)
Interval contractor over a subset of the dimensions of the box.
Definition Box.cpp:587
Box operator|(const Box &other) const
Box interval hull.
Definition Box.cpp:550
Eigen::Vector< zono_float, -1 > center() const
Get center of box.
Definition Box.cpp:163
Box operator&(const Box &other) const
Box intersection.
Definition Box.cpp:545
void permute(const Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic > &P)
Permutes in place using permutation matrix, i.e., [x] <- P*[x].
Definition Box.cpp:711
Box interval_hull(const Box &other) const
Box interval hull.
Definition Box.cpp:200
bool operator>=(const Box &other) const
Set containment operator.
Definition Box.cpp:560
size_t size() const
Get size of Box object.
Definition Box.cpp:141
friend std::ostream & operator<<(std::ostream &os, const Box &box)
print to ostream
Definition Box.cpp:728
Box radius() const
Get radius of box.
Definition Box.cpp:168
void set_element(int i, const Interval &val)
Element-wise assignment.
Definition Box.cpp:133
friend class detail::MI_Box
Definition Box.hpp:767
Interval get_element(int i) const
Element-wise access.
Definition Box.cpp:126
virtual Box * clone() const
Clone operation.
Definition Box.cpp:153
friend Box operator*(zono_float alpha, const Box &box)
Elementwise multiplication with scalar.
Definition Box.cpp:389
zono_float width() const
Get width of box.
Definition Box.cpp:158
bool contract(const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &A, const Eigen::Vector< zono_float, -1 > &b, int iter)
Interval contractor.
Definition Box.cpp:570
virtual ~Box()=default
Virtual destructor.
friend Box operator-(const Eigen::Vector< zono_float, -1 > &v, const Box &box)
Elementwise subtraction with vector.
Definition Box.cpp:374
void operator-=(const Box &other)
Elementwise subtraction in-place.
Definition Box.cpp:359
const Eigen::Vector< zono_float, -1 > & lower() const
Get lower bounds.
Definition Box.hpp:153
bool is_single_valued() const
Determine whether box is single-valued (i.e., all intervals have width 0 within numerical tolerance)
Definition Box.cpp:183
void operator*=(const Box &other)
Elementwise multiplication in-place.
Definition Box.cpp:379
friend Box operator+(const Eigen::Vector< zono_float, -1 > &v, const Box &box)
Elementwise addition with vector.
Definition Box.cpp:342
Box pontry_diff(const Box &other) const
Pontryagin difference of this box and other, i.e., {x : x + y is in this for all y in other}.
Definition Box.cpp:273
Box project_onto_dims(const std::vector< int > &dims) const
Projects the box onto the dimensions specified in dims.
Definition Box.cpp:286
bool is_empty() const
Determine whether box is empty (any contained interval is empty)
Definition Box.cpp:174
bool operator<=(const Box &other) const
Set containment operator.
Definition Box.cpp:555
Box minkowski_sum(const Box &other) const
Minkowski sum of this box and other.
Definition Box.cpp:266
Interval class.
Definition Interval.hpp:50
#define zono_float
Defines the floating-point type used in ZonoOpt.
Definition Defines.hpp:22
Box minkowski_sum(const Box &Z1, const Box &Z2)
Computes the Minkowski sum of two boxes Z1 and Z2.
Definition Box.cpp:939
Box intersection(const Box &Z1, const Box &Z2, const Eigen::SparseMatrix< zono_float > &R=Eigen::SparseMatrix< zono_float >(), int contractor_iter=10)
Computes the generalized intersection of boxes Z1 and Z2 over the matrix R.
Definition Box.cpp:980
Box interval_hull(const Box &Z1, const Box &Z2)
Computes the interval hull of two boxes.
Definition Box.cpp:959
Box pontry_diff(const Box &Z1, const Box &Z2)
Computes the Pontryagin difference Z1 - Z2 of two boxes.
Definition Box.cpp:944
Box affine_map(const Box &Z, const Eigen::SparseMatrix< zono_float > &R, const Eigen::Vector< zono_float, -1 > &s=Eigen::Vector< zono_float, -1 >())
Returns affine map R*Z + s of box Z.
Definition Box.cpp:954
Box cartesian_product(const Box &Z1, const Box &Z2)
Computes the Cartesian product of two boxes Z1 and Z2.
Definition Box.cpp:934
Box intersection_over_dims(const Box &Z1, const Box &Z2, const std::vector< int > &dims)
Computes the intersection of boxes Z1 and Z2 over the specified dimensions.
Definition Box.cpp:1039
Box project_onto_dims(const Box &Z, const std::vector< int > &dims)
Projects box Z onto the dimensions specified in dims.
Definition Box.cpp:949
Definition ZonoOpt.hpp:51