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

L-BFGS storage. More...

#include <LBFGSStorage.hpp>

Public Member Functions

 LBFGSStorage (Eigen::Index n, Eigen::Index m, Scalar epsilon, 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, const Vector< Scalar > &STv, const Vector< Scalar > &YTv)
 Calculate product of inverse Hessian approximation $ \mathbf{H} $ with vector $ \mathbf{v} $. 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...
 
Vector< Scalar > calculate_Bv (const Vector< Scalar > &v, const Vector< Scalar > &STv, const Vector< Scalar > &YTv)
 Calculate product of Hessian approximation $ \mathbf{B} $ with vector $ \mathbf{v} $. 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...
 
Matrix< Scalar > calculate_B ()
 Calculate the Hessian matrix approximation $ \mathbf{B} $. More...
 
bool update (const Vector< Scalar > &s, const Vector< Scalar > &y, const Vector< Scalar > &g)
 Update the (inverse) Hessian approximation. More...
 
void resize (Eigen::Index b)
 Function that resizes the storage to b. More...
 

Public Attributes

Eigen::Index n
 Dimensionality of the problem.
 
Eigen::Index m
 Maximal number of update pairs to store.
 
Eigen::Index b
 Current number of stored update pairs.
 
Matrix< Scalar > W
 $ 2n*m $ working matrix
 
Matrix< Scalar > M
 $ 2m*2m $ working matrix
 
Matrix< Scalar > S
 $ n*m $ matrix storing the last $ \mathbf{s} $ vectors
 
Matrix< Scalar > Y
 $ n*m $ matrix storing the last $ \mathbf{y} $ vectors
 
Matrix< Scalar > R
 $ m*m $ helper matrix
 
Matrix< Scalar > L
 $ m*m $ helper matrix
 
Matrix< Scalar > D
 $ m*m $ helper matrix
 
Matrix< Scalar > YTY
 $ m*m $ matrix storing $ \mathbf{Y}^\intercal \mathbf{Y} $
 
Matrix< Scalar > STS
 $ m*m $ matrix storing $ \mathbf{S}^\intercal \mathbf{S} $
 
Matrix< Scalar > LOW
 $ 2m*2m $ working matrix
 
Matrix< Scalar > UPP
 $ 2m*2m $ working matrix
 
Scalar gamma = Scalar{1}
 current scaling of the inverse Hessian
 
Scalar epsilon
 numerical stability check epsilon
 
OutputFunction & output_function
 output function for status messages.
 

Detailed Description

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

L-BFGS storage.

Template Parameters
ScalarThe scalar type of vector/matrix coefficients.

This is the implementation of the limited memory BFGS algorithm. Here, the approximation of the (inverse) Hessian is stored as the last m update pairs.

It requires $ \Theta(nm + m^2) $ storage.

We use the matrix representation described in

Byrd, R.H., Nocedal, J., Schnable, R.B. Representation of quasi-Newton matrices and their use in limited memory methods. 1994. Mathematical Programming. 63. 129-156.

Byrd, R.H., Lu, P., Nocedal, J., Zhu, C. A Limited Memory Algorithm for Bound Constrained Optimization. 1995. SIAM Journal of Scientific and Statistical Computing. 16(5). 1190-1208.

Constructor & Destructor Documentation

◆ LBFGSStorage()

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

Construct a BFGS storage.

Parameters
nDimensionality of the problem.
mNumber $ (\mathbf{s}, \mathbf{y}) $ update pairs to store.
epsilonSmall value for numerical stability check.
output_functionOutput function for status messages.

Member Function Documentation

◆ calculate_B()

template<typename Scalar , typename OutputFunction >
Matrix< Scalar > LSLOpt::Implementation::LBFGSStorage< Scalar, OutputFunction >::calculate_B ( )

Calculate the Hessian matrix approximation $ \mathbf{B} $.

Returns
The Hessian matrix approximation $ \mathbf{B} $.
Warning
This is only for debugging and testing. This can get very large and it undermines the limited-memory concept!

◆ calculate_Bv() [1/2]

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

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

Parameters
vVector $ \mathbf{v} $ for calculation.
STvProduct of the $ \mathbf{S}^\intercal $ matrix with $ \mathbf{v} $
YTvProduct of the $ \mathbf{S}^\intercal $ matrix with $ \mathbf{v} $
Returns
The product $ \mathbf{B} \mathbf{v} $.

Runtime $ \Theta(mn) $.

◆ calculate_Bv() [2/2]

template<typename Scalar , typename OutputFunction >
Vector< Scalar > LSLOpt::Implementation::LBFGSStorage< 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(mn) $.

◆ calculate_Hv() [1/2]

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

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

Parameters
vVector $ \mathbf{v} $ for calculation.
STvProduct of the $ \mathbf{S}^\intercal $ matrix with $ \mathbf{v} $
YTvProduct of the $ \mathbf{S}^\intercal $ matrix with $ \mathbf{v} $
Returns
The product $ \mathbf{H} \mathbf{v} $.

Runtime $ \Theta(mn) $.

◆ calculate_Hv() [2/2]

template<typename Scalar , typename OutputFunction >
Vector< Scalar > LSLOpt::Implementation::LBFGSStorage< 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(mn) $.

◆ calculate_vBv()

template<typename Scalar , typename OutputFunction >
Scalar LSLOpt::Implementation::LBFGSStorage< 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(mn) $.

Todo:
There is a formulation that calculates this in $ \Theta(m^2) $.

◆ calculate_vHv()

template<typename Scalar , typename OutputFunction >
Scalar LSLOpt::Implementation::LBFGSStorage< 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(mn) $.

◆ reset()

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

Reset the (inverse) Hessian approximation to identity matrix.

This function deletes all $ (\mathbf{s}, \mathbf{y}) $ update pairs.

Runtime $ \Theta(n) $.

◆ resize()

template<typename Scalar , typename OutputFunction >
void LSLOpt::Implementation::LBFGSStorage< Scalar, OutputFunction >::resize ( Eigen::Index  b)

Function that resizes the storage to b.

Parameters
bNew size of the storage.

If $ b < m $, then the size of the storage is increased. Otherwise the oldest update pair is deleted.

Runtime $ \Theta(mn + m^2) $.

◆ update()

template<typename Scalar , typename OutputFunction >
bool LSLOpt::Implementation::LBFGSStorage< 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

The runtime of update is $ 4*n*m + \Theta(m^3) $

The $ \Theta(m^3) $ part stems from the Cholesky decomposition and the inversion of $ \mathbf{M} $.


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