quala main
Quasi-Newton and other accelerators
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
LBFGS Class Reference

#include <quala/decl/lbfgs.hpp>

Detailed Description

Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm.

Definition at line 72 of file decl/lbfgs.hpp.

+ Collaboration diagram for LBFGS:

Public Types

enum class  Sign { Positive , Negative }
 The sign of the vectors \( p \) passed to the LBFGS::update method. More...
 
using Params = LBFGSParams
 

Public Member Functions

 LBFGS (Params params)
 
 LBFGS (Params params, length_t n)
 
template<class VecS , class VecY >
bool update_sy (const anymat< VecS > &s, const anymat< VecY > &y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced=false)
 Update the inverse Hessian approximation using the new vectors sₖ = xₖ₊₁ - xₖ and yₖ = pₖ₊₁ - pₖ. More...
 
bool update (crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, Sign sign=Sign::Positive, bool forced=false)
 Update the inverse Hessian approximation using the new vectors xₖ₊₁ and pₖ₊₁. More...
 
bool apply (rvec q, real_t γ=-1)
 Apply the inverse Hessian approximation to the given vector q. More...
 
template<class IndexVec >
bool apply (rvec q, real_t γ, const IndexVec &J)
 Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J. More...
 
void reset ()
 Throw away the approximation and all previous vectors s and y. More...
 
void resize (length_t n)
 Re-allocate storage for a problem with a different size. More...
 
void scale_y (real_t factor)
 Scale the stored y vectors by the given factor. More...
 
const Paramsget_params () const
 Get the parameters. More...
 
length_t n () const
 Get the size of the s and y vectors in the buffer. More...
 
length_t history () const
 Get the number of previous vectors s and y stored in the buffer. More...
 
index_t succ (index_t i) const
 Get the next index in the circular buffer of previous s and y vectors. More...
 
index_t pred (index_t i) const
 Get the previous index in the circular buffer of s and y vectors. More...
 
length_t current_history () const
 Get the number of previous s and y vectors currently stored in the buffer. More...
 
auto s (index_t i)
 
auto s (index_t i) const
 
auto y (index_t i)
 
auto y (index_t i) const
 
real_tρ (index_t i)
 
const real_tρ (index_t i) const
 
real_tα (index_t i)
 
const real_tα (index_t i) const
 
template<class F >
void foreach_fwd (const F &fun) const
 Iterate over the indices in the history buffer, oldest first. More...
 
template<class F >
void foreach_rev (const F &fun) const
 Iterate over the indices in the history buffer, newest first. More...
 

Static Public Member Functions

static bool update_valid (const LBFGSParams &params, real_t yᵀs, real_t sᵀs, real_t pᵀp)
 Check if the new vectors s and y allow for a valid BFGS update that preserves the positive definiteness of the Hessian approximation. More...
 

Private Attributes

LBFGSStorage sto
 
index_t idx = 0
 
bool full = false
 
Params params
 

Member Typedef Documentation

◆ Params

Definition at line 74 of file decl/lbfgs.hpp.

Member Enumeration Documentation

◆ Sign

enum class Sign
strong

The sign of the vectors \( p \) passed to the LBFGS::update method.

Enumerator
Positive 

\( p \sim \nabla \psi(x) \)

Negative 

\( p \sim -\nabla \psi(x) \)

Definition at line 78 of file decl/lbfgs.hpp.

Constructor & Destructor Documentation

◆ LBFGS() [1/2]

LBFGS ( Params  params)
inline

Definition at line 83 of file decl/lbfgs.hpp.

◆ LBFGS() [2/2]

LBFGS ( Params  params,
length_t  n 
)
inline

Definition at line 84 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ update_valid()

bool update_valid ( const LBFGSParams params,
real_t  yᵀs,
real_t  sᵀs,
real_t  pᵀp 
)
inlinestatic

Check if the new vectors s and y allow for a valid BFGS update that preserves the positive definiteness of the Hessian approximation.

Definition at line 9 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_sy()

bool update_sy ( const anymat< VecS > &  s,
const anymat< VecY > &  y,
real_t  pₙₑₓₜᵀpₙₑₓₜ,
bool  forced = false 
)
inline

Update the inverse Hessian approximation using the new vectors sₖ = xₖ₊₁ - xₖ and yₖ = pₖ₊₁ - pₖ.

Definition at line 34 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

bool update ( crvec  xₖ,
crvec  xₙₑₓₜ,
crvec  pₖ,
crvec  pₙₑₓₜ,
Sign  sign = Sign::Positive,
bool  forced = false 
)
inline

Update the inverse Hessian approximation using the new vectors xₖ₊₁ and pₖ₊₁.

Definition at line 56 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ apply() [1/2]

bool apply ( rvec  q,
real_t  γ = -1 
)
inline

Apply the inverse Hessian approximation to the given vector q.

Initial inverse Hessian approximation is set to \( H_0 = \gamma I \). If γ is negative, \( H_0 = \frac{s^\top y}{y^\top y} I \).

Definition at line 64 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ apply() [2/2]

bool apply ( rvec  q,
real_t  γ,
const IndexVec &  J 
)

Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.

Definition at line 93 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ reset()

void reset ( )
inline

Throw away the approximation and all previous vectors s and y.

Definition at line 180 of file lbfgs.hpp.

+ Here is the caller graph for this function:

◆ resize()

void resize ( length_t  n)
inline

Re-allocate storage for a problem with a different size.

Causes a reset.

Definition at line 185 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ scale_y()

void scale_y ( real_t  factor)
inline

Scale the stored y vectors by the given factor.

Definition at line 196 of file lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_params()

const Params & get_params ( ) const
inline

Get the parameters.

Definition at line 122 of file decl/lbfgs.hpp.

+ Here is the caller graph for this function:

◆ n()

length_t n ( ) const
inline

Get the size of the s and y vectors in the buffer.

Definition at line 125 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ history()

length_t history ( ) const
inline

Get the number of previous vectors s and y stored in the buffer.

Definition at line 127 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ succ()

index_t succ ( index_t  i) const
inline

Get the next index in the circular buffer of previous s and y vectors.

Definition at line 129 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pred()

index_t pred ( index_t  i) const
inline

Get the previous index in the circular buffer of s and y vectors.

Definition at line 131 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ current_history()

length_t current_history ( ) const
inline

Get the number of previous s and y vectors currently stored in the buffer.

Definition at line 134 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ s() [1/2]

auto s ( index_t  i)
inline

Definition at line 136 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ s() [2/2]

auto s ( index_t  i) const
inline

Definition at line 137 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:

◆ y() [1/2]

auto y ( index_t  i)
inline

Definition at line 138 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ y() [2/2]

auto y ( index_t  i) const
inline

Definition at line 139 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:

◆ ρ() [1/2]

real_t & ρ ( index_t  i)
inline

Definition at line 140 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ρ() [2/2]

const real_t & ρ ( index_t  i) const
inline

Definition at line 141 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:

◆ α() [1/2]

real_t & α ( index_t  i)
inline

Definition at line 142 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ α() [2/2]

const real_t & α ( index_t  i) const
inline

Definition at line 143 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:

◆ foreach_fwd()

void foreach_fwd ( const F &  fun) const
inline

Iterate over the indices in the history buffer, oldest first.

Definition at line 147 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ foreach_rev()

void foreach_rev ( const F &  fun) const
inline

Iterate over the indices in the history buffer, newest first.

Definition at line 158 of file decl/lbfgs.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ sto

LBFGSStorage sto
private

Definition at line 168 of file decl/lbfgs.hpp.

◆ idx

index_t idx = 0
private

Definition at line 169 of file decl/lbfgs.hpp.

◆ full

bool full = false
private

Definition at line 170 of file decl/lbfgs.hpp.

◆ params

Params params
private

Definition at line 171 of file decl/lbfgs.hpp.


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