|
Interior-point-optimisation
1.0-1
Interior-pointoptimisationlibrary
|
This class computes a function at a vector. More...
#include <Function.hpp>


Public Member Functions | |
| Function (size_t const size=0) | |
| Constructor. More... | |
| virtual double | operator() (gsl::vector const &vector)=0 |
| Compute a function value. More... | |
| virtual gsl::vector | gradient (gsl::vector const &vector) |
| Compute or estimate a gradient value. More... | |
| virtual gsl::matrix | hessian (gsl::vector const &vector) |
| Compute or estimate a Hessian value. 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... | |
Protected Attributes | |
| 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... | |
This class computes a function at a vector.
It is an abstract base class and so you derive from this class to create classes to implement the function objects needed for interior-point optimisation.
The constructor subclass of Function should use FunctionBase( size ) to specify the size of vectors it uses unless these are arbitrary.
When creating a subclass, do not forget to initialise FunctionBase explicitly in the constructor.
Definition at line 38 of file Function.hpp.
| Function::Function | ( | size_t const | size = 0 | ) |
Constructor.
| size | The size of vector for member functions that take a vector |
Definition at line 28 of file Function.cc.
|
virtual |
Compute or estimate derivative values.
The default is to compute central difference quotient graient and Hessian estimates. The virtual base function just calls gradient and hessian. So it is not necessary to define derivatives in addition to gradient and hessian in subclasses. But it is possible if there is some benefit to be gained.
| vector | The vector at which to evaluate the function |
Definition at line 109 of file Function.cc.
References gradient(), and hessian().
|
virtual |
Compute or estimate a gradient value.
The default is to compute a central difference quotient gradient estimate.
| vector | The vector at which to evaluate the function |
Reimplemented in ipo_function::concrete::QuadraticCombination, ipo_function::concrete::LinearCombination, ipo_function::detail::PhaseIBoundedVariableFunctionAndDerivatives, ipo_function::concrete::Sum, ipo::detail::BarrierFunction, ipo_function::detail::PhaseIFunctionAndDerivatives, ipo_function::detail::PhaseIObjectiveFunctionAndDerivatives, ipo_function::concrete::SumOfSquares, and ipo_function::concrete::NullFunction.
Definition at line 31 of file Function.cc.
References h, and operator()().
Referenced by derivatives(), and ipo::detail::BarrierFunction::initialiseGradientFromObjective().
|
virtual |
Compute or estimate a Hessian value.
The default is to compute a central difference quotient Hessian estimate.
| vector | The vector at which to evaluate the function |
Reimplemented in ipo_function::concrete::QuadraticCombination, ipo_function::concrete::LinearCombination, ipo_function::detail::PhaseIBoundedVariableFunctionAndDerivatives, ipo_function::concrete::Sum, ipo::detail::BarrierFunction, ipo_function::detail::PhaseIFunctionAndDerivatives, ipo_function::detail::PhaseIObjectiveFunctionAndDerivatives, ipo_function::concrete::SumOfSquares, and ipo_function::concrete::NullFunction.
Definition at line 54 of file Function.cc.
References h2, and operator()().
Referenced by derivatives(), and ipo::detail::BarrierFunction::initialiseHessianFromObjective().
|
pure virtual |
Compute a function value.
This may throw an exception if vector and data sizes do not match
| vector | The vector at which to evaluate the function |
Implemented in ipo_function::concrete::QuadraticCombination, ipo_function::concrete::LinearCombination, ipo_function::detail::PhaseIBoundedVariableFunctionAndDerivatives, ipo_function::concrete::Sum, ipo::detail::BarrierFunction, ipo_function::detail::PhaseIFunctionAndDerivatives, ipo_function::detail::PhaseIObjectiveFunctionAndDerivatives, ipo_function::concrete::SumOfSquares, and ipo_function::concrete::NullFunction.
Referenced by gradient(), and hessian().
|
protected |
Value used for default gradient estimates.
The default value is the square root of machine epsilon.
Definition at line 82 of file Function.hpp.
Referenced by gradient(), ipo_function::detail::PhaseIFunctionAndDerivatives::hessian(), and ipo_function::detail::PhaseIFunctionAndDerivatives::setVector().
|
protected |
Value used for default Hessian estimates.
The default value is the fourth root of machine epsilon.
Definition at line 87 of file Function.hpp.
Referenced by hessian().