22 const auto s = xₖ₊₁ - xₖ;
23 const auto y = pₖ - pₖ₊₁;
27 real_t pᵀp = pₖ₊₁.squaredNorm();
54 auto &&sₖ = xₖ₊₁ - xₖ;
55 auto &&yₖ = this->
w();
58 auto &&pₖ = this->
p();
65 real_t sᵀs = sₖ.squaredNorm();
66 real_t pᵀp = pₖ₊₁.squaredNorm();
76 for (
size_t i =
pred(
idx); i != endidx; i =
pred(i)) {
111 auto update1 = [&](
size_t i) {
112 α(i) =
ρ(i) * (
s(i).dot(q));
116 for (
size_t i =
idx; i-- > 0;)
124 auto update2 = [&](
size_t i) {
126 q += (
α(i) - β) *
s(i);
131 for (
size_t i = 0; i <
idx; ++i)
137 sto.fill(std::numeric_limits<real_t>::quiet_NaN());
168 return lbfgs.
update(xₖ, xₖ₊₁, pₖ, pₖ₊₁, gradₖ₊₁,
C, γ);
static bool update_valid(LBFGSParams 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 definitene...
Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm that can handle updates of the γ p...
bool full_update(crvec xₖ, crvec xₖ₊₁, crvec pₖ_old_γ, crvec pₖ₊₁, crvec gradₖ₊₁, const Box &C, real_t γ)
L-BFGS update when changing the step size γ, recomputing everything.
size_t succ(size_t i) const
Get the next index in the circular buffer of previous s, y, x and g vectors.
void initialize(crvec x₀, crvec grad₀)
Initialize with the starting point x₀ and the gradient in that point.
size_t pred(size_t i) const
Get the previous index in the circular buffer of previous s, y, x and g vectors.
void apply(Vec &&q)
Apply the inverse Hessian approximation to the given vector q.
bool standard_update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec gradₖ₊₁)
Standard L-BFGS update without changing the step size γ.
size_t history() const
Get the number of previous vectors s, y, x and g stored in the buffer.
bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec gradₖ₊₁, const Box &C, real_t γ)
Update the inverse Hessian approximation using the new vectors xₖ₊₁ and pₖ₊₁.
void resize(size_t n, size_t history)
Re-allocate storage for a problem with a different size.
size_t n() const
Get the size of the s, y, x and g vectors in the buffer.
void reset()
Throw away the approximation and all previous vectors s and y.
auto projected_gradient_step(const Box &C, real_t γ, crvec x, crvec grad_ψ)
Projected gradient step.
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
double real_t
Default floating point type.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
static bool update(SpecializedLBFGS &lbfgs, crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, crvec gradₖ₊₁, const Box &C, real_t γ)
static void initialize(SpecializedLBFGS &lbfgs, crvec x₀, crvec x̂₀, crvec p₀, crvec grad₀)
static bool apply(SpecializedLBFGS &lbfgs, crvec xₖ, crvec x̂ₖ, crvec pₖ, real_t γ, rvec qₖ)
static void changed_γ(SpecializedLBFGS &lbfgs, real_t γₖ, real_t old_γₖ)