|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
Model an interior-point optimisation problem. More...
#include <Model.hpp>


Classes | |
| class | DirectSubvector |
| This class gives direct access to a subvector of a vector. More... | |
| class | IndirectSubvector |
| This class gives direct access to a subvector of a vector. More... | |
| class | Parameters |
| class | Subvector |
| Abstract base class for subvector classes. More... | |
Public Member Functions | |
| Model () | |
| Constructor. More... | |
| virtual void | notify () |
| Notify function that model must implement. More... | |
| void | setObjective (Objective &objective) |
| Set the objective function. More... | |
| Objective | getObjective () |
| Get the objective function. More... | |
| void | addConstraint (Constraint &constraint) |
| Add a constraint. More... | |
| bool | removeConstraint (Constraint &constraint) |
| Remove a constraint. More... | |
| std::vector< Constraint > const & | getConstraints () const |
| Get list of constraints. More... | |
| std::vector< LinearConstraint > const & | getEqualityConstraints () const |
| Get list of equality constraints. More... | |
| bool | isFeasible () |
| Test whether current values of variables give a feasible solution. More... | |
| bool | isStrictlyFeasible () |
| Test whether current values of variables give a feasible solution. More... | |
| bool | minimise () |
| Try to minimise the objective function subject to the constraints. More... | |
| bool | maximise () |
| Try to maximise the objective function subject to the constraints. More... | |
| virtual bool | findFeasible () |
| Try to find a set of values for the variables that gives a feasible solution. More... | |
| Parameters & | getParameters () |
| Get parameters by reference. More... | |
| detail::NewtonDescent::Parameters & | getNewtonDescentParameters () |
| Get Newton descent parameters by reference. More... | |
| detail::LineSearch::Parameters & | getLineSearchParameters () |
| Get line search parameters by reference. More... | |
| bool | checkSize () const |
| Check objective and constraint functions. More... | |
| void | testSizes () const |
| Check objective and constraint functions. More... | |
| void | summary (std::ostream &ostream=std::cout) const |
| Create a summary of this model. More... | |
Protected Member Functions | |
| gsl::vector | getVectorFromVariables () const |
| Get a vector from values of variables. More... | |
| void | setVariablesFromVector (gsl::vector const &vector) |
| Set variable values from a vector. More... | |
| bool | stoppingCriterion (double const t) const |
| Check whether or not stopping criterion has been met. More... | |
| virtual bool | optimise (bool const minimise) |
| Try to optimise the objective function subject to the constraints. More... | |
| virtual void | setIndices () |
| Sets the values of objectiveIndices, constraintIndices and variableIndices from constraints. More... | |
| void | setObjectiveIndices () |
| Set objectiveIndices. More... | |
| void | setConstraintIndices () |
| Set constraintIndices. More... | |
Protected Attributes | |
| std::vector< Constraint > | constraints |
| The set of constraints. More... | |
| std::vector < ipo::LinearConstraint > | equalityConstraints |
| The set of equality constraints. More... | |
| Objective | objective |
| The objective function. More... | |
| std::shared_ptr< Subvector > | objectiveIndices |
| Used internally to match the variables in the objective to indices in a vector: objectiveIndices[i] is the index in a gsl::vector of the ith variable in objective.getVariables() after a call to setIndices(). More... | |
| std::vector< std::shared_ptr < Subvector > > | constraintIndices |
| Used internally to match the variables in each constraint to indices in a vector: (*constraintIndices[j])()[i] is the index in a gsl::vector of the ith variable in constraint[j]->getVariables() after a call to setIndices(). More... | |
| std::vector< std::shared_ptr < Subvector > > | equalityConstraintIndices |
| Used internally to match the variables in each equality constraint to indices in a vector: (*constraintIndices[j])()[i] is the index in a gsl::vector of the ith variable in * constraint[j]->getVariables() after a call to setIndices(). More... | |
| std::map< Variable, size_t > | indexMap |
| Used internally to match the variables in each variable to indices in a vector. More... | |
| bool | variablesChanged = false |
| Value that indicates if any variables, objective or constraints have been modified in such a way that we may have to update them. More... | |
| detail::NewtonDescent::Parameters | newtonDescentParameters |
| Parameters used by Newton descent algorithm during optimisation. More... | |
| detail::LineSearch::Parameters | lineSearchParameters |
| Parameters used by backtracking line search algorithm during optimisation. More... | |
Private Attributes | |
| Parameters | parameters |
| Parameters for interior point optimisation. More... | |
Friends | |
| class | detail::BarrierFunction |
| class | detail::PhaseIModel |
Model an interior-point optimisation problem.
The problem must have an objective function and (usually) some constraints. Initially a new instance of this class will have a null objective function and no constraints.
| void Model::addConstraint | ( | Constraint & | constraint | ) |
Add a constraint.
| constraint | The constraint |
Definition at line 48 of file Model.cc.
References constraints, and equalityConstraints.
Referenced by ipo::LinearConstraint::setLowerBound(), ipo::LinearConstraint::setUpperBound(), and ipo::LinearConstraint::setValue().
| bool Model::checkSize | ( | ) | const |
Check objective and constraint functions.
If any of these differ in the number of Variable objects assigned to them and the declared size of the function return true; otherwise return false.
If the result is false, use the chcekSize() method on the Objective object or Constraint object to identify where the problem lies.
Definition at line 343 of file Model.cc.
References ipo::detail::ModelFunction::checkSize(), constraints, and objective.
|
virtual |
Try to find a set of values for the variables that gives a feasible solution.
If the values are not already feasible this function used a Phase I model to seek a feasible solution.
Definition at line 531 of file Model.cc.
References ipo::detail::PhaseIModel::findFeasibleSolution(), and isStrictlyFeasible().
Referenced by optimise().
| std::vector< Constraint > const & Model::getConstraints | ( | ) | const |
Get list of constraints.
Definition at line 82 of file Model.cc.
References constraints.
| std::vector< LinearConstraint > const & Model::getEqualityConstraints | ( | ) | const |
Get list of equality constraints.
Definition at line 87 of file Model.cc.
References equalityConstraints.
| detail::LineSearch::Parameters & Model::getLineSearchParameters | ( | ) |
Get line search parameters by reference.
These parameters are used by backtracking line search algorithm during optimisation.
Definition at line 336 of file Model.cc.
References lineSearchParameters.
Referenced by optimise().
| detail::NewtonDescent::Parameters & Model::getNewtonDescentParameters | ( | ) |
Get Newton descent parameters by reference.
These parameters are used by Newton descent algorithm during optimisation.
Definition at line 331 of file Model.cc.
References newtonDescentParameters.
Referenced by ipo::detail::PhaseIModel::findFeasibleSolution(), and optimise().
| Objective Model::getObjective | ( | ) |
| Model::Parameters & Model::getParameters | ( | ) |
Get parameters by reference.
Definition at line 341 of file Model.cc.
References parameters.
|
protected |
Get a vector from values of variables.
Definition at line 214 of file Model.cc.
References indexMap.
Referenced by optimise().
| bool Model::isFeasible | ( | ) |
Test whether current values of variables give a feasible solution.
Definition at line 136 of file Model.cc.
References constraintIndices, constraints, equalityConstraints, ipo::Variable::getValue(), indexMap, and setIndices().
| bool Model::isStrictlyFeasible | ( | ) |
Test whether current values of variables give a feasible solution.
This function differs from isFeasible because it also checks if variables are strictly within their bounds.
Definition at line 175 of file Model.cc.
References constraintIndices, constraints, equalityConstraintIndices, equalityConstraints, ipo::Variable::getValue(), indexMap, and setIndices().
Referenced by findFeasible(), and ipo::detail::PhaseIModel::findFeasibleSolution().
|
inline |
Try to maximise the objective function subject to the constraints.
Definition at line 763 of file Model.hpp.
References optimise().
|
inline |
Try to minimise the objective function subject to the constraints.
Definition at line 758 of file Model.hpp.
References optimise().
Referenced by ipo::detail::PhaseIModel::findFeasibleSolution().
|
virtual |
Notify function that model must implement.
This function is called internally whenever a variable is changed.
Implements ipo::detail::ModelBase.
Definition at line 130 of file Model.cc.
References variablesChanged.
|
protectedvirtual |
Try to optimise the objective function subject to the constraints.
| minimise | Set to true for minimisation, false for maximisation |
DEBUG
DEBUG
Definition at line 247 of file Model.cc.
References equalityConstraints, findFeasible(), getLineSearchParameters(), ipo::Model::Parameters::getMu(), getNewtonDescentParameters(), ipo::Model::Parameters::getOutputStream(), ipo::detail::NewtonDescent::getParameters(), getVectorFromVariables(), indexMap, ipo::detail::BarrierFunction::negative, parameters, ipo::detail::BarrierFunction::positive, RETHROW, setVariablesFromVector(), and stoppingCriterion().
Referenced by maximise(), and minimise().
| bool Model::removeConstraint | ( | Constraint & | constraint | ) |
Remove a constraint.
If the constraint is not in this then it cannot be removed and the function returns false.
| constraint | The constraint |
Definition at line 57 of file Model.cc.
References constraints, and equalityConstraints.
|
protected |
Set constraintIndices.
This function is called internally in setIndices.
Definition at line 429 of file Model.cc.
References constraintIndices, equalityConstraintIndices, equalityConstraints, ipo::Array::front(), ipo::Objective::getVariables(), indexMap, objective, and ipo::Array::size().
Referenced by ipo::detail::PhaseIModel::setIndices(), and setIndices().
|
protectedvirtual |
Sets the values of objectiveIndices, constraintIndices and variableIndices from constraints.
This function is designed to be used internally to generate indices for subvectors of a gsl::vector for calculating gradients and Hessians during optimisation.
Reimplemented in ipo::detail::PhaseIModel.
Definition at line 92 of file Model.cc.
References constraints, equalityConstraints, ipo::Objective::getVariables(), indexMap, objective, RETHROW, setConstraintIndices(), setObjectiveIndices(), ipo::Array::size(), testSizes(), and variablesChanged.
Referenced by ipo::detail::PhaseIModel::getInitial_s(), isFeasible(), isStrictlyFeasible(), and ipo::detail::PhaseIModel::setIndices().
| void Model::setObjective | ( | Objective & | objective | ) |
|
inlineprotected |
Set objectiveIndices.
This function is called internally in setIndices.
Definition at line 847 of file Model.hpp.
References ipo::Objective::getVariables(), indexMap, objective, objectiveIndices, and ipo::Array::size().
Referenced by ipo::detail::PhaseIModel::setIndices(), and setIndices().
|
protected |
Set variable values from a vector.
| vector | a vector of values for variables |
| IPOException | if vector size does not match number of variables |
Definition at line 224 of file Model.cc.
References indexMap, and IPOE.
Referenced by ipo::detail::PhaseIModel::findFeasibleSolution(), and optimise().
|
protected |
Check whether or not stopping criterion has been met.
| t | The value or t used by the barrier |
Definition at line 238 of file Model.cc.
References constraints, equalityConstraints, ipo::Model::Parameters::getEpsilon(), and parameters.
Referenced by optimise().
| void Model::summary | ( | std::ostream & | ostream = std::cout | ) | const |
Create a summary of this model.
| ostream | The stream to print to. |
Definition at line 391 of file Model.cc.
References getObjective(), ipo::Objective::summary(), and summary().
Referenced by summary().
| void Model::testSizes | ( | ) | const |
Check objective and constraint functions.
If any of these differ in the number of Variable objects assigned to them and the declared size of the function, throw an exception of class IPOException describing all the failures.
| IPOException | if any function size don’t match the number of variables supplied |
Definition at line 351 of file Model.cc.
References constraints, ipo::Objective::getName(), ipo::detail::ModelFunction::getSizes(), and objective.
Referenced by setIndices().
|
friend |
|
friend |
|
protected |
Used internally to match the variables in each constraint to indices in a vector: (*constraintIndices[j])()[i] is the index in a gsl::vector of the ith variable in constraint[j]->getVariables() after a call to setIndices().
Definition at line 892 of file Model.hpp.
Referenced by ipo::detail::PhaseIModel::getInitial_s(), ipo::detail::BarrierFunction::gradient(), ipo::detail::BarrierFunction::hessian(), isFeasible(), isStrictlyFeasible(), ipo::detail::BarrierFunction::operator()(), setConstraintIndices(), ipo::detail::PhaseIModel::setIndices(), ipo::detail::BarrierFunction::setVector(), ipo::detail::BarrierFunction::updateGradientFromConstraint(), and ipo::detail::BarrierFunction::updateHessianFromConstraint().
|
protected |
The set of constraints.
Definition at line 872 of file Model.hpp.
Referenced by addConstraint(), checkSize(), getConstraints(), ipo::detail::PhaseIModel::getInitial_s(), ipo::detail::BarrierFunction::gradient(), ipo::detail::BarrierFunction::hessian(), isFeasible(), isStrictlyFeasible(), ipo::detail::BarrierFunction::operator()(), removeConstraint(), ipo::detail::PhaseIModel::setIndices(), setIndices(), ipo::detail::BarrierFunction::setVector(), stoppingCriterion(), testSizes(), ipo::detail::BarrierFunction::updateGradientFromConstraint(), and ipo::detail::BarrierFunction::updateHessianFromConstraint().
|
protected |
Used internally to match the variables in each equality constraint to indices in a vector: (*constraintIndices[j])()[i] is the index in a gsl::vector of the ith variable in * constraint[j]->getVariables() after a call to setIndices().
Definition at line 898 of file Model.hpp.
Referenced by isStrictlyFeasible(), and setConstraintIndices().
|
protected |
The set of equality constraints.
Definition at line 876 of file Model.hpp.
Referenced by addConstraint(), ipo::detail::PhaseIModel::findEqualityConstraintFeasibleSolution(), getEqualityConstraints(), isFeasible(), isStrictlyFeasible(), optimise(), removeConstraint(), setConstraintIndices(), ipo::detail::PhaseIModel::setIndices(), setIndices(), and stoppingCriterion().
|
protected |
Used internally to match the variables in each variable to indices in a vector.
Maps each variable used to a unique index in [0,indexMap.size()).
Definition at line 903 of file Model.hpp.
Referenced by ipo::detail::PhaseIModel::findEqualityConstraintFeasibleSolution(), ipo::detail::PhaseIModel::findFeasibleSolution(), ipo::detail::PhaseIModel::getInitial_s(), getVectorFromVariables(), ipo::detail::BarrierFunction::gradient(), ipo::detail::BarrierFunction::hessian(), ipo::detail::BarrierFunction::initialiseGradientFromObjective(), ipo::detail::BarrierFunction::initialiseHessianFromObjective(), isFeasible(), isStrictlyFeasible(), ipo::detail::BarrierFunction::operator()(), optimise(), setConstraintIndices(), ipo::detail::PhaseIModel::setIndices(), setIndices(), setObjectiveIndices(), setVariablesFromVector(), and ipo::detail::BarrierFunction::setVector().
|
protected |
Parameters used by backtracking line search algorithm during optimisation.
Definition at line 916 of file Model.hpp.
Referenced by getLineSearchParameters(), and ipo::detail::PhaseIModel::PhaseIModel().
|
protected |
Parameters used by Newton descent algorithm during optimisation.
Definition at line 912 of file Model.hpp.
Referenced by getNewtonDescentParameters(), and ipo::detail::PhaseIModel::PhaseIModel().
|
protected |
The objective function.
Definition at line 880 of file Model.hpp.
Referenced by checkSize(), getObjective(), ipo::detail::BarrierFunction::initialiseGradientFromObjective(), ipo::detail::BarrierFunction::initialiseHessianFromObjective(), ipo::detail::BarrierFunction::initialiseResultFromObjective(), setConstraintIndices(), ipo::detail::PhaseIModel::setIndices(), setIndices(), setObjective(), setObjectiveIndices(), and testSizes().
|
protected |
Used internally to match the variables in the objective to indices in a vector: objectiveIndices[i] is the index in a gsl::vector of the ith variable in objective.getVariables() after a call to setIndices().
Definition at line 886 of file Model.hpp.
Referenced by ipo::detail::BarrierFunction::gradient(), ipo::detail::BarrierFunction::hessian(), ipo::detail::BarrierFunction::initialiseGradientFromObjective(), ipo::detail::BarrierFunction::initialiseHessianFromObjective(), ipo::detail::BarrierFunction::operator()(), setObjectiveIndices(), and ipo::detail::BarrierFunction::setVector().
|
private |
Parameters for interior point optimisation.
Definition at line 399 of file Model.hpp.
Referenced by getParameters(), optimise(), ipo::detail::PhaseIModel::PhaseIModel(), and stoppingCriterion().
|
protected |
Value that indicates if any variables, objective or constraints have been modified in such a way that we may have to update them.
Definition at line 908 of file Model.hpp.
Referenced by notify(), ipo::detail::PhaseIModel::PhaseIModel(), ipo::detail::PhaseIModel::setIndices(), and setIndices().