alpaqa sparse
Nonconvex constrained optimization
Loading...
Searching...
No Matches
structured-lbfgs.hpp
Go to the documentation of this file.
1#pragma once
2
8#include <optional>
9
10namespace alpaqa {
11
12/// Parameters for the @ref StructuredLBFGSDirection class.
13template <Config Conf>
16 /// Set this option to a nonzero value to include the Hessian-vector product
17 /// @f$ \nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x) q_\mathcal{K} @f$ from
18 /// equation 12b in @cite pas2022alpaqa, scaled by this parameter.
19 /// Set it to zero to leave out that term.
21 /// If @ref hessian_vec_factor is nonzero, set this option to true to
22 /// approximate that term using finite differences instead of using AD.
24 /// If @ref hessian_vec_factor is nonzero and
25 /// @ref hessian_vec_finite_differences is true, set this option to true to
26 /// compute the exact Hessian of the augmented Lagrangian, false to
27 /// approximate it using the Hessian of the Lagrangian.
30 /// If L-BFGS fails, propagate the failure and tell PANOC that no
31 /// accelerated step is available, causing it to accept the projected
32 /// gradient step instead.
34 /// If L-BFGS fails, return @f$ q_\mathcal{J} =
35 /// -\gamma\nabla_{x_\mathcal{J}}\psi(x^k)
36 /// -\gamma\nabla^2_{x_\mathcal{J}x_\mathcal{K}}\psi(x)
37 /// q_\mathcal{K} @f$ as the accelerated step (effectively approximating
38 /// @f$ \nabla_{x_\mathcal{J}x_\mathcal{J}} \approx \gamma I @f$).
40 }
41 /// What to do when L-BFGS failed (e.g. if there were no pairs (s, y) with
42 /// positive curvature).
44};
45
46/// @ingroup grp_DirectionProviders
47template <Config Conf = DefaultConfig>
54
59
62 : lbfgs(params.accelerator), direction_params(params.direction) {}
72
73 /// @see @ref PANOCDirection::initialize
76
77 /// @see @ref PANOCDirection::has_initial_direction
78 bool has_initial_direction() const { return false; }
79
80 /// @see @ref PANOCDirection::update
89
90 /// @see @ref PANOCDirection::apply
92 rvec qₖ) const;
93
94 /// @see @ref PANOCDirection::changed_γ
96 // Nothing, Hessian approximation is independent of step size
97 }
98
99 /// @see @ref PANOCDirection::reset
100 void reset() { lbfgs.reset(); }
101
102 /// @see @ref PANOCDirection::get_name
103 std::string get_name() const {
104 return "StructuredLBFGSDirection<" + std::string(config_t::get_name()) +
105 '>';
106 }
107
108 auto get_params() const {
109 return std::tie(lbfgs.get_params(), direction_params);
110 }
111
112 private:
114
115 const Problem *problem = nullptr;
116#ifndef _WIN32
117 std::optional<crvec> y = std::nullopt;
118 std::optional<crvec> Σ = std::nullopt;
119#else
120 std::optional<vec> y = std::nullopt;
121 std::optional<vec> Σ = std::nullopt;
122#endif
123
126 mutable vec HqK;
127 mutable vec work_n;
128 mutable vec work_n2;
129 mutable vec work_m;
130
132 crindexvec J) const;
133
134 public:
136};
137
138// clang-format off
143// clang-format on
144
145} // namespace alpaqa
LBFGSParams< config_t > Params
Definition lbfgs.hpp:112
const Params & get_params() const
Get the parameters.
Definition lbfgs.hpp:168
void reset()
Throw away the approximation and all previous vectors s and y.
Definition lbfgs.tpp:207
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ₙₑₓₜ.
Definition lbfgs.tpp:65
#define USING_ALPAQA_CONFIG(Conf)
Definition config.hpp:56
#define ALPAQA_IF_QUADF(...)
Definition config.hpp:182
#define ALPAQA_IF_LONGD(...)
Definition config.hpp:194
#define ALPAQA_IF_FLOAT(...)
Definition config.hpp:188
#define ALPAQA_EXPORT_EXTERN_TEMPLATE(...)
Definition export.hpp:21
typename Conf::indexvec indexvec
Definition config.hpp:78
typename Conf::real_t real_t
Definition config.hpp:65
constexpr const auto inf
Definition config.hpp:85
typename Conf::rvec rvec
Definition config.hpp:69
typename Conf::crvec crvec
Definition config.hpp:70
typename Conf::vec vec
Definition config.hpp:66
typename Conf::crindexvec crindexvec
Definition config.hpp:80
Double-precision double configuration.
Definition config.hpp:135
Single-precision float configuration.
Definition config.hpp:131
long double configuration.
Definition config.hpp:140
Parameters for the StructuredLBFGSDirection class.
real_t hessian_vec_factor
Set this option to a nonzero value to include the Hessian-vector product from equation 12b in ,...
bool full_augmented_hessian
If hessian_vec_factor is nonzero and hessian_vec_finite_differences is true, set this option to true ...
bool hessian_vec_finite_differences
If hessian_vec_factor is nonzero, set this option to true to approximate that term using finite diffe...
@ FallbackToProjectedGradient
If L-BFGS fails, propagate the failure and tell PANOC that no accelerated step is available,...
@ UseScaledLBFGSInput
If L-BFGS fails, return as the accelerated step (effectively approximating ).
enum alpaqa::StructuredLBFGSDirectionParams::FailurePolicy failure_policy
What to do when L-BFGS failed (e.g.
void changed_γ(real_t γₖ, real_t old_γₖ)
bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)
StructuredLBFGSDirection(LBFGS &&lbfgs, const DirectionParams &directionparams={})
typename LBFGS::Params AcceleratorParams
StructuredLBFGSDirection(const LBFGS &lbfgs, const DirectionParams &directionparams={})
StructuredLBFGSDirection(const Params &params)
StructuredLBFGSDirection(const typename LBFGS::Params &params, const DirectionParams &directionparams={})
void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)
void approximate_hessian_vec_term(crvec xₖ, crvec grad_ψxₖ, rvec qₖ, crindexvec J) const
bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
TypeErasedProblem< config_t > Problem