Interior-point-optimisation  1.0-1
Interior-pointoptimisationlibrary
ipo_function::concrete::Sum Class Reference

This class has two purposes. More...

#include <Sum.hpp>

Inheritance diagram for ipo_function::concrete::Sum:
Inheritance graph
Collaboration diagram for ipo_function::concrete::Sum:
Collaboration graph

Public Member Functions

 Sum (size_t const size=0)
 Specify a constructor argument if you want to be able to check the size of the argument in a Model Objective or Constraint and do not need this size to vary. More...
 
double operator() (gsl::vector const &vector)
 The function operator: computes the sum of the vector entries. More...
 
gsl::vector gradient (gsl::vector const &vector)
 The function operator: returns the gradient: a vector of 1s. More...
 
gsl::matrix hessian (gsl::vector const &vector)
 The function operator: returns the Hessian: a matrix of 0s. More...
 
void setVector (gsl::vector const &vector)
 Set a vector and compute function value, gradient and Hessian efficiently. 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
 

Additional Inherited Members

- 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...
 

Detailed Description

This class has two purposes.

First it provides a plausibly useful Function dependent on a size parameter. Second, it provides an example of how a Function might efficiently be constructed. The class computes the sum of the entries in a vector together with the first and second derivatives.

Definition at line 49 of file Sum.hpp.

Constructor & Destructor Documentation

Sum::Sum ( size_t const  size = 0)

Specify a constructor argument if you want to be able to check the size of the argument in a Model Objective or Constraint and do not need this size to vary.

Parameters
sizeThe size of vectors in the function and derivatives

Definition at line 28 of file Sum.cc.

Member Function Documentation

gsl::vector Sum::gradient ( gsl::vector const &  vector)
virtual

The function operator: returns the gradient: a vector of 1s.

Parameters
vectorA vector argument
Returns
The gradient (a vector of 1s)

Reimplemented from ipo_function::Function.

Definition at line 46 of file Sum.cc.

References ipo_function::GradientEstimate::functionGradient, and ipo_function::detail::FunctionBase::getSize().

gsl::matrix Sum::hessian ( gsl::vector const &  vector)
virtual

The function operator: returns the Hessian: a matrix of 0s.

Parameters
vectorA vector argument
Returns
The Hessian: a matrix of zeros

Reimplemented from ipo_function::Function.

Definition at line 58 of file Sum.cc.

References ipo_function::DerivativesEstimates::functionHessian, and ipo_function::detail::FunctionBase::getSize().

double Sum::operator() ( gsl::vector const &  vector)
virtual

The function operator: computes the sum of the vector entries.

Parameters
vectorA vector argument
Returns
The sum of vector entries

Implements ipo_function::Function.

Definition at line 40 of file Sum.cc.

void Sum::setVector ( gsl::vector const &  vector)
virtual

Set a vector and compute function value, gradient and Hessian efficiently.

Parameters
vectorA vector argument

Implements ipo_function::GradientEstimate.

Definition at line 70 of file Sum.cc.

References ipo_function::GradientEstimate::functionGradient, ipo_function::DerivativesEstimates::functionHessian, ipo_function::GradientEstimate::functionValue, and ipo_function::detail::FunctionBase::getSize().


The documentation for this class was generated from the following files: