LSLOpt  1.0
Public Member Functions | Public Attributes | List of all members
LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction > Struct Template Reference

BFGS storage. More...

#include <BFGSStorage.hpp>

Public Member Functions

 BFGSStorage (Eigen::Index n, Eigen::Index, Scalar, OutputFunction &output_function)
 Construct a BFGS storage. More...
 
void reset ()
 Reset the (inverse) Hessian approximation to identity matrix. More...
 
Vector< Scalar > calculate_Hv (const Vector< Scalar > &v)
 Calculate product of inverse Hessian approximation $ \mathbf{H} $ with vector $ \mathbf{v} $. More...
 
Scalar calculate_vHv (const Vector< Scalar > &v)
 Calculate normalized scalar product of vector $ \mathbf{v} $ with inverse Hessian approximation $ \mathbf{H} $. More...
 
const Matrix< Scalar > & calculate_H ()
 Access the inverse Hessian approximation $ \mathbf{H} $. More...
 
Vector< Scalar > calculate_Bv (const Vector< Scalar > &v)
 Calculate product of Hessian approximation $ \mathbf{B} $ with vector $ \mathbf{v} $. More...
 
Scalar calculate_vBv (const Vector< Scalar > &v)
 Calculate normalized scalar product of vector $ \mathbf{v} $ with Hessian approximation $ \mathbf{B} $. More...
 
const Matrix< Scalar > & calculate_B ()
 Access the Hessian approximation $ \mathbf{B} $. More...
 
bool update (const Vector< Scalar > &s, const Vector< Scalar > &y, const Vector< Scalar > &g)
 Update the (inverse) Hessian approximation. More...
 

Public Attributes

Eigen::Index n
 dimensionality of the problem
 
Matrix< Scalar > H
 inverse Hessian approximation
 
Matrix< Scalar > B
 Hessian approximation.
 
bool initial
 is this the initial approximation?
 
OutputFunction & output_function
 output function for status messages
 

Detailed Description

template<typename Scalar, typename OutputFunction>
struct LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >

BFGS storage.

This is the implementation of the BFGS algorithm. It directly stores the approximate Hessian $ \mathbf{B} $ and the inverse approximate inverse Hessian $ \mathbf{H} $.

Template Parameters
ScalarThe scalar type of vector/matrix coefficients.

It requires $ \Theta(n^2) $ storage!

Constructor & Destructor Documentation

◆ BFGSStorage()

template<typename Scalar , typename OutputFunction >
LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::BFGSStorage ( Eigen::Index  n,
Eigen::Index  ,
Scalar  ,
OutputFunction &  output_function 
)

Construct a BFGS storage.

Parameters
nDimensionality of the problem.
output_functionOutput function for status messages.

The second and third parameter are unused.

Member Function Documentation

◆ calculate_B()

template<typename Scalar , typename OutputFunction >
const Matrix< Scalar > & LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_B ( )

Access the Hessian approximation $ \mathbf{B} $.

Runtime $ \Theta(1) $.

◆ calculate_Bv()

template<typename Scalar , typename OutputFunction >
Vector< Scalar > LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_Bv ( const Vector< Scalar > &  v)

Calculate product of Hessian approximation $ \mathbf{B} $ with vector $ \mathbf{v} $.

Parameters
vVector $ \mathbf{v} $ for calculation.
Returns
The product $ \mathbf{B} \mathbf{v} $.

Runtime $ \Theta(n^2) $.

◆ calculate_H()

template<typename Scalar , typename OutputFunction >
const Matrix< Scalar > & LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_H ( )

Access the inverse Hessian approximation $ \mathbf{H} $.

Runtime $ \Theta(1) $.

◆ calculate_Hv()

template<typename Scalar , typename OutputFunction >
Vector< Scalar > LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_Hv ( const Vector< Scalar > &  v)

Calculate product of inverse Hessian approximation $ \mathbf{H} $ with vector $ \mathbf{v} $.

Parameters
vVector $ \mathbf{v} $ for calculation.
Returns
The product $ \mathbf{H} \mathbf{v} $.

Runtime $ \Theta(n^2) $.

◆ calculate_vBv()

template<typename Scalar , typename OutputFunction >
Scalar LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_vBv ( const Vector< Scalar > &  v)

Calculate normalized scalar product of vector $ \mathbf{v} $ with Hessian approximation $ \mathbf{B} $.

Parameters
vVector $ \mathbf{v} $ for calculation.
Returns
The normalized scalar product $ \mathbf{v}^\intercal \mathbf{B} \mathbf{v} $.

Runtime $ \Theta(n^2) $.

◆ calculate_vHv()

template<typename Scalar , typename OutputFunction >
Scalar LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::calculate_vHv ( const Vector< Scalar > &  v)

Calculate normalized scalar product of vector $ \mathbf{v} $ with inverse Hessian approximation $ \mathbf{H} $.

Parameters
vVector $ \mathbf{v} $ for calculation.
Returns
The normalized scalar product $ \mathbf{v}^\intercal \mathbf{H} \mathbf{v} $.

Runtime $ \Theta(n^2) $.

◆ reset()

template<typename Scalar , typename OutputFunction >
void LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::reset ( )

Reset the (inverse) Hessian approximation to identity matrix.

Runtime $ \Theta(n^2) $.

◆ update()

template<typename Scalar , typename OutputFunction >
bool LSLOpt::Implementation::BFGSStorage< Scalar, OutputFunction >::update ( const Vector< Scalar > &  s,
const Vector< Scalar > &  y,
const Vector< Scalar > &  g 
)

Update the (inverse) Hessian approximation.

Parameters
sChange in x coordinate.
yChange in gradient.
gNew gradient.
Returns
true if successful, false otherwise

Runtime $ \omega(n^2) $ (depends on the matrix multiplication algorithm in Eigen).

Todo:
Here we could also introduce a check if the product B * H really is the identity.

The documentation for this struct was generated from the following file: