|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
Function for the logarithmic barrier. More...
#include <BarrierFunction.hpp>


Public Types | |
| enum | Sign { Sign::positive, Sign::negative } |
| Enumerated type used to determine sign of objective in BarrierFunction. More... | |
Public Member Functions | |
| BarrierFunction (Model &model, Sign const sign=Sign::positive, double const t=0.1) | |
| The constructor needs a Model. More... | |
| virtual double | operator() (gsl::vector const &vector) |
| Evaluate the function. More... | |
| virtual gsl::vector | gradient (gsl::vector const &vector) |
| Compute or estimate a gradient value from objective and constraints. More... | |
| virtual gsl::matrix | hessian (gsl::vector const &vector) |
| Compute or estimate a Hessian value from objective and constraints. More... | |
| virtual gsl::vector | gradient () |
| Get gradient value from last call to setValue();. More... | |
| virtual gsl::matrix | hessian () |
| Get Hessian value from last call to setValue();. More... | |
| void | set_t (double const t) |
| Set t to a new value. More... | |
| double | get_t () const |
| Get t value. More... | |
| virtual void | setVector (gsl::vector const &vector) |
| Set value of vector. More... | |
Public Member Functions inherited from ipo_function::Function | |
| Function (size_t const size=0) | |
| Constructor. More... | |
| virtual std::tuple < gsl::vector, gsl::matrix > | derivatives (gsl::vector const &vector) |
| Compute or estimate derivative values. More... | |
Public Member Functions inherited from ipo_function::detail::FunctionBase | |
| FunctionBase (size_t const size=0) | |
| Constructor. More... | |
| virtual | ~FunctionBase ()=0 |
| Make the class abstract. More... | |
| size_t | getSize () const |
| Get size of vector for function arguments or zero for arbitrary size. More... | |
Public Member Functions inherited from ipo_function::DerivativesEstimates | |
| DerivativesEstimates (size_t const size=0) | |
| Constructor. More... | |
| virtual gsl::matrix | hessian () const |
Public Member Functions inherited from ipo_function::GradientEstimate | |
| GradientEstimate (size_t const size=0) | |
| Constructor. More... | |
| virtual double | value () const |
| virtual gsl::vector | gradient () const |
Protected Member Functions | |
| void | initialiseResultFromObjective (gsl::vector &subvector, bool const simul=false) |
| Update result from objective. More... | |
| void | updateResultFromConstraint (Constraint &constraint, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound) |
| Update result from a constraint. More... | |
| void | updateResultFromVariable (std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector) |
| Update result from a variable. More... | |
| gsl::vector | initialiseGradientFromObjective (gsl::vector &subvector, bool const simul=false) |
| Update gradient from objective. More... | |
| gsl::vector | updateGradientFromConstraint (size_t const constraintIndex, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound, bool const simul=false) |
| Update gradient from a constraint. More... | |
| void | updateGradientFromVariable (std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector) |
| Update gradient from a variable. More... | |
| void | initialiseHessianFromObjective (gsl::vector &subvector, bool const simul=false) |
| Update gradient from objective. More... | |
| void | updateHessianFromConstraint (size_t const constraintIndex, gsl::vector &subvector, double const &lowerBound, double const &functionValue, double const &upperBound, gsl::vector &gradient, bool const simul=false) |
| Update Hessian from a constraint. More... | |
| void | updateHessianFromVariable (std::map< Variable, size_t >::value_type &entry, gsl::vector const &vector) |
| Update hessian from a variable. More... | |
Protected Attributes | |
| Model & | model |
| The value t used to determine the barrier. More... | |
| Sign const | sign |
| Set this to true or false according as the objective is to be added or subtracted. More... | |
| double | t |
| The value t used to determine the barrier. More... | |
Protected Attributes inherited from ipo_function::Function | |
| double | h = std::sqrt( std::numeric_limits<double>::epsilon() ) |
| Value used for default gradient estimates. More... | |
| double | h2 = std::sqrt( h ) |
| Value used for default Hessian estimates. More... | |
Protected Attributes inherited from ipo_function::detail::FunctionBase | |
| size_t const | size |
| Size of vector arguments to supply to subclass functions. More... | |
Protected Attributes inherited from ipo_function::DerivativesEstimates | |
| gsl::matrix | functionHessian |
| The Hessian value. More... | |
Protected Attributes inherited from ipo_function::GradientEstimate | |
| double | functionValue |
| The function value. More... | |
| gsl::vector | functionGradient |
| The gradient value. More... | |
Function for the logarithmic barrier.
Definition at line 35 of file BarrierFunction.hpp.
|
strong |
Enumerated type used to determine sign of objective in BarrierFunction.
| Enumerator | |
|---|---|
| positive |
Use +objective. |
| negative |
Use -objective. |
Definition at line 41 of file BarrierFunction.hpp.
| BarrierFunction::BarrierFunction | ( | Model & | model, |
| Sign const | sign = Sign::positive, |
||
| double const | t = 0.1 |
||
| ) |
The constructor needs a Model.
It can also take a parameter t that is used together with logarithms to approximate an indicator function. The larger t is the better the approximation. Typically t is set useing set_t() during optimisation.
| model | The Model |
| sign | The Sign: positive or negative |
| t | The value of t |
Definition at line 28 of file BarrierFunction.cc.
| double BarrierFunction::get_t | ( | ) | const |
|
virtual |
Compute or estimate a gradient value from objective and constraints.
| vector | The vector at which to evaluate the function |
Reimplemented from ipo_function::Function.
Definition at line 77 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::GradientEstimate::functionGradient, ipo::Model::indexMap, ipo::infinity, initialiseGradientFromObjective(), lowerBound, ipo::minusInfinity, model, ipo::Model::objectiveIndices, updateGradientFromConstraint(), updateGradientFromVariable(), and upperBound.
|
inlinevirtual |
Get gradient value from last call to setValue();.
Definition at line 74 of file BarrierFunction.hpp.
Referenced by hessian(), initialiseGradientFromObjective(), setVector(), and updateGradientFromConstraint().
|
virtual |
Compute or estimate a Hessian value from objective and constraints.
| vector | The vector at which to evaluate the function |
Reimplemented from ipo_function::Function.
Definition at line 107 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::DerivativesEstimates::functionHessian, gradient(), ipo::Model::indexMap, ipo::infinity, initialiseHessianFromObjective(), lowerBound, ipo::minusInfinity, model, ipo::Model::objectiveIndices, updateHessianFromConstraint(), updateHessianFromVariable(), and upperBound.
|
inlinevirtual |
Get Hessian value from last call to setValue();.
Definition at line 79 of file BarrierFunction.hpp.
Referenced by initialiseHessianFromObjective(), and updateHessianFromConstraint().
|
protected |
Update gradient from objective.
| subvector | The subvector for the objective |
| simul | Set to true to try to estimate function value and derivatives simultaneously: assumes gradient already calculated |
Definition at line 185 of file BarrierFunction.cc.
References ipo_function::DerivativesEstimates::DerivativesEstimates(), ipo_function::GradientEstimate::functionGradient, ipo::detail::ModelFunction::getFunction(), ipo_function::Function::gradient(), gradient(), ipo::Model::indexMap, model, ipo::Model::objective, ipo::Model::objectiveIndices, positive, sign, and t.
Referenced by gradient(), and setVector().
|
protected |
Update gradient from objective.
| subvector | The subvector for the objective |
| simul | Set to true to try to estimate function value and derivatives simultaneously |
Definition at line 252 of file BarrierFunction.cc.
References ipo_function::DerivativesEstimates::DerivativesEstimates(), ipo_function::DerivativesEstimates::functionHessian, ipo::detail::ModelFunction::getFunction(), ipo_function::Function::hessian(), hessian(), ipo::Model::indexMap, model, ipo::Model::objective, ipo::Model::objectiveIndices, positive, sign, and t.
Referenced by hessian(), and setVector().
|
protected |
Update result from objective.
| subvector | The subvector for the objective |
| simul | Set to true to try to estimate function value and derivatives simultaneously |
Definition at line 138 of file BarrierFunction.cc.
References ipo_function::DerivativesEstimates::DerivativesEstimates(), ipo_function::GradientEstimate::functionValue, ipo::detail::ModelFunction::getFunction(), model, ipo::Model::objective, positive, sign, and t.
Referenced by operator()(), and setVector().
|
virtual |
Evaluate the function.
| vector | The function argument |
Implements ipo_function::Function.
Definition at line 47 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::GradientEstimate::functionValue, ipo::Model::indexMap, ipo::infinity, initialiseResultFromObjective(), lowerBound, ipo::minusInfinity, model, ipo::Model::objectiveIndices, updateResultFromConstraint(), updateResultFromVariable(), and upperBound.
| void BarrierFunction::set_t | ( | double const | t | ) |
Set t to a new value.
| t | The new vector value |
Definition at line 37 of file BarrierFunction.cc.
References t.
|
virtual |
Set value of vector.
This also calculates and stores function value, gradient and Hessian more efficiently than if all three are computed seprately. It is even more efficient on objective and constraint functions that are also derived classes of DerivativesEstimates.
Implements ipo_function::GradientEstimate.
Definition at line 327 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::DerivativesEstimates::DerivativesEstimates(), gradient(), ipo::Model::indexMap, ipo::infinity, initialiseGradientFromObjective(), initialiseHessianFromObjective(), initialiseResultFromObjective(), lowerBound, ipo::minusInfinity, model, ipo::Model::objectiveIndices, updateGradientFromConstraint(), updateGradientFromVariable(), updateHessianFromConstraint(), updateHessianFromVariable(), updateResultFromConstraint(), updateResultFromVariable(), and upperBound.
|
protected |
Update gradient from a constraint.
| constraintIndex | The constraintIndex |
| subvector | The subvector for constraint |
| lowerBound | The lower bound on the constraint |
| functionValue | The constraint function value |
| upperBound | The upper bound on the constraint |
| simul | Set to true to try to estimate function value and derivatives simultaneously: assumes gradient already calculated |
Definition at line 205 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::DerivativesEstimates::DerivativesEstimates(), ipo_function::GradientEstimate::functionGradient, gradient(), ipo::infinity, ipo::minusInfinity, and model.
Referenced by gradient(), and setVector().
|
protected |
Update gradient from a variable.
| entry | The indexMap entry for the variable |
| vector | The vector of variable values |
Definition at line 230 of file BarrierFunction.cc.
References ipo_function::GradientEstimate::functionGradient, ipo::infinity, lowerBound, ipo::minusInfinity, and upperBound.
Referenced by gradient(), and setVector().
|
protected |
Update Hessian from a constraint.
| constraintIndex | The constraintIndex |
| subvector | The subvector for constraint |
| lowerBound | The lower bound on the constraint |
| functionValue | The constraint function value |
| upperBound | The upper bound on the constraint |
| gradient | The gradient at subvector |
| simul | Set to true to try to estimate function value and derivatives simultaneously |
Definition at line 272 of file BarrierFunction.cc.
References ipo::Model::constraintIndices, ipo::Model::constraints, ipo_function::DerivativesEstimates::DerivativesEstimates(), ipo_function::DerivativesEstimates::functionHessian, hessian(), ipo::infinity, ipo::minusInfinity, and model.
Referenced by hessian(), and setVector().
|
protected |
Update hessian from a variable.
| entry | The indexMap entry for the variable |
| vector | The vector of variable values |
Definition at line 301 of file BarrierFunction.cc.
References ipo_function::DerivativesEstimates::functionHessian, ipo::infinity, lowerBound, ipo::minusInfinity, and upperBound.
Referenced by hessian(), and setVector().
|
protected |
Update result from a constraint.
| constraint | The constraint |
| subvector | The subvector for constraint |
| lowerBound | The lower bound on the constraint |
| functionValue | The constraint function value |
| upperBound | The upper bound on the constraint |
Definition at line 157 of file BarrierFunction.cc.
References ipo::infinity, and ipo::minusInfinity.
Referenced by operator()(), and setVector().
|
protected |
Update result from a variable.
| entry | The indexMap entry for the variable |
| vector | The vector of variable values |
Definition at line 169 of file BarrierFunction.cc.
References ipo_function::GradientEstimate::functionValue, ipo::infinity, lowerBound, ipo::minusInfinity, and upperBound.
Referenced by operator()(), and setVector().
|
protected |
The value t used to determine the barrier.
Definition at line 188 of file BarrierFunction.hpp.
Referenced by gradient(), hessian(), initialiseGradientFromObjective(), initialiseHessianFromObjective(), initialiseResultFromObjective(), operator()(), setVector(), updateGradientFromConstraint(), and updateHessianFromConstraint().
|
protected |
Set this to true or false according as the objective is to be added or subtracted.
Definition at line 193 of file BarrierFunction.hpp.
Referenced by initialiseGradientFromObjective(), initialiseHessianFromObjective(), and initialiseResultFromObjective().
|
protected |
The value t used to determine the barrier.
Definition at line 197 of file BarrierFunction.hpp.
Referenced by get_t(), initialiseGradientFromObjective(), initialiseHessianFromObjective(), initialiseResultFromObjective(), and set_t().