|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
This class represents a variable. More...
#include <Variable.hpp>


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... | |
| Variable & | operator= (Variable const &variable) |
| Copy assignment operator. More... | |
| Variable (Variable &&variable) | |
| Move constructor. More... | |
| Variable & | operator= (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... | |
| Var & | operator= (Var &var) |
| Copy assignment operator. More... | |
| Var (Var &&var) | |
| Move constructor. More... | |
| Var & | operator= (Var &&var) |
| Move assignment operator. More... | |
| ModelBase const *const | getModel () const |
| Get pointer to model. More... | |
Private Attributes | |
| std::shared_ptr< Data > | data |
| 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 | |
| ModelBase & | model |
| A Model to attach this to. More... | |
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.
| 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.
| model | The Model |
| name | The 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.
| model | The Model |
| name | The name |
Definition at line 33 of file Variable.cc.
| Variable::Variable | ( | Variable const & | variable | ) |
Copy constructor.
| variable | The variable to be moved |
Definition at line 135 of file Variable.cc.
|
inline |
Move constructor.
| variable | The variable to be moved |
Definition at line 114 of file Variable.hpp.
| 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 |
Get name of variable.
Definition at line 49 of file Variable.cc.
References data.
Referenced by ipo::Objective::addVariable(), ipo::LinearConstraint::getCoefficient(), ipo::Objective::removeVariable(), ipo::LinearConstraint::setCoefficient(), ipo::detail::PhaseIModel::setIndices(), and summary().
| 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().
Copy assignment operator.
| variable | The variable to be copied |
*this Definition at line 128 of file Variable.cc.
References data, IPOE, and ipo::detail::Var::model.
Move assignment operator.
| variable | The variable to be moved |
*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.
| lowerBound | The new lower bound. |
| IPOException | if 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 | ) |
| void Variable::setName | ( | char *const | name | ) |
Set name of variable.
| name | The 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.
| upperBound | The new upper bound. |
| IPOException | if 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.
| value | The new value. |
| IPOException | if 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().
|
overridevirtual |
Create a summary of this variable.
| ostream | The stream to print to. |
| prefix | This 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.
|
private |
The Variable data as a shared pointer.
Definition at line 154 of file Variable.hpp.
Referenced by getLowerBound(), getName(), getUpperBound(), getValue(), ipo::operator<(), operator=(), ipo::operator==(), setLowerBound(), setName(), setUpperBound(), and setValue().