11template <Config Conf,
class Storage>
17 if (
not std::isfinite(
yᵀs))
36template <Config Conf,
class Storage>
59template <Config Conf,
class Storage>
65template <Config Conf,
class Storage>
74template <Config Conf,
class Storage>
77 if (idx == 0 &&
not full)
88 α(i) = ρ(i) * s(i).dot(q);
97 q -= (
β - α(i)) * s(i);
103template <Config Conf,
class Storage>
105 const auto &
J)
const {
107 if (idx == 0 &&
not full)
109 const bool fullJ = q.size() ==
static_cast<index_t>(
J.size());
116 throw std::invalid_argument(
"CBFGS check not supported when using "
117 "masked version of LBFGS::apply_masked()");
127 const auto dotJ = [&
J,
fullJ](
const auto &
a,
const auto &b) {
169 α(i) = ρ(i) *
dotJ(s(i), q);
175 γ = 1 / (ρ(i) *
yᵀy);
187 if (std::isnan(ρ(i)))
197template <Config Conf,
class Storage>
199 return apply_masked_impl(q, γ,
J);
202template <Config Conf,
class Storage>
204 const std::vector<index_t> &
J)
const {
205 return apply_masked_impl(q, γ,
J);
208template <Config Conf,
class Storage>
214template <Config Conf,
class Storage>
216 if (params.memory < 1)
217 throw std::invalid_argument(
"LBFGS::Params::memory must be >= 1");
218 sto.resize(n, params.memory);
222template <Config Conf>
224 sto.resize(n + 1, history * 2);
227template <Config Conf,
class Storage>
230 for (
index_t i = 0; i < history(); ++i) {
235 for (
index_t i = 0; i < idx; ++i) {
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 ...
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ₖ.
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ₙₑₓₜ.
real_t min_abs_s
Reject update if .
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 .
typename Conf::real_t real_t
typename Conf::index_t index_t
typename Conf::length_t length_t
typename Conf::crvec crvec
@ BasedOnCurvature
Initial inverse Hessian approximation is set to .
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.