alpaqa 1.0.0a13
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
LBFGS< Conf > Class Template Reference

#include <alpaqa/accelerators/lbfgs.hpp>

Detailed Description

template<Config Conf = DefaultConfig>
class alpaqa::LBFGS< Conf >

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

Definition at line 117 of file lbfgs.hpp.

+ Collaboration diagram for LBFGS< Conf >:

Public Types

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

Public Member Functions

 LBFGS ()=default
 
 LBFGS (Params params)
 
 LBFGS (Params params, length_t n)
 
bool update_sy (crvec s, crvec y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced=false)
 Update the inverse Hessian approximation using the new vectors sₖ = xₙₑₓₜ - xₖ and yₖ = pₙₑₓₜ - pₖ.
 
bool update_sy_impl (const auto &s, const auto &y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced=false)
 
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ₙₑₓₜ.
 
bool apply (rvec q, real_t γ=-1) const
 Apply the inverse Hessian approximation to the given vector q.
 
bool apply_masked (rvec q, real_t γ, crindexvec J) const
 Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.
 
bool apply_masked (rvec q, real_t γ, const std::vector< index_t > &J) const
 Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.
 
bool apply_masked_impl (rvec q, real_t γ, const auto &J) const
 Apply the inverse Hessian approximation to the given vector q, applying only the columns and rows of the Hessian in the index set J.
 
void reset ()
 Throw away the approximation and all previous vectors s and y.
 
void resize (length_t n)
 Re-allocate storage for a problem with a different size.
 
void scale_y (real_t factor)
 Scale the stored y vectors by the given factor.
 
std::string get_name () const
 Get a string identifier for this accelerator.
 
const Paramsget_params () const
 Get the parameters.
 
length_t n () const
 Get the size of the s and y vectors in the buffer.
 
length_t history () const
 Get the number of previous vectors s and y stored in the buffer.
 
index_t succ (index_t i) const
 Get the next index in the circular buffer of previous s and y vectors.
 
index_t pred (index_t i) const
 Get the previous index in the circular buffer of s and y vectors.
 
length_t current_history () const
 Get the number of previous s and y vectors currently stored in the buffer.
 
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)
 
real_tρ (index_t i) const
 
real_tα (index_t i)
 
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.
 
template<class F >
void foreach_rev (const F &fun) const
 Iterate over the indices in the history buffer, newest first.
 

Static Public Member Functions

static bool update_valid (const Params &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.
 

Private Attributes

LBFGSStorage< config_t > sto
 
index_t idx = 0
 
bool full = false
 
Params params
 

Member Typedef Documentation

◆ Params

template<Config Conf = DefaultConfig>
using Params = LBFGSParams<config_t>

Definition at line 121 of file lbfgs.hpp.

Member Enumeration Documentation

◆ Sign

template<Config Conf = DefaultConfig>
enum class Sign
strong

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

Enumerator
Positive 

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

Negative 

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

Definition at line 124 of file lbfgs.hpp.

Constructor & Destructor Documentation

◆ LBFGS() [1/3]

template<Config Conf = DefaultConfig>
LBFGS ( )
default

◆ LBFGS() [2/3]

template<Config Conf = DefaultConfig>
LBFGS ( Params  params)
inline

Definition at line 130 of file lbfgs.hpp.

◆ LBFGS() [3/3]

template<Config Conf = DefaultConfig>
LBFGS ( Params  params,
length_t  n 
)
inline

Definition at line 131 of file lbfgs.hpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ update_valid()

template<Config Conf>
bool update_valid ( const Params params,
real_t  yᵀs,
real_t  sᵀs,
real_t  pᵀp 
)
static

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 12 of file lbfgs.tpp.

◆ update_sy()

template<Config Conf>
bool update_sy ( crvec  s,
crvec  y,
real_t  pₙₑₓₜᵀpₙₑₓₜ,
bool  forced = false 
)

Update the inverse Hessian approximation using the new vectors sₖ = xₙₑₓₜ - xₖ and yₖ = pₙₑₓₜ - pₖ.

Definition at line 60 of file lbfgs.tpp.

◆ update_sy_impl()

template<Config Conf>
bool update_sy_impl ( const auto s,
const auto y,
real_t  pₙₑₓₜᵀpₙₑₓₜ,
bool  forced = false 
)
See also
update_sy

Definition at line 37 of file lbfgs.tpp.

◆ update()

template<Config Conf>
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ₙₑₓₜ.

Definition at line 65 of file lbfgs.tpp.

+ Here is the caller graph for this function:

◆ apply()

template<Config Conf>
bool apply ( rvec  q,
real_t  γ = -1 
) const

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 74 of file lbfgs.tpp.

+ Here is the caller graph for this function:

◆ apply_masked() [1/2]

template<Config Conf>
bool apply_masked ( rvec  q,
real_t  γ,
crindexvec  J 
) const

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 196 of file lbfgs.tpp.

◆ apply_masked() [2/2]

template<Config Conf>
bool apply_masked ( rvec  q,
real_t  γ,
const std::vector< index_t > &  J 
) const

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 201 of file lbfgs.tpp.

◆ apply_masked_impl()

template<Config Conf>
bool apply_masked_impl ( rvec  q,
real_t  γ,
const auto J 
) const

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 103 of file lbfgs.tpp.

◆ reset()

template<Config Conf>
void reset ( )

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

Definition at line 207 of file lbfgs.tpp.

+ Here is the caller graph for this function:

◆ resize()

template<Config Conf>
void resize ( length_t  n)

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

Causes a reset.

Definition at line 213 of file lbfgs.tpp.

+ Here is the caller graph for this function:

◆ scale_y()

template<Config Conf>
void scale_y ( real_t  factor)

Scale the stored y vectors by the given factor.

Definition at line 226 of file lbfgs.tpp.

+ Here is the caller graph for this function:

◆ get_name()

template<Config Conf = DefaultConfig>
std::string get_name ( ) const
inline

Get a string identifier for this accelerator.

Definition at line 173 of file lbfgs.hpp.

◆ get_params()

template<Config Conf = DefaultConfig>
const Params & get_params ( ) const
inline

Get the parameters.

Definition at line 177 of file lbfgs.hpp.

+ Here is the caller graph for this function:

◆ n()

template<Config Conf = DefaultConfig>
length_t n ( ) const
inline

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

Definition at line 180 of file lbfgs.hpp.

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

◆ history()

template<Config Conf = DefaultConfig>
length_t history ( ) const
inline

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

Definition at line 182 of file lbfgs.hpp.

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

◆ succ()

template<Config Conf = DefaultConfig>
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 184 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ pred()

template<Config Conf = DefaultConfig>
index_t pred ( index_t  i) const
inline

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

Definition at line 186 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ current_history()

template<Config Conf = DefaultConfig>
length_t current_history ( ) const
inline

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

Definition at line 189 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ s() [1/2]

template<Config Conf = DefaultConfig>
auto s ( index_t  i)
inline

Definition at line 191 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ s() [2/2]

template<Config Conf = DefaultConfig>
auto s ( index_t  i) const
inline

Definition at line 192 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ y() [1/2]

template<Config Conf = DefaultConfig>
auto y ( index_t  i)
inline

Definition at line 193 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ y() [2/2]

template<Config Conf = DefaultConfig>
auto y ( index_t  i) const
inline

Definition at line 194 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ ρ() [1/2]

template<Config Conf = DefaultConfig>
real_t & ρ ( index_t  i)
inline

Definition at line 195 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ ρ() [2/2]

template<Config Conf = DefaultConfig>
real_t & ρ ( index_t  i) const
inline

Definition at line 196 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ α() [1/2]

template<Config Conf = DefaultConfig>
real_t & α ( index_t  i)
inline

Definition at line 197 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ α() [2/2]

template<Config Conf = DefaultConfig>
real_t & α ( index_t  i) const
inline

Definition at line 198 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ foreach_fwd()

template<Config Conf = DefaultConfig>
template<class F >
void foreach_fwd ( const F fun) const
inline

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

Definition at line 202 of file lbfgs.hpp.

+ Here is the call graph for this function:

◆ foreach_rev()

template<Config Conf = DefaultConfig>
template<class F >
void foreach_rev ( const F fun) const
inline

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

Definition at line 213 of file lbfgs.hpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ sto

template<Config Conf = DefaultConfig>
LBFGSStorage<config_t> sto
private

Definition at line 223 of file lbfgs.hpp.

◆ idx

template<Config Conf = DefaultConfig>
index_t idx = 0
private

Definition at line 224 of file lbfgs.hpp.

◆ full

template<Config Conf = DefaultConfig>
bool full = false
private

Definition at line 225 of file lbfgs.hpp.

◆ params

template<Config Conf = DefaultConfig>
Params params
private

Definition at line 226 of file lbfgs.hpp.


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