MAiNGO
babBase::OptimizationVariable Class Reference

Class for representing an optimization variable specified by the user. More...

#include <babOptVar.h>

Public Member Functions

 OptimizationVariable (const Bounds &variableBoundsIn, const enums::VT variableType, const unsigned branchingPriority, const std::string nameIn)
 Constructor for the case all three optional parameters are used. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const enums::VT variableType, const unsigned branchingPriority)
 Constructor for the case only a variable type and a branching priority is specified in addition to the bounds. The variable name is empty. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const enums::VT variableType, const std::string nameIn)
 Constructor for the case only a variable type and a name is specified in addition to the bounds. The variable is used for branching. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const unsigned branchingPriority, const std::string nameIn)
 Constructor for the case only a branching priority and a name is specified in addition to the bounds. The variable is assumed to be continuous. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const enums::VT variableType)
 Constructor for the case only a variable type is specified in addition to the bounds. The variable is used for branching, and the name is empty. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const unsigned branchingPriority)
 Constructor for the case only a branching priority is specified in addition to the bounds. The variable is thus assumed to be continuous, and the name is empty. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn, const std::string nameIn)
 Constructor for the case only a name is specified in addition to the bounds. The variable is thus assumed to be continuous, and it is used for branching. More...
 
 OptimizationVariable (const Bounds &variableBoundsIn)
 Minimal constructor requiring only the required information. The variable is thus assumed to be continuous, it is used for branching, and the name is empty. More...
 
 OptimizationVariable (const enums::VT variableType, const unsigned branchingPriority, const std::string nameIn)
 Constructor for the case only a variable type, branching priority and a variable name are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable. More...
 
 OptimizationVariable (const enums::VT variableType, const unsigned branchingPriority)
 Constructor for the case only a variable type and branching priority are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable. More...
 
 OptimizationVariable (const enums::VT variableType, const std::string nameIn)
 Constructor for the case only a variable type and a variable name are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable. More...
 
 OptimizationVariable (const enums::VT variableType)
 Constructor for the case only a variable type is specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable. More...
 
 OptimizationVariable (const unsigned branchingPriority, const std::string nameIn)
 Constructor for the case only branching priority and a variable name arespecified. The variable bounds are not defined. This function currently just throws an exception. More...
 
 OptimizationVariable (const unsigned branchingPriority)
 Constructor for the case only a branching priority is specified. The variable bounds are not defined. This function currently just throws an exception. More...
 
 OptimizationVariable (const std::string nameIn)
 Constructor for the case only a variable name is specified. The variable bounds are not defined. This function currently just throws an exception. More...
 
 OptimizationVariable ()
 Default constructor The variable bounds are not defined. This function currently just throws an exception. More...
 
double get_lower_bound () const
 Function for querying the lower variable bound. More...
 
double get_upper_bound () const
 Function for querying the upper variable bound. More...
 
double get_user_lower_bound () const
 Function for querying the lower variable bound as originally specified by the user. More...
 
double get_user_upper_bound () const
 Function for querying the upper variable bound as originally specified by the user. More...
 
double get_mid () const
 Function for querying the midpoint of the variable range. More...
 
std::string get_name () const
 Function for querying the variable name. More...
 
enums::VT get_variable_type () const
 Function for querying the variable type. More...
 
unsigned get_branching_priority () const
 Function for querying the branching priority. More...
 
bool has_nonempty_host_set () const
 Function for querying whether the host set of the variable is non-empty. More...
 
bool bounds_changed_from_user_input () const
 Function for querying whether the bounds have been modified (e.g., by rounding to integer values) compared to those specified by the user. More...
 

Private Member Functions

void _round_and_check_discrete_bounds ()
 sanity check of user-given bounds on discrete variables More...
 
void _infer_and_set_bounds_or_throw ()
 Auxiliary function for determining bounds in case the user did not specify any. More...
 

Private Attributes

Internal variables for storing information on the OptimizationVariable
Bounds _bounds
 
const Bounds _userSpecifiedBounds
 
const enums::VT _variableType
 
const unsigned _branchingPriority
 
const std::string _name
 
bool _feasible
 

Friends

std::ostream & operator<< (std::ostream &os, const OptimizationVariable &ov)
 operator << overloaded for Bounds for easier output More...
 

Detailed Description

Class for representing an optimization variable specified by the user.

An optimization variable is characterized by an upper and lower bound, a variable type (enums::VT, optional), a branching priority (BP, optional), and a name (optional), all of which are private members. Once instantiated, it cannot be modified. Each optimization variable also contains a flag (_feasible) that indicates if the bounds are consistent (lower bound <= upper bound) and in case of integer variables, whether the interval contains an integer value

Constructor & Destructor Documentation

◆ OptimizationVariable() [1/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const enums::VT  variableType,
const unsigned  branchingPriority,
const std::string  nameIn 
)
inline

Constructor for the case all three optional parameters are used.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]variableTypeis the Variable Type of this variable
[in]branchingPriorityis the Branching Priority of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [2/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const enums::VT  variableType,
const unsigned  branchingPriority 
)
inline

Constructor for the case only a variable type and a branching priority is specified in addition to the bounds. The variable name is empty.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]variableTypeis the Variable Type of this variable
[in]branchingPriorityis the Branching Priority of this variable

◆ OptimizationVariable() [3/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const enums::VT  variableType,
const std::string  nameIn 
)
inline

Constructor for the case only a variable type and a name is specified in addition to the bounds. The variable is used for branching.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]variableTypeis the Variable Type of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [4/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const unsigned  branchingPriority,
const std::string  nameIn 
)
inline

Constructor for the case only a branching priority and a name is specified in addition to the bounds. The variable is assumed to be continuous.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]branchingPriorityis the Branching Priority of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [5/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const enums::VT  variableType 
)
inline

Constructor for the case only a variable type is specified in addition to the bounds. The variable is used for branching, and the name is empty.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]variableTypeis the Variable Type of this variable

◆ OptimizationVariable() [6/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const unsigned  branchingPriority 
)
inline

Constructor for the case only a branching priority is specified in addition to the bounds. The variable is thus assumed to be continuous, and the name is empty.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]branchingPriorityis the Branching Priority of this variable

◆ OptimizationVariable() [7/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn,
const std::string  nameIn 
)
inline

Constructor for the case only a name is specified in addition to the bounds. The variable is thus assumed to be continuous, and it is used for branching.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [8/16]

babBase::OptimizationVariable::OptimizationVariable ( const Bounds variableBoundsIn)
inline

Minimal constructor requiring only the required information. The variable is thus assumed to be continuous, it is used for branching, and the name is empty.

Parameters
[in]variableBoundsInis the Bounds object representing lower and upper bounds on the optimization variable

◆ OptimizationVariable() [9/16]

babBase::OptimizationVariable::OptimizationVariable ( const enums::VT  variableType,
const unsigned  branchingPriority,
const std::string  nameIn 
)
inline

Constructor for the case only a variable type, branching priority and a variable name are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable.

Parameters
[in]variableTypeis the Variable Type of this variable
[in]branchingPriorityis the Branching Priority of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [10/16]

babBase::OptimizationVariable::OptimizationVariable ( const enums::VT  variableType,
const unsigned  branchingPriority 
)
inline

Constructor for the case only a variable type and branching priority are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable.

Parameters
[in]variableTypeis the Variable Type of this variable
[in]branchingPriorityis the Branching Priority of this variable

◆ OptimizationVariable() [11/16]

babBase::OptimizationVariable::OptimizationVariable ( const enums::VT  variableType,
const std::string  nameIn 
)
inline

Constructor for the case only a variable type and a variable name are specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable.

Parameters
[in]variableTypeis the Variable Type of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [12/16]

babBase::OptimizationVariable::OptimizationVariable ( const enums::VT  variableType)
inline

Constructor for the case only a variable type is specified. The variable bounds are not defined. This function currently just throws an exception, except in case of a binary variable.

Parameters
[in]variableTypeis the Variable Type of this variable

◆ OptimizationVariable() [13/16]

OptimizationVariable::OptimizationVariable ( const unsigned  branchingPriority,
const std::string  nameIn 
)

Constructor for the case only branching priority and a variable name arespecified. The variable bounds are not defined. This function currently just throws an exception.

Parameters
[in]branchingPriorityis the Branching Priority of this variable
[in]nameInis the name of this variable

◆ OptimizationVariable() [14/16]

OptimizationVariable::OptimizationVariable ( const unsigned  branchingPriority)

Constructor for the case only a branching priority is specified. The variable bounds are not defined. This function currently just throws an exception.

Parameters
[in]branchingPriorityis the Branching Priority of this variable

◆ OptimizationVariable() [15/16]

OptimizationVariable::OptimizationVariable ( const std::string  nameIn)

Constructor for the case only a variable name is specified. The variable bounds are not defined. This function currently just throws an exception.

Parameters
[in]nameInis the name of this variable

◆ OptimizationVariable() [16/16]

OptimizationVariable::OptimizationVariable ( )

Default constructor The variable bounds are not defined. This function currently just throws an exception.

Member Function Documentation

◆ _infer_and_set_bounds_or_throw()

void OptimizationVariable::_infer_and_set_bounds_or_throw ( )
private

Auxiliary function for determining bounds in case the user did not specify any.

Attemps to infer bounds from other information (e.g., variable type). If this is possible, the inferred bounds are stored in the corresponding member variables. If not, an exception is thrown.

◆ _round_and_check_discrete_bounds()

void OptimizationVariable::_round_and_check_discrete_bounds ( )
private

sanity check of user-given bounds on discrete variables

Rounds non-discrete bounds to discrete values and updates the private member _feasible depending on whether discrete ub < discrete lb.

◆ bounds_changed_from_user_input()

bool babBase::OptimizationVariable::bounds_changed_from_user_input ( ) const
inline

Function for querying whether the bounds have been modified (e.g., by rounding to integer values) compared to those specified by the user.

◆ get_branching_priority()

unsigned babBase::OptimizationVariable::get_branching_priority ( ) const
inline

Function for querying the branching priority.

◆ get_lower_bound()

double babBase::OptimizationVariable::get_lower_bound ( ) const
inline

Function for querying the lower variable bound.

◆ get_mid()

double babBase::OptimizationVariable::get_mid ( ) const
inline

Function for querying the midpoint of the variable range.

◆ get_name()

std::string babBase::OptimizationVariable::get_name ( ) const
inline

Function for querying the variable name.

◆ get_upper_bound()

double babBase::OptimizationVariable::get_upper_bound ( ) const
inline

Function for querying the upper variable bound.

◆ get_user_lower_bound()

double babBase::OptimizationVariable::get_user_lower_bound ( ) const
inline

Function for querying the lower variable bound as originally specified by the user.

◆ get_user_upper_bound()

double babBase::OptimizationVariable::get_user_upper_bound ( ) const
inline

Function for querying the upper variable bound as originally specified by the user.

◆ get_variable_type()

enums::VT babBase::OptimizationVariable::get_variable_type ( ) const
inline

Function for querying the variable type.

◆ has_nonempty_host_set()

bool babBase::OptimizationVariable::has_nonempty_host_set ( ) const
inline

Function for querying whether the host set of the variable is non-empty.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const OptimizationVariable ov 
)
friend

operator << overloaded for Bounds for easier output

Parameters
[out]osis the outstream to be written to
[in]ovis an optimization variable to be written

Member Data Documentation

◆ _bounds

Bounds babBase::OptimizationVariable::_bounds
private

bounds on the optimization variable (potentially altered from the user-specified through rounding in case of discrete variables)

◆ _branchingPriority

const unsigned babBase::OptimizationVariable::_branchingPriority
private

optional: whether this variable should be branched on (default: 1)

◆ _feasible

bool babBase::OptimizationVariable::_feasible
private

flag indicating whether the variable has a non-empty host set (upper bound >= lower bound; contains integer/binary values where approriate)

◆ _name

const std::string babBase::OptimizationVariable::_name
private

optional: name of the variable

◆ _userSpecifiedBounds

const Bounds babBase::OptimizationVariable::_userSpecifiedBounds
private

bounds on the optimization variable as specified by the user (i.e., before potential rounding in case of discrete variables)

◆ _variableType

const enums::VT babBase::OptimizationVariable::_variableType
private

optional: type of variable (default: enums::VT_CONTINUOUS)


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