ZonoOpt 2.2.0
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
ZonoOpt::Box Class Reference

Box (i.e., interval vector) class. More...

#include <Box.hpp>

Inheritance diagram for ZonoOpt::Box:
Inheritance graph
[legend]

Public Member Functions

 Box ()=default
 Default constructor.
 
 Box (const size_t size)
 Default construct with size specified.
 
 Box (const std::vector< Interval > &vals)
 Constructor using vector of intervals.
 
 Box (const Eigen::Vector< Interval, -1 > &vals)
 Constructor using Eigen vector of intervals.
 
 Box (const Eigen::Vector< zono_float, -1 > &x_lb, const Eigen::Vector< zono_float, -1 > &x_ub)
 Constructor from intervals of lower and upper bounds.
 
std::vector< Intervalto_array () const
 Convert to vector of intervals.
 
virtual ~Box ()=default
 Virtual destructor.
 
Boxoperator= (const Box &other)
 Copy assignment.
 
 Box (const Box &other)
 Copy constructor.
 
Interval get_element (int i) const
 Element-wise access.
 
void set_element (int i, const Interval &val)
 Element-wise assignment.
 
size_t size () const
 Get size of Box object.
 
virtual void project (Eigen::Ref< Eigen::Vector< zono_float, -1 > > x) const
 Projects vector onto the Box.
 
virtual Boxclone () const
 Clone operation.
 
const Eigen::Vector< zono_float, -1 > & lower () const
 Get lower bounds.
 
const Eigen::Vector< zono_float, -1 > & upper () const
 Get upper bounds.
 
zono_float width () const
 Get width of box.
 
Box radius () const
 Get radius of box.
 
Eigen::Vector< zono_float, -1 > center () const
 Get center of box.
 
Box intersect (const Box &other) const
 Box intersection.
 
Box interval_hull (const Box &other) const
 Box interval hull.
 
bool contains (const Eigen::Vector< zono_float, -1 > &v)
 Check vector continment.
 
bool contains_set (const Box &other) const
 Check set containment.
 
Box operator+ (const Box &other) const
 Elementwise addition.
 
void operator+= (const Box &other)
 Elementwise addition in-place.
 
Box operator+ (const Eigen::Vector< zono_float, -1 > &v) const
 Elementwise addition with vector.
 
void operator+= (const Eigen::Vector< zono_float, -1 > &v)
 Elementwise addition with vector in-place.
 
Box operator- (const Box &other) const
 Elementwise subtraction.
 
void operator-= (const Box &other)
 Elementwise subtraction in-place.
 
Box operator- (const Eigen::Vector< zono_float, -1 > &v) const
 Elementwise subtraction with vector.
 
void operator-= (const Eigen::Vector< zono_float, -1 > &v)
 Elementwise subtraction with vector in-place.
 
Box operator* (const Box &other) const
 Elementwise multiplication.
 
void operator*= (const Box &other)
 Elementwise multiplication in-place.
 
Box operator* (zono_float alpha) const
 Elementwise multiplication with scalar.
 
void operator*= (zono_float alpha)
 Elementwise multiplication with scalar in-place.
 
Box operator* (const Eigen::Vector< zono_float, -1 > &v) const
 Elementwise multiplication with vector.
 
void operator*= (const Eigen::Vector< zono_float, -1 > &v)
 Elementwise multiplication with vector in-place.
 
Box operator* (const Interval &interval) const
 Elementwise multiplication with interval.
 
void operator*= (const Interval &interval)
 Elementwise multiplication with interval in-place.
 
Box operator/ (const Box &other) const
 Elementwise division.
 
void operator/= (const Box &other)
 Elementwise division in-place.
 
Box operator/ (zono_float alpha) const
 Elementwise division with scalar.
 
void operator/= (zono_float alpha)
 Elementwise division with scalar.
 
Box operator/ (const Interval &interval) const
 Elementwise division with interval.
 
void operator/= (const Interval &interval)
 Elementwise division with interval in-place.
 
Box operator- () const
 Unary minus: returns -1 * this.
 
Box operator& (const Box &other) const
 Box intersection.
 
Box operator| (const Box &other) const
 Box interval hull.
 
bool operator<= (const Box &other) const
 Set containment operator.
 
bool operator>= (const Box &other) const
 Set containment operator.
 
bool operator== (const Box &other) const
 Set equality operator.
 
bool contract (const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &A, const Eigen::Vector< zono_float, -1 > &b, int iter)
 Interval contractor.
 
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.
 
Box linear_map (const Eigen::Matrix< zono_float, -1, -1 > &A) const
 Linear map of box based on interval arithmetic.
 
Box linear_map (const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &A) const
 Linear map of box based on interval arithmetic.
 
Interval dot (const Eigen::Vector< zono_float, -1 > &x) const
 Linear map with vector.
 
void permute (const Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic > &P)
 Permutes in place using permutation matrix, i.e., [x] <- P*[x].
 
std::string print () const
 Print method.
 

Protected Attributes

Eigen::Vector< zono_float, -1 > x_lb
 vector of lower bounds
 
Eigen::Vector< zono_float, -1 > x_ub
 vector of upper bounds
 

Friends

class MI_Box
 
Box operator+ (const Eigen::Vector< zono_float, -1 > &v, const Box &box)
 Elementwise addition with vector.
 
Box operator- (const Eigen::Vector< zono_float, -1 > &v, const Box &box)
 Elementwise subtraction with vector.
 
Box operator* (zono_float alpha, const Box &box)
 Elementwise multiplication with scalar.
 
Box operator* (const Eigen::Vector< zono_float, -1 > &v, const Box &box)
 Elementwise multiplication with vector.
 
Box operator* (const Interval &interval, const Box &box)
 Elementwise multiplication with interval.
 
Box operator* (const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &A, const Box &box)
 Linear map.
 
Box operator* (const Eigen::Matrix< zono_float, -1, -1 > &A, const Box &box)
 Linear map.
 
Box operator/ (zono_float alpha, const Box &box)
 Elementwise division with scalar.
 
Box operator/ (const Interval &interval, const Box &box)
 Elementwise division with interval.
 
std::ostream & operator<< (std::ostream &os, const Box &box)
 print to ostream
 

Detailed Description

Box (i.e., interval vector) class.

Constructor & Destructor Documentation

◆ Box() [1/6]

ZonoOpt::Box::Box ( )
default

Default constructor.

◆ Box() [2/6]

ZonoOpt::Box::Box ( const size_t  size)
explicit

Default construct with size specified.

Parameters
sizedimension of box

◆ Box() [3/6]

ZonoOpt::Box::Box ( const std::vector< Interval > &  vals)
explicit

Constructor using vector of intervals.

Parameters
valsvector of intervals

◆ Box() [4/6]

ZonoOpt::Box::Box ( const Eigen::Vector< Interval, -1 > &  vals)
explicit

Constructor using Eigen vector of intervals.

Parameters
valsEigen vector of intervals

◆ Box() [5/6]

ZonoOpt::Box::Box ( const Eigen::Vector< zono_float, -1 > &  x_lb,
const Eigen::Vector< zono_float, -1 > &  x_ub 
)

Constructor from intervals of lower and upper bounds.

Parameters
x_lbvector of lower bounds
x_ubvector of upper bounds

◆ ~Box()

virtual ZonoOpt::Box::~Box ( )
virtualdefault

Virtual destructor.

◆ Box() [6/6]

ZonoOpt::Box::Box ( const Box other)

Copy constructor.

Parameters
otherother Box object

Member Function Documentation

◆ center()

Eigen::Vector< zono_float, -1 > ZonoOpt::Box::center ( ) const

Get center of box.

Returns
center of box

◆ clone()

Box * ZonoOpt::Box::clone ( ) const
virtual

Clone operation.

Returns
pointer to newly created object

Reimplemented in ZonoOpt::MI_Box.

◆ contains()

bool ZonoOpt::Box::contains ( const Eigen::Vector< zono_float, -1 > &  v)

Check vector continment.

Parameters
vvector
Returns
true if v is contained in box, false otherwise

◆ contains_set()

bool ZonoOpt::Box::contains_set ( const Box other) const

Check set containment.

Parameters
otherbox to check if subset
Returns
true if other is a subset of this

◆ contract()

bool ZonoOpt::Box::contract ( const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &  A,
const Eigen::Vector< zono_float, -1 > &  b,
int  iter 
)

Interval contractor.

Parameters
Aconstraint matrix (row-major)
bconstraint vector
iternumber of contractor iterations
Returns
flag indicating that the contractor did not detect that A*x=b and the box do not intersect

Executes a forward-backward interval contractor for the equality constraint A*x=b. For points x in the box, this shrinks the box without removing any points x that satisfy A*x=b. If the contractor detects that the box does not intersect A*x=b, then this function will return false.

◆ contract_subset()

bool ZonoOpt::Box::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.

Parameters
A_rmconstraint matrix, row major
bconstraint vector
iternumber of contractor iterations
Aconstraint matrix, column major
indsbox dimension indices
tree_search_depthhow deep to search constraint tree
Returns
flag indicating that the contractor did not detect that A*x=b and the box do not intersect

This is a forward-backward contractor over a subset of the dimensions of the box. This detects what other dimensions are affected up to a specified search depth prior to executing the contractor.

◆ dot()

Interval ZonoOpt::Box::dot ( const Eigen::Vector< zono_float, -1 > &  x) const

Linear map with vector.

Parameters
xvector
Returns
Interval

◆ get_element()

Interval ZonoOpt::Box::get_element ( int  i) const

Element-wise access.

Parameters
iindex
Returns
Interval for element i in Box

◆ intersect()

Box ZonoOpt::Box::intersect ( const Box other) const

Box intersection.

Parameters
otherother
Returns
intersection of this and other

◆ interval_hull()

Box ZonoOpt::Box::interval_hull ( const Box other) const

Box interval hull.

Parameters
otherother box
Returns
interval hull of this and other

◆ linear_map() [1/2]

Box ZonoOpt::Box::linear_map ( const Eigen::Matrix< zono_float, -1, -1 > &  A) const

Linear map of box based on interval arithmetic.

Parameters
Amap matrix (dense)
Returns
Linear mapped box

◆ linear_map() [2/2]

Box ZonoOpt::Box::linear_map ( const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &  A) const

Linear map of box based on interval arithmetic.

Parameters
Amap matrix (sparse row major)
Returns
Linear mapped box

◆ lower()

const Eigen::Vector< zono_float, -1 > & ZonoOpt::Box::lower ( ) const
inline

Get lower bounds.

Returns
const reference to lower bounds

◆ operator&()

Box ZonoOpt::Box::operator& ( const Box other) const

Box intersection.

Parameters
otherother box
Returns
Intersection of this and other

◆ operator*() [1/4]

Box ZonoOpt::Box::operator* ( const Box other) const

Elementwise multiplication.

Parameters
otherrhs box
Returns
enclosure of this * other (elementwise)

◆ operator*() [2/4]

Box ZonoOpt::Box::operator* ( const Eigen::Vector< zono_float, -1 > &  v) const

Elementwise multiplication with vector.

Parameters
vvector to multiply
Returns
enclosure of this * v (elementwise)

◆ operator*() [3/4]

Box ZonoOpt::Box::operator* ( const Interval interval) const

Elementwise multiplication with interval.

Parameters
intervalinterval to multiply
Returns
enclosure of this * interval (elementwise)

◆ operator*() [4/4]

Box ZonoOpt::Box::operator* ( zono_float  alpha) const

Elementwise multiplication with scalar.

Parameters
alphascalar multiplier
Returns
enclosure of alpha * this (elementwise)

◆ operator*=() [1/4]

void ZonoOpt::Box::operator*= ( const Box other)

Elementwise multiplication in-place.

Parameters
otherother box

◆ operator*=() [2/4]

void ZonoOpt::Box::operator*= ( const Eigen::Vector< zono_float, -1 > &  v)

Elementwise multiplication with vector in-place.

Parameters
vvector to multiply

◆ operator*=() [3/4]

void ZonoOpt::Box::operator*= ( const Interval interval)

Elementwise multiplication with interval in-place.

Parameters
intervalinterval to multiply

◆ operator*=() [4/4]

void ZonoOpt::Box::operator*= ( zono_float  alpha)

Elementwise multiplication with scalar in-place.

Parameters
alphascalar multiplier

◆ operator+() [1/2]

Box ZonoOpt::Box::operator+ ( const Box other) const

Elementwise addition.

Parameters
otherrhs box
Returns
enclosure of this + other (elementwise)

◆ operator+() [2/2]

Box ZonoOpt::Box::operator+ ( const Eigen::Vector< zono_float, -1 > &  v) const

Elementwise addition with vector.

Parameters
vvector to add
boxbox to add
Returns
enclosure of v + box (elementwise)

◆ operator+=() [1/2]

void ZonoOpt::Box::operator+= ( const Box other)

Elementwise addition in-place.

Parameters
otherother box

◆ operator+=() [2/2]

void ZonoOpt::Box::operator+= ( const Eigen::Vector< zono_float, -1 > &  v)

Elementwise addition with vector in-place.

Parameters
vvector

◆ operator-() [1/3]

Box ZonoOpt::Box::operator- ( ) const

Unary minus: returns -1 * this.

Returns
enclosure of -this

◆ operator-() [2/3]

Box ZonoOpt::Box::operator- ( const Box other) const

Elementwise subtraction.

Parameters
otherrhs box
Returns
enclosure of this - other (elementwise)

◆ operator-() [3/3]

Box ZonoOpt::Box::operator- ( const Eigen::Vector< zono_float, -1 > &  v) const

Elementwise subtraction with vector.

Parameters
vvector to subtract
Returns
enclosure of this - v (elementwise)

◆ operator-=() [1/2]

void ZonoOpt::Box::operator-= ( const Box other)

Elementwise subtraction in-place.

Parameters
otherother box

◆ operator-=() [2/2]

void ZonoOpt::Box::operator-= ( const Eigen::Vector< zono_float, -1 > &  v)

Elementwise subtraction with vector in-place.

Parameters
vvector to subtract

◆ operator/() [1/3]

Box ZonoOpt::Box::operator/ ( const Box other) const

Elementwise division.

Parameters
otherrhs box
Returns
enclosure of this / other (elementwise)

◆ operator/() [2/3]

Box ZonoOpt::Box::operator/ ( const Interval interval) const

Elementwise division with interval.

Parameters
intervalinterval to divide
Returns
enclosure of this / interval (elementwise)

◆ operator/() [3/3]

Box ZonoOpt::Box::operator/ ( zono_float  alpha) const

Elementwise division with scalar.

Parameters
alphascalar divisor
Returns
enclosure of this / alpha (elementwise)

◆ operator/=() [1/3]

void ZonoOpt::Box::operator/= ( const Box other)

Elementwise division in-place.

Parameters
otherrhs box

◆ operator/=() [2/3]

void ZonoOpt::Box::operator/= ( const Interval interval)

Elementwise division with interval in-place.

Parameters
intervalinterval to divide

◆ operator/=() [3/3]

void ZonoOpt::Box::operator/= ( zono_float  alpha)

Elementwise division with scalar.

Parameters
alphascalar divisor

◆ operator<=()

bool ZonoOpt::Box::operator<= ( const Box other) const

Set containment operator.

Parameters
other
Returns
true if this is subset of other

◆ operator=()

Box & ZonoOpt::Box::operator= ( const Box other)

Copy assignment.

Parameters
otherother Box object
Returns
this = other

◆ operator==()

bool ZonoOpt::Box::operator== ( const Box other) const

Set equality operator.

Parameters
other
Returns
true if sets are equal

◆ operator>=()

bool ZonoOpt::Box::operator>= ( const Box other) const

Set containment operator.

Parameters
other
Returns
true if this is superset of other

◆ operator|()

Box ZonoOpt::Box::operator| ( const Box other) const

Box interval hull.

Parameters
otherbox
Returns
Interval hull of this and other

◆ permute()

void ZonoOpt::Box::permute ( const Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic > &  P)

Permutes in place using permutation matrix, i.e., [x] <- P*[x].

Parameters
Ppermutation matrix

◆ print()

std::string ZonoOpt::Box::print ( ) const

Print method.

Returns
string display of Box

◆ project()

void ZonoOpt::Box::project ( Eigen::Ref< Eigen::Vector< zono_float, -1 > >  x) const
virtual

Projects vector onto the Box.

Parameters
xvector reference

Reimplemented in ZonoOpt::MI_Box.

◆ radius()

Box ZonoOpt::Box::radius ( ) const

Get radius of box.

Returns
radius of box

Returns box with intervals centered at zero with width equal to the width of the original box

◆ set_element()

void ZonoOpt::Box::set_element ( int  i,
const Interval val 
)

Element-wise assignment.

Parameters
iindex
valinterval to assign

◆ size()

size_t ZonoOpt::Box::size ( ) const

Get size of Box object.

Returns
size of box

◆ to_array()

std::vector< Interval > ZonoOpt::Box::to_array ( ) const

Convert to vector of intervals.

Returns
std::vector<Interval>

◆ upper()

const Eigen::Vector< zono_float, -1 > & ZonoOpt::Box::upper ( ) const
inline

Get upper bounds.

Returns
const reference to upper bounds

◆ width()

zono_float ZonoOpt::Box::width ( ) const

Get width of box.

Returns
width of box

Specifically, this returns the max width for any interval in the box

Friends And Related Symbol Documentation

◆ MI_Box

friend class MI_Box
friend

◆ operator* [1/5]

Box operator* ( const Eigen::Matrix< zono_float, -1, -1 > &  A,
const Box box 
)
friend

Linear map.

Parameters
Amatrix to multiply
Returns
enclosure of A * this

◆ operator* [2/5]

Box operator* ( const Eigen::SparseMatrix< zono_float, Eigen::RowMajor > &  A,
const Box box 
)
friend

Linear map.

Parameters
Amatrix to multiply
Returns
enclosure of A * this

◆ operator* [3/5]

Box operator* ( const Eigen::Vector< zono_float, -1 > &  v,
const Box box 
)
friend

Elementwise multiplication with vector.

Parameters
vvector to multiply
boxbox to multiply
Returns
enclosure of v * box (elementwise)

◆ operator* [4/5]

Box operator* ( const Interval interval,
const Box box 
)
friend

Elementwise multiplication with interval.

Parameters
intervalinterval to multiply
boxbox to multiply
Returns
enclosure of interval * box (elementwise)

◆ operator* [5/5]

Box operator* ( zono_float  alpha,
const Box box 
)
friend

Elementwise multiplication with scalar.

Parameters
alphascalar multiplier
boxbox to multiply
Returns
enclosure of alpha * box (elementwise)

◆ operator+

Box operator+ ( const Eigen::Vector< zono_float, -1 > &  v,
const Box box 
)
friend

Elementwise addition with vector.

Parameters
vvector to add
boxbox to add
Returns
enclosure of v + box (elementwise)

◆ operator-

Box operator- ( const Eigen::Vector< zono_float, -1 > &  v,
const Box box 
)
friend

Elementwise subtraction with vector.

Parameters
vvector
boxbox to subtract
Returns
enclosure of v - box (elementwise)

◆ operator/ [1/2]

Box operator/ ( const Interval interval,
const Box box 
)
friend

Elementwise division with interval.

Parameters
intervalinterval
boxbox to divide
Returns
enclosure of interval / box (elementwise)

◆ operator/ [2/2]

Box operator/ ( zono_float  alpha,
const Box box 
)
friend

Elementwise division with scalar.

Parameters
alphascalar divisor
boxbox to divide
Returns
enclosure of alpha / box (elementwise)

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Box box 
)
friend

print to ostream

Parameters
osostream
boxreference to box
Returns
ostream

Member Data Documentation

◆ x_lb

Eigen::Vector<zono_float, -1> ZonoOpt::Box::x_lb
protected

vector of lower bounds

◆ x_ub

Eigen::Vector<zono_float, -1> ZonoOpt::Box::x_ub
protected

vector of upper bounds


The documentation for this class was generated from the following files: