|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
Class for an objective function. More...
#include <Objective.hpp>


Classes | |
| struct | Data |
| Struct to contain Constraint data. More... | |
Public Member Functions | |
| Objective (detail::ModelBase &model, detail::SharedFunctionPtr function, std::string const &name) | |
| Use this constructor to construct from a SharedFunctionPtr object. More... | |
| Objective (detail::ModelBase &model, ipo_function::Function *function, std::string const &name) | |
| Use this constructor to construct from a pointer to a ipo_function::Function object. More... | |
| Objective (detail::ModelBase &model, ipo_function::Function &function, std::string const &name) | |
| Use this constructor to construct from a ipo_function::Function object by reference. More... | |
| Objective (detail::ModelBase &model, detail::SharedFunctionPtr function, char const *const name=0) | |
| Use this constructor to construct from a SharedFunctionPtr object. More... | |
| Objective (detail::ModelBase &model, ipo_function::Function *function, char const *const name=0) | |
| Use this constructor to construct from a pointer to a ipo_function::Function object. More... | |
| Objective (detail::ModelBase &model, ipo_function::Function &function, char const *const name=0) | |
| Constructor. More... | |
| Objective (Objective const &objective) | |
| Copy constructor. More... | |
| Objective (Objective &&objective) | |
| Move constructor. More... | |
| Objective & | operator= (Objective const &objective) |
| Assignment operator. More... | |
| Objective & | operator= (Objective &&objective) |
| Assignment operator. More... | |
| std::string | getName () const |
| Get name of variable. More... | |
| void | setName (std::string const &name) |
| Set name of Objective. More... | |
| void | setName (char *const name) |
| Set name of Objective. More... | |
| Array & | getVariables () |
| Get variables used by Objective function. More... | |
| void | addVariable (Variable &variable) |
| Add a Variable. More... | |
| void | removeVariable (Variable &variable) |
| Remove (first, and usually only occurrence of) a Variable. More... | |
| void | addArray (Array &array) |
| Add an Array. More... | |
| void | removeArray (Array &array) |
| Remove an Array. More... | |
| virtual void | summary (std::ostream &ostream=std::cout, std::string const &prefix="") const override |
| Create a summary of this function. 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... | |
Public Member Functions inherited from ipo::detail::ModelFunction | |
| ModelFunction (SharedFunctionPtr function) | |
| Use this constructor to construct from a SharedFunctionPtr object. More... | |
| ModelFunction (ipo_function::Function *function) | |
| Use this constructor to construct from a pointer to a ipo_function::Function object. More... | |
| ModelFunction (ipo_function::Function &function) | |
| Use this constructor to construct from a ipo_function::Function object by reference. More... | |
| bool | checkSize () const |
| Check size of vector for function arguments matches number of variables supplied. More... | |
| std::tuple< size_t, size_t > | getSizes () const |
| Get size of vector for function arguments and number of variables supplied. More... | |
| virtual ::ipo_function::Function * | getFunction () |
| Get function. More... | |
Protected Member Functions | |
| double | value () const noexcept |
| Value of the objective function at the current value of the variables. More... | |
Protected Attributes | |
| std::shared_ptr< Data > | data |
| The objective data. More... | |
Protected Attributes inherited from ipo::detail::Var | |
| ModelBase & | model |
| A Model to attach this to. More... | |
Protected Attributes inherited from ipo::detail::ModelFunction | |
| SharedFunctionPtr | function |
| The objective or constraint function. More... | |
Class for an objective function.
The function should be set from an object of a subclass of ipo_function::Function. Use getVariables() = ... to specify an Array or Variable for the objective function to use. Note that setting getVariables also implicitly determines the size of the vector to be passed to function, but this class does not check the sizes of variables and function arguments match. Note also that if function is destructed before an Objective object that uses it, the behaviour of the Objective object is undefined.
Definition at line 37 of file Objective.hpp.
| Objective::Objective | ( | detail::ModelBase & | model, |
| detail::SharedFunctionPtr | function, | ||
| std::string const & | name | ||
| ) |
Use this constructor to construct from a SharedFunctionPtr object.
| model | A Model |
| function | A SharedFunctionPtr object |
| name | A name for this object |
Definition at line 28 of file Objective.cc.
| Objective::Objective | ( | detail::ModelBase & | model, |
| ipo_function::Function * | function, | ||
| std::string const & | name | ||
| ) |
Use this constructor to construct from a pointer to a ipo_function::Function object.
The Function object should be constructed using new and should not be deleted explicitly.
| model | A Model |
| function | A pointer to an object of a subclass of ipo_function::Function |
| name | A name for this object |
Definition at line 39 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | detail::ModelBase & | model, |
| ipo_function::Function & | function, | ||
| std::string const & | name | ||
| ) |
Use this constructor to construct from a ipo_function::Function object by reference.
The Function object must remain in scope for the Objective object to be useable.
| model | A Model |
| function | An object of a subclass of ipo_function::Function |
| name | A name for this object |
Definition at line 43 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | detail::ModelBase & | model, |
| detail::SharedFunctionPtr | function, | ||
| char const *const | name = 0 |
||
| ) |
Use this constructor to construct from a SharedFunctionPtr object.
| model | A Model |
| function | A SharedFunctionPtr object |
| name | A name for this object |
Definition at line 47 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | detail::ModelBase & | model, |
| ipo_function::Function * | function, | ||
| char const *const | name = 0 |
||
| ) |
Use this constructor to construct from a pointer to a ipo_function::Function object.
The Function object should be constructed using new and should not be deleted explicitly.
| model | A Model |
| function | A pointer to an object of a subclass of ipo_function::Function |
| name | A name for this object |
Definition at line 51 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | detail::ModelBase & | model, |
| ipo_function::Function & | function, | ||
| char const *const | name = 0 |
||
| ) |
Constructor.
| model | A Model |
| function | An object of a subclass of ipo_function::Function |
| name | A name for this object |
Definition at line 55 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | Objective const & | objective | ) |
Copy constructor.
| objective | The Objective to copy |
Definition at line 80 of file Objective.cc.
References ipo::detail::Var::model.
| Objective::Objective | ( | Objective && | objective | ) |
Move constructor.
| objective | The Objective to move |
Definition at line 87 of file Objective.cc.
References ipo::detail::Var::model.
| void Objective::addArray | ( | Array & | array | ) |
Add an Array.
It should contain no Variable already added.
| array | The Array |
| IPOException | if array is not in Model or any Variable is already added. |
Definition at line 146 of file Objective.cc.
References ipo::detail::Var::getModel(), getName(), ipo::Array::getName(), getVariables(), IPOE, ipo::Array::push_back(), and RETHROW.
|
virtual |
Add a Variable.
If you really need to add a Variable more than once, use getVariables().push_back( variable ).
| variable | The Variable to add |
| IPOException | if Variable is not in Model or variable already added. |
Reimplemented from ipo::detail::ModelFunction.
Definition at line 113 of file Objective.cc.
References ipo::Variable::getName(), getName(), getVariables(), IPOE, and RETHROW.
| std::string Objective::getName | ( | ) | const |
Get name of variable.
Definition at line 60 of file Objective.cc.
References data.
Referenced by addArray(), addVariable(), removeArray(), removeVariable(), ipo::Constraint::summary(), summary(), and ipo::Model::testSizes().
|
virtual |
Get variables used by Objective function.
Implements ipo::detail::ModelFunction.
Definition at line 75 of file Objective.cc.
References data, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
Referenced by addArray(), addVariable(), ipo::LinearConstraint::getCoefficient(), ipo::LinearConstraint::getCoefficients(), ipo::LinearConstraint::getFunction(), removeArray(), removeVariable(), ipo::LinearConstraint::setCoefficient(), ipo::LinearConstraint::setCoefficients(), ipo::Model::setConstraintIndices(), ipo::detail::PhaseIModel::setIndices(), ipo::Model::setIndices(), ipo::Model::setObjectiveIndices(), and value().
Assignment operator.
| objective | The Objective to copy |
Definition at line 94 of file Objective.cc.
References data, ipo::detail::ModelFunction::function, ipo::detail::Var::model, and ipo::detail::ModelBase::notify().
Assignment operator.
| objective | The Objective to move |
Definition at line 103 of file Objective.cc.
References data, and ipo::detail::Var::model.
| void Objective::removeArray | ( | Array & | array | ) |
Remove an Array.
It should contain no Variable not already added.
| array | The Array |
| IPOException | if any Variable is not already added. |
Definition at line 171 of file Objective.cc.
References ipo::Array::erase(), ipo::detail::Var::getModel(), getName(), ipo::Array::getName(), getVariables(), IPOE, and RETHROW.
| void Objective::removeVariable | ( | Variable & | variable | ) |
Remove (first, and usually only occurrence of) a Variable.
| variable | The Variable to remove |
| IPOException | if Variable is not in this |
Definition at line 129 of file Objective.cc.
References ipo::Variable::getName(), getName(), getVariables(), IPOE, and RETHROW.
| void Objective::setName | ( | std::string const & | name | ) |
| void Objective::setName | ( | char *const | name | ) |
|
overridevirtual |
Create a summary of this function.
This should be a description of the objective function and its variables.
| 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.
Reimplemented in ipo::Constraint.
Definition at line 198 of file Objective.cc.
References getName(), and value().
Referenced by ipo::Model::summary().
|
protectednoexcept |
Value of the objective function at the current value of the variables.
Definition at line 209 of file Objective.cc.
References getVariables(), and ipo::Array::size().
Referenced by ipo::LinearConstraint::setCoefficient(), ipo::LinearConstraint::setValue(), ipo::Constraint::summary(), and summary().
|
protected |
The objective data.
Definition at line 205 of file Objective.hpp.
Referenced by ipo::Constraint::getLowerBound(), getName(), ipo::Constraint::getUpperBound(), getVariables(), operator=(), ipo::Constraint::operator=(), ipo::operator==(), ipo::LinearConstraint::setLowerBound(), ipo::Constraint::setLowerBound(), setName(), ipo::LinearConstraint::setUpperBound(), ipo::Constraint::setUpperBound(), and ipo::LinearConstraint::setValue().