dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
dlinear::Box Class Reference

Collection of variables with associated intervals. More...

#include <Box.h>

Public Member Functions

 Box (Config::LPSolver lp_solver)
 Construct a new Box object associated with the given lp_solver.
 
 Box (const std::vector< Variable > &variables, Config::LPSolver lp_solver)
 Construct a box from variables associated with the given lp_solver.
 
void Add (const Variable &v)
 Add the variable v to the box.
 
void Add (const Variable &v, const mpq_class &lb, const mpq_class &ub)
 Add the variable v to the box and sets its domain using lb and ub.
 
bool empty () const
 Check whether the box is empty.
 
void set_empty ()
 Clear the box, making it empty.
 
int size () const
 Get read-only access to the number of variables of the box.
 
Intervaloperator[] (int i)
 Return the interval at index i.
 
Intervaloperator[] (const Variable &var)
 Return the interval associated with var.
 
const Intervaloperator[] (int i) const
 Return the interval at index i.
 
const Intervaloperator[] (const Variable &var) const
 Return the interval associated with var.
 
Config::LPSolver lp_solver () const
 Get read-only access to the lp_solver of the box.
 
const std::vector< Variable > & variables () const
 Get read-only access to the variables of the box.
 
const Variablevariable (int i) const
 Return the i -th variable in the box.
 
bool has_variable (const Variable &var) const
 Checks if this box contains var.
 
const std::vector< Interval > & interval_vector () const
 Return the interval vector of the box.
 
std::vector< Interval > & m_interval_vector ()
 Return the interval vector of the box.
 
int index (const Variable &var) const
 Return the index associated with var.
 
std::pair< mpq_class, int > MaxDiam () const
 Return the max diameter of the box and the associated index.
 
std::pair< Box, BoxBisect (int i) const
 Bisect the box at i -th dimension.
 
std::pair< Box, BoxBisect (const Variable &var) const
 Bisect the box at var.
 

Private Member Functions

std::pair< Box, BoxBisectInt (int i) const
 Bisects the box at i -th dimension.
 
std::pair< Box, BoxBisectContinuous (int i) const
 Bisects the box at i -th dimension.
 

Private Attributes

Config::LPSolver lp_solver_
 LP solver.
 
std::vector< Intervalvalues_
 Interval vector of the box.
 
std::shared_ptr< std::vector< Variable > > variables_
 Variables in the box.
 
std::shared_ptr< std::unordered_map< Variable, int > > var_to_idx_
 Variable to index map.
 
std::shared_ptr< std::unordered_map< int, Variable > > idx_to_var_
 Index to variable map.
 

Detailed Description

Collection of variables with associated intervals.

The Box class is used throughout the tool to keep track of the variables that will eventually populate the model. When a model is produced, the bounds on each variable will match a single value.

Definition at line 31 of file Box.h.

Constructor & Destructor Documentation

◆ Box() [1/2]

dlinear::Box::Box ( Config::LPSolver lp_solver)
explicit

Construct a new Box object associated with the given lp_solver.

Parameters
lp_solverLP solver to use. It will determine the values for the unbounded intervals

Definition at line 26 of file Box.cpp.

◆ Box() [2/2]

dlinear::Box::Box ( const std::vector< Variable > & variables,
Config::LPSolver lp_solver )
explicit

Construct a box from variables associated with the given lp_solver.

Parameters
variablesvariables contained in the box
lp_solverLP solver to use. It will determine the values for the unbounded intervals

Definition at line 33 of file Box.cpp.

Member Function Documentation

◆ Add() [1/2]

void dlinear::Box::Add ( const Variable & v)

Add the variable v to the box.

Parameters
vvariable to add

Definition at line 39 of file Box.cpp.

◆ Add() [2/2]

void dlinear::Box::Add ( const Variable & v,
const mpq_class & lb,
const mpq_class & ub )

Add the variable v to the box and sets its domain using lb and ub.

Parameters
vvariable to add
lblower bound
ubupper bound

Definition at line 78 of file Box.cpp.

◆ Bisect() [1/2]

std::pair< Box, Box > dlinear::Box::Bisect ( const Variable & var) const
nodiscard

Bisect the box at var.

Parameters
varvariable to Bisect
Returns
pair of boxes resulting from the bisection
Exceptions
std::runtimeif var is not bisectable

Definition at line 154 of file Box.cpp.

◆ Bisect() [2/2]

std::pair< Box, Box > dlinear::Box::Bisect ( int i) const
nodiscard

Bisect the box at i -th dimension.

Parameters
idimension to Bisect
Returns
pair of boxes resulting from the bisection
Exceptions
std::runtimeif i -th dimension is not bisectable

Definition at line 137 of file Box.cpp.

◆ BisectContinuous()

std::pair< Box, Box > dlinear::Box::BisectContinuous ( int i) const
nodiscardprivate

Bisects the box at i -th dimension.

Precondition
i-th variable is bisectable.
i-th variable is of continuous type.
Parameters
iindex of the dimension to Bisect
Returns
pair of boxes resulting from the bisection

Definition at line 185 of file Box.cpp.

◆ BisectInt()

std::pair< Box, Box > dlinear::Box::BisectInt ( int i) const
nodiscardprivate

Bisects the box at i -th dimension.

Precondition
i-th variable is bisectable.
i-th variable is of integer type.
Parameters
iindex of the dimension to Bisect
Returns
pair of boxes resulting from the bisection

Definition at line 164 of file Box.cpp.

◆ empty()

bool dlinear::Box::empty ( ) const
nodiscard

Check whether the box is empty.

Returns
true if the box is empty
false if the box is not empty
See also
set_empty

Definition at line 94 of file Box.cpp.

◆ has_variable()

bool dlinear::Box::has_variable ( const Variable & var) const
nodiscard

Checks if this box contains var.

Parameters
varvariable to check the presence of
Returns
true if the box contains var
false if the box does not contain var

Definition at line 117 of file Box.cpp.

◆ index()

int dlinear::Box::index ( const Variable & var) const
nodiscard

Return the index associated with var.

Parameters
varvariable to get the index from
Returns
index associated with var

Definition at line 119 of file Box.cpp.

◆ interval_vector()

const std::vector< Interval > & dlinear::Box::interval_vector ( ) const
nodiscard

Return the interval vector of the box.

Returns
interval vector of the box

Definition at line 121 of file Box.cpp.

◆ lp_solver()

Config::LPSolver dlinear::Box::lp_solver ( ) const
inlinenodiscard

Get read-only access to the lp_solver of the box.

Returns
lp_solver of the box

Definition at line 104 of file Box.h.

◆ m_interval_vector()

std::vector< Interval > & dlinear::Box::m_interval_vector ( )

Return the interval vector of the box.

Returns
interval vector of the box

Definition at line 122 of file Box.cpp.

◆ MaxDiam()

std::pair< mpq_class, int > dlinear::Box::MaxDiam ( ) const
nodiscard

Return the max diameter of the box and the associated index.

Returns
max diameter of the box and the associated index

Definition at line 124 of file Box.cpp.

◆ operator[]() [1/4]

Interval & dlinear::Box::operator[] ( const Variable & var)

Return the interval associated with var.

Parameters
varvariable to get the interval from
Returns
interval associated with var

Definition at line 106 of file Box.cpp.

◆ operator[]() [2/4]

const Interval & dlinear::Box::operator[] ( const Variable & var) const

Return the interval associated with var.

Parameters
varvariable to get the interval from
Returns
interval associated with var

Definition at line 111 of file Box.cpp.

◆ operator[]() [3/4]

Interval & dlinear::Box::operator[] ( int i)

Return the interval at index i.

Parameters
iindex of the interval
Returns
interval at index i

Definition at line 102 of file Box.cpp.

◆ operator[]() [4/4]

const Interval & dlinear::Box::operator[] ( int i) const

Return the interval at index i.

Parameters
iindex of the interval
Returns
interval at index i

Definition at line 107 of file Box.cpp.

◆ set_empty()

void dlinear::Box::set_empty ( )

Clear the box, making it empty.

See also
empty

Definition at line 96 of file Box.cpp.

◆ size()

int dlinear::Box::size ( ) const
nodiscard

Get read-only access to the number of variables of the box.

Returns
number of variables of the box

Definition at line 100 of file Box.cpp.

◆ variable()

const Variable & dlinear::Box::variable ( int i) const
nodiscard

Return the i -th variable in the box.

Parameters
iindex of the variable
Returns
variable at index i

Definition at line 115 of file Box.cpp.

◆ variables()

const std::vector< Variable > & dlinear::Box::variables ( ) const
nodiscard

Get read-only access to the variables of the box.

Returns
variables of the box

Definition at line 113 of file Box.cpp.


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