43 std::string
get_name()
const {
return "SpecializedLBFGS"; }
46 size_t n()
const {
return sto.rows() - 1; }
51 size_t succ(
size_t i)
const {
return i + 1 <
history() ? i + 1 : 0; }
54 size_t pred(
size_t i)
const {
return i == 0 ?
history() - 1 : i - 1; }
56 auto s(
size_t i) {
return sto.col(2 * i).topRows(
n()); }
57 auto s(
size_t i)
const {
return sto.col(2 * i).topRows(
n()); }
58 auto y(
size_t i) {
return sto.col(2 * i + 1).topRows(
n()); }
59 auto y(
size_t i)
const {
return sto.col(2 * i + 1).topRows(
n()); }
60 auto x(
size_t i) {
return sto.col(2 *
history() + 2 * i).topRows(
n()); }
61 auto x(
size_t i)
const {
64 auto g(
size_t i) {
return sto.col(2 *
history() + 2 * i + 1).topRows(
n()); }
65 auto g(
size_t i)
const {
66 return sto.col(2 *
history() + 2 * i + 1).topRows(
n());
73 const real_t &
ρ(
size_t i)
const {
return sto.coeff(
n(), 2 * i); }
75 const real_t &
α(
size_t i)
const {
return sto.coeff(
n(), 2 * i + 1); }
78 using storage_t = Eigen::Matrix<real_t, Eigen::Dynamic, Eigen::Dynamic>;
Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm that can handle updates of the γ p...
std::string get_name() const
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.
SpecializedLBFGS(Params params, size_t n, size_t history)
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.
Eigen::Matrix< real_t, Eigen::Dynamic, Eigen::Dynamic > storage_t
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ₖ₊₁.
SpecializedLBFGS(Params params)
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.
const real_t & α(size_t i) const
void reset()
Throw away the approximation and all previous vectors s and y.
const real_t & ρ(size_t i) const
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
double real_t
Default floating point type.
Parameters for the LBFGS and SpecializedLBFGS classes.