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

This class provides function objects representing linear combinations of the elements of their vector arguments. More...

#include <LinearCombination.hpp>

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

Public Member Functions

 LinearCombination (size_t const size=0)
 The constructor sets up function as a linear combination of size entries. More...
 
void resize (size_t const size)
 Resize the vector of coefficients. More...
 
void setCoefficient (size_t const index, double const value)
 Set the value of a coefficient. More...
 
double getCoefficient (size_t const index) const
 Get the value of a coefficient. More...
 
gsl::vector const & getCoefficients () const
 Get the coefficients as a vector by reference. More...
 
void setCoefficients (gsl::vector const &vector)
 Set coefficients from a vector. More...
 
virtual double operator() (gsl::vector const &vector)
 The function operator: computes the sum of the vector entries. More...
 
virtual gsl::vector gradient (gsl::vector const &vector)
 The function operator: returns the gradient: the coefficients. More...
 
virtual gsl::matrix hessian (gsl::vector const &vector)
 The function operator: returns the Hessian: a matrix of 0s. More...
 
virtual 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
 

Protected Attributes

gsl::vector coefficients
 The vector of coefficients;. 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...
 

Detailed Description

This class provides function objects representing linear combinations of the elements of their vector arguments.

Each object of this class stores a vector $\mathbf{c}=(c_1,\ldots,c_k)^\top$ of coefficients. When the function object is called with a vector argument $\mathbf{v}=(v_1,\ldots,v_k)^\top$ it returns $\mathbf{c}^\top\mathbf{v}$.

Definition at line 37 of file LinearCombination.hpp.

Constructor & Destructor Documentation

LinearCombination::LinearCombination ( size_t const  size = 0)

The constructor sets up function as a linear combination of size entries.

Initially the coefficient of each entry is zero so that a call to function returns zero.

Parameters
sizeThe size of vectors in the function and derivatives

Definition at line 28 of file LinearCombination.cc.

Member Function Documentation

double LinearCombination::getCoefficient ( size_t const  index) const

Get the value of a coefficient.

Parameters
indexThe index of the coefficient
Returns
The value of the coefficient
Exceptions
IPOExceptionif index out of range

Definition at line 57 of file LinearCombination.cc.

References coefficients, and IPOE.

gsl::vector const & LinearCombination::getCoefficients ( ) const

Get the coefficients as a vector by reference.

Returns
the vector of coefficients

Definition at line 67 of file LinearCombination.cc.

References coefficients.

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

The function operator: returns the gradient: the coefficients.

The return value may change if the coefficients change.

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

Reimplemented from ipo_function::Function.

Definition at line 101 of file LinearCombination.cc.

References coefficients, ipo_function::GradientEstimate::functionGradient, and IPOE.

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

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

The return value may change if the number of coefficients change.

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

Reimplemented from ipo_function::Function.

Definition at line 119 of file LinearCombination.cc.

References coefficients, ipo_function::DerivativesEstimates::functionHessian, and IPOE.

double LinearCombination::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 86 of file LinearCombination.cc.

References coefficients, and IPOE.

void LinearCombination::resize ( size_t const  size)

Resize the vector of coefficients.

Any new entries are set to zero.

Parameters
sizeThe new size

Definition at line 32 of file LinearCombination.cc.

References coefficients, and ipo_function::detail::FunctionBase::size.

void LinearCombination::setCoefficient ( size_t const  index,
double const  value 
)

Set the value of a coefficient.

Parameters
indexThe index of the coefficient
valueThe new value of the coefficient
Exceptions
IPOExceptionif index out of range

Definition at line 47 of file LinearCombination.cc.

References coefficients, IPOE, and ipo_function::GradientEstimate::value().

void LinearCombination::setCoefficients ( gsl::vector const &  vector)

Set coefficients from a vector.

This can resize the coefficients.

Parameters
vectorThe new coefficients vector

Definition at line 72 of file LinearCombination.cc.

References coefficients, and IPOE.

void LinearCombination::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 136 of file LinearCombination.cc.

References coefficients, ipo_function::GradientEstimate::functionGradient, ipo_function::DerivativesEstimates::functionHessian, ipo_function::GradientEstimate::functionValue, and IPOE.

Member Data Documentation

gsl::vector ipo_function::concrete::LinearCombination::coefficients
protected

The vector of coefficients;.

Definition at line 106 of file LinearCombination.hpp.

Referenced by getCoefficient(), getCoefficients(), gradient(), hessian(), operator()(), resize(), setCoefficient(), setCoefficients(), and setVector().


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