#include <alpaqa/include/alpaqa/accelerators/lbfgs.hpp>
Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm.
Definition at line 108 of file accelerators/lbfgs.hpp.
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 Params & | get_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 ¶ms, 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 |
using Params = LBFGSParams<config_t> |
Definition at line 112 of file accelerators/lbfgs.hpp.
|
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 115 of file accelerators/lbfgs.hpp.
|
default |
Definition at line 121 of file accelerators/lbfgs.hpp.
bool update_sy_impl | ( | const auto & | s, |
const auto & | y, | ||
real_t | pₙₑₓₜᵀpₙₑₓₜ, | ||
bool | forced = false |
||
) |
bool apply_masked | ( | rvec | q, |
real_t | γ, | ||
crindexvec | J | ||
) | const |
void reset |
void resize | ( | length_t | n | ) |
void scale_y | ( | real_t | factor | ) |
|
inline |
Get a string identifier for this accelerator.
Definition at line 164 of file accelerators/lbfgs.hpp.
|
inline |
Get the parameters.
Definition at line 168 of file accelerators/lbfgs.hpp.
|
inline |
Get the size of the s and y vectors in the buffer.
Definition at line 171 of file accelerators/lbfgs.hpp.
|
inline |
Get the number of previous vectors s and y stored in the buffer.
Definition at line 173 of file accelerators/lbfgs.hpp.
Get the next index in the circular buffer of previous s and y vectors.
Definition at line 175 of file accelerators/lbfgs.hpp.
Get the previous index in the circular buffer of s and y vectors.
Definition at line 177 of file accelerators/lbfgs.hpp.
|
inline |
Get the number of previous s and y vectors currently stored in the buffer.
Definition at line 180 of file accelerators/lbfgs.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Iterate over the indices in the history buffer, oldest first.
Definition at line 193 of file accelerators/lbfgs.hpp.
|
inline |
Iterate over the indices in the history buffer, newest first.
Definition at line 204 of file accelerators/lbfgs.hpp.
|
private |
Definition at line 214 of file accelerators/lbfgs.hpp.
|
private |
Definition at line 215 of file accelerators/lbfgs.hpp.
|
private |
Definition at line 216 of file accelerators/lbfgs.hpp.
|
private |
Definition at line 217 of file accelerators/lbfgs.hpp.