alpaqa 1.0.0a16
Nonconvex constrained optimization
Loading...
Searching...
No Matches
lbfgsb-adapter.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <chrono>
11#include <iostream>
12
13#include <LBFGSB.h>
14
15namespace alpaqa::lbfgspp {
16
17template <Config Conf = DefaultConfig>
27
28/// L-BFGS-B solver for ALM.
29/// @ingroup grp_InnerSolvers
30template <Config Conf>
32 public:
34
36 using Params = ::LBFGSpp::LBFGSBParam<real_t>;
39
41
42 Stats operator()(const Problem &problem, // in
43 const SolveOptions &opts, // in
44 rvec x, // inout
45 rvec y, // inout
46 crvec Σ, // in
47 rvec err_z); // out
48
49 template <class P>
50 Stats operator()(const P &problem, const SolveOptions &opts, rvec u, rvec y,
51 crvec Σ, rvec e) {
52 return operator()(Problem{&problem}, opts, u, y, Σ, e);
53 }
54
55 std::string get_name() const;
56
57 void stop() { stop_signal.stop(); }
58
59 const Params &get_params() const { return params; }
60
61 private:
64
65 public:
66 std::ostream *os = &std::cout;
67};
68
69// clang-format off
74
79// clang-format on
80
81} // namespace alpaqa::lbfgspp
82
83namespace alpaqa {
84
85template <class InnerSolverStats>
87
88template <Config Conf>
89struct InnerStatsAccumulator<lbfgspp::LBFGSBStats<Conf>> {
91
92 /// Total elapsed time in the inner solver.
93 std::chrono::nanoseconds elapsed_time{};
94 /// Total number of inner PANOC iterations.
95 unsigned iterations = 0;
96 /// Final value of the smooth cost @f$ \psi(\hat x) @f$.
97 real_t final_ψ = 0;
98};
99
100template <Config Conf>
105 acc.elapsed_time += s.elapsed_time;
106 acc.final_ψ = s.final_ψ;
107 return acc;
108}
109
110} // namespace alpaqa
L-BFGS-B solver for ALM.
Stats operator()(const P &problem, const SolveOptions &opts, rvec u, rvec y, crvec Σ, rvec e)
Stats operator()(const Problem &problem, const SolveOptions &opts, rvec x, rvec y, crvec Σ, rvec err_z)
::LBFGSpp::LBFGSBParam< real_t > Params
InnerSolveOptions< config_t > SolveOptions
LBFGSBStats< config_t > Stats
LBFGSBSolver(const Params &params)
const Params & get_params() const
TypeErasedProblem< config_t > Problem
#define USING_ALPAQA_CONFIG(Conf)
Definition config.hpp:63
#define ALPAQA_IF_QUADF(...)
Definition config.hpp:207
#define ALPAQA_IF_LONGD(...)
Definition config.hpp:219
#define ALPAQA_IF_FLOAT(...)
Definition config.hpp:213
#define ALPAQA_LBFGSPP_EXPORT_EXTERN_TEMPLATE(...)
std::chrono::nanoseconds elapsed_time
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
@ Busy
In progress.
typename Conf::real_t real_t
Definition config.hpp:72
InnerStatsAccumulator< FISTAStats< Conf > > & operator+=(InnerStatsAccumulator< FISTAStats< Conf > > &acc, const FISTAStats< Conf > &s)
Definition fista.hpp:189
constexpr const auto inf
Definition config.hpp:98
typename Conf::rvec rvec
Definition config.hpp:77
typename Conf::crvec crvec
Definition config.hpp:78
unsigned iterations
Total number of inner FISTA iterations.
Definition fista.hpp:176
Double-precision double configuration.
Definition config.hpp:160
Single-precision float configuration.
Definition config.hpp:156
long double configuration.
Definition config.hpp:165