21 explicit operator bool()
const {
return ϵ > 0; }
59 auto y(
index_t i)
const {
return sto.col(2 * i + 1).topRows(
n()); }
66 Eigen::Matrix<real_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
93 template <
class VecS,
class VecY>
95 real_t pₙₑₓₜᵀpₙₑₓₜ,
bool forced =
false);
109 template <
class IndexVec>
Limited memory Broyden–Fletcher–Goldfarb–Shanno (L-BFGS) algorithm.
void foreach_rev(const F &fun) const
Iterate over the indices in the history buffer, newest first.
static bool update_valid(const LBFGSParams ¶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...
length_t current_history() const
Get the number of previous s and y vectors currently stored in the buffer.
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)
const real_t & ρ(index_t i) const
const Params & get_params() const
Get the parameters.
bool apply(rvec q, real_t γ=-1)
Apply the inverse Hessian approximation to the given vector q.
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.
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.
Sign
The sign of the vectors passed to the LBFGS::update method.
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ₖ₊₁.
const real_t & α(index_t i) const
bool update_sy(const anymat< VecS > &s, const anymat< VecY > &y, real_t pₙₑₓₜᵀpₙₑₓₜ, bool forced=false)
Update the inverse Hessian approximation using the new vectors sₖ = xₖ₊₁ - xₖ and yₖ = pₖ₊₁ - pₖ.
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
real_t min_abs_s
Reject update if .
CBFGSParams cbfgs
Parameters in the cautious BFGS update condition.
length_t memory
Length of the history to keep.
index_t length_t
Default type for vector sizes.
bool force_pos_def
If set to true, the inverse Hessian estimate should remain definite, i.e.
Eigen::Index index_t
Default type for vector indices.
double real_t
Default floating point type.
Eigen::MatrixBase< Derived > anymat
Generic type for vector and matrix arguments.
real_t min_div_fac
Reject update if .
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Parameters for the LBFGS class.
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.
const real_t & ρ(index_t i) const
length_t history() const
Get the number of previous vectors s and y stored in the buffer.
Eigen::Matrix< real_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > storage_t
const real_t & α(index_t i) const