17template <Config Conf = DefaultConfig>
22 explicit operator bool()
const {
return ϵ > 0; }
35 [[
deprecated(
"use BasedOnExternalStepSize instead")]] =
41template <Config Conf = DefaultConfig>
53 std::pow(std::numeric_limits<real_t>::epsilon(),
real_t(2));
84template <Config Conf = DefaultConfig>
98 return std::as_const(
sto).col(2 * i).topRows(
n());
102 return std::as_const(
sto).col(2 * i + 1).topRows(
n());
110 static_assert(!storage_t::IsRowMajor);
116template <Config Conf = DefaultConfig>
174 return "LBFGS<" + std::string(config_t::get_name()) +
'>';
232 return "BasedOnExternalStepSize";
236 throw std::out_of_range(
"invalid value for alpaqa::LBFGSStepSize");
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.
LBFGSStepSize stepsize
Scale of the initial inverse Hessian approximation that the rank-one L-BFGS updates are applied to,...
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.
real_t min_div_fac
Reject update if .
Parameters for the LBFGS class.
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
constexpr const char * enum_name(LBFGSStepSize s)
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 , where is the forward-backward splitting step size.
typename Conf::crindexvec crindexvec
real_t ϵ
Set to zero to disable CBFGS check.
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