16template <Config Conf = DefaultConfig>
21 explicit operator bool()
const {
return ϵ > 0; }
33 [[
deprecated(
"use BasedOnExternalStepSize instead")]] =
38template <Config Conf = DefaultConfig>
48 std::pow(std::numeric_limits<real_t>::epsilon(),
real_t(2));
75template <Config Conf = DefaultConfig>
89 return std::as_const(
sto).col(2 * i).topRows(
n());
93 return std::as_const(
sto).col(2 * i + 1).topRows(
n());
101 static_assert(!storage_t::IsRowMajor);
107template <Config Conf = DefaultConfig>
165 return "LBFGS<" + std::string(config_t::get_name()) +
'>';
Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm.
std::string get_name() const
Get a string identifier for this accelerator.
void foreach_rev(const F &fun) const
Iterate over the indices in the history buffer, newest first.
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 ...
length_t current_history() const
Get the number of previous s and y vectors currently stored in the buffer.
LBFGSParams< config_t > Params
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 n() const
Get the size of the s and y vectors in the buffer.
LBFGS(Params params, length_t n)
LBFGSStorage< config_t > sto
const Params & get_params() const
Get the parameters.
length_t history() const
Get the number of previous vectors s and y stored in the buffer.
void foreach_fwd(const F &fun) const
Iterate over the indices in the history buffer, oldest first.
real_t & α(index_t i) const
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ₖ.
real_t & ρ(index_t i) const
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 definitene...
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 ...
void resize(length_t n)
Re-allocate storage for a problem with a different size.
void reset()
Throw away the approximation and all previous vectors s and y.
bool update_sy_impl(const auto &s, const auto &y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced=false)
Sign
The sign of the vectors passed to the update method.
bool apply(rvec q, real_t γ=-1) const
Apply the inverse Hessian approximation to the given vector q.
void scale_y(real_t factor)
Scale the stored y vectors by the given factor.
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ₙₑₓₜ.
#define USING_ALPAQA_CONFIG(Conf)
#define ALPAQA_IF_QUADF(...)
#define ALPAQA_IF_LONGD(...)
#define ALPAQA_IF_FLOAT(...)
#define ALPAQA_EXPORT_EXTERN_TEMPLATE(...)
real_t min_abs_s
Reject update if .
length_t memory
Length of the history to keep.
CBFGSParams< config_t > cbfgs
Parameters in the cautious BFGS update condition.
bool force_pos_def
If set to true, the inverse Hessian estimate should remain definite, i.e.
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
real_t min_div_fac
Reject update if .
LBFGSStepSize
Which method to use to select the L-BFGS step size.
@ BasedOnGradientStepSize
@ BasedOnCurvature
Initial inverse Hessian approximation is set to .
@ BasedOnExternalStepSize
Initial inverse Hessian approximation is set to .
typename Conf::crindexvec crindexvec
Parameters for the LBFGS class.
real_t ϵ
Set to zero to disable CBFGS check.
Double-precision double configuration.
Single-precision float configuration.
long double configuration.
void resize(length_t n, length_t history)
Re-allocate storage for a problem with a different size.
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.
real_t & α(index_t i) const
real_t & ρ(index_t i) const