Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
ipo::Variable Class Reference

This class represents a variable. More...

#include <Variable.hpp>

Inheritance diagram for ipo::Variable:
Inheritance graph
Collaboration diagram for ipo::Variable:
Collaboration graph

Classes

struct  Data
 Struct to contain Variable data. More...
 

Public Member Functions

 Variable (detail::ModelBase &model, char const *const name=nullptr)
 Default constructor creates a named variable with the given name, initial value 0 and unbounded. More...
 
 Variable (detail::ModelBase &model, std::string const &name)
 Constructor creates a named variable with the given name, initial value 0 and unbounded. More...
 
double getValue () const
 Get value of variable. More...
 
std::string getName () const
 Get name of variable. More...
 
void setName (std::string const &name)
 Set name of variable. More...
 
void setName (char *const name)
 Set name of variable. More...
 
double getUpperBound () const
 Get upper bound of variable. More...
 
double getLowerBound () const
 Get lower bound of variable. More...
 
void setValue (double const value)
 Set value of variable. More...
 
void setUpperBound (double const upperBound)
 Set upper bound of variable. More...
 
void setLowerBound (double const lowerBound)
 Set lower bound of variable. More...
 
 Variable (Variable const &variable)
 Copy constructor. More...
 
Variableoperator= (Variable const &variable)
 Copy assignment operator. More...
 
 Variable (Variable &&variable)
 Move constructor. More...
 
Variableoperator= (Variable &&variable)
 Move assignment operator. More...
 
virtual void summary (std::ostream &ostream=std::cout, std::string const &prefix="") const override
 Create a summary of this variable. More...
 
- Public Member Functions inherited from ipo::detail::Var
 Var (ModelBase &model)
 Constructor needs a model so that variable can only be attached to one model. More...
 
virtual ~Var ()=0
 Virtual destructor to make class abstract. More...
 
 Var (Var &var)
 Copy constructor. More...
 
Varoperator= (Var &var)
 Copy assignment operator. More...
 
 Var (Var &&var)
 Move constructor. More...
 
Varoperator= (Var &&var)
 Move assignment operator. More...
 
ModelBase const *const getModel () const
 Get pointer to model. More...
 

Private Attributes

std::shared_ptr< Datadata
 The Variable data as a shared pointer. More...
 

Friends

bool ipo::operator== (Variable const &, Variable const &)
 
bool ipo::operator< (Variable const &, Variable const &)
 

Additional Inherited Members

- Protected Attributes inherited from ipo::detail::Var
ModelBasemodel
 A Model to attach this to. More...
 

Detailed Description

This class represents a variable.

A variable has optionally a name and bounds. A Variable contains a shared pointer to its data so that it is safe and inexpensive to copy Variable objects, put them in arrays, pass them as function values, and the like.

Definition at line 36 of file Variable.hpp.

Constructor & Destructor Documentation

Variable::Variable ( detail::ModelBase model,
char const *const  name = nullptr 
)

Default constructor creates a named variable with the given name, initial value 0 and unbounded.

Parameters
modelThe Model
nameThe name

Definition at line 28 of file Variable.cc.

References ipo::detail::Var::model.

Variable::Variable ( detail::ModelBase model,
std::string const &  name 
)

Constructor creates a named variable with the given name, initial value 0 and unbounded.

Parameters
modelThe Model
nameThe name

Definition at line 33 of file Variable.cc.

Variable::Variable ( Variable const &  variable)

Copy constructor.

Parameters
variableThe variable to be moved

Definition at line 135 of file Variable.cc.

ipo::Variable::Variable ( Variable &&  variable)
inline

Move constructor.

Parameters
variableThe variable to be moved

Definition at line 114 of file Variable.hpp.

Member Function Documentation

double Variable::getLowerBound ( ) const

Get lower bound of variable.

Definition at line 59 of file Variable.cc.

References data.

Referenced by setUpperBound(), setValue(), and summary().

std::string Variable::getName ( ) const
double Variable::getUpperBound ( ) const

Get upper bound of variable.

Definition at line 54 of file Variable.cc.

References data.

Referenced by setLowerBound(), setValue(), and summary().

double Variable::getValue ( ) const

Get value of variable.

Definition at line 44 of file Variable.cc.

References data.

Referenced by ipo::Model::isFeasible(), ipo::Model::isStrictlyFeasible(), setLowerBound(), setUpperBound(), and summary().

Variable & Variable::operator= ( Variable const &  variable)

Copy assignment operator.

Parameters
variableThe variable to be copied
Returns
*this

Definition at line 128 of file Variable.cc.

References data, IPOE, and ipo::detail::Var::model.

Variable & Variable::operator= ( Variable &&  variable)

Move assignment operator.

Parameters
variableThe variable to be moved
Returns
*this

Definition at line 141 of file Variable.cc.

References data, IPOE, and ipo::detail::Var::model.

void Variable::setLowerBound ( double const  lowerBound)

Set lower bound of variable.

This may invalidate value set if the value is less than the lower bound.

Parameters
lowerBoundThe new lower bound.
Exceptions
IPOExceptionif new lower bound exceeds upper bound

Definition at line 105 of file Variable.cc.

References data, getUpperBound(), getValue(), IPOE, and lowerBound.

void Variable::setName ( std::string const &  name)

Set name of variable.

Parameters
nameThe new name.

Definition at line 82 of file Variable.cc.

References data, and name.

void Variable::setName ( char *const  name)

Set name of variable.

Parameters
nameThe new name.

Definition at line 87 of file Variable.cc.

References data.

void Variable::setUpperBound ( double const  upperBound)

Set upper bound of variable.

This may invalidate value set if the value is not less than the upper bound.

Parameters
upperBoundThe new upper bound.
Exceptions
IPOExceptionif lower bound exceeds new upper bound

Definition at line 92 of file Variable.cc.

References data, getLowerBound(), getValue(), IPOE, and upperBound.

void Variable::setValue ( double const  value)

Set value of variable.

Parameters
valueThe new value.
Exceptions
IPOExceptionif value is not between bounds.

Definition at line 64 of file Variable.cc.

References data, getLowerBound(), getUpperBound(), and IPOE.

Referenced by ipo::detail::PhaseIModel::findEqualityConstraintFeasibleSolution().

void Variable::summary ( std::ostream &  ostream = std::cout,
std::string const &  prefix = "" 
) const
overridevirtual

Create a summary of this variable.

Parameters
ostreamThe stream to print to.
prefixThis is put in front of every row of output, for example for indentation

Implements ipo::detail::Var.

Definition at line 149 of file Variable.cc.

References getLowerBound(), getName(), getUpperBound(), getValue(), and ipo::format::infinity.

Friends And Related Function Documentation

bool ipo::operator< ( Variable const &  ,
Variable const &   
)
friend
bool ipo::operator== ( Variable const &  ,
Variable const &   
)
friend

Member Data Documentation

std::shared_ptr<Data> ipo::Variable::data
private

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