alpaqa pi-pico
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:77
#define ALPAQA_IF_QUADF(...)
Definition config.hpp:223
#define ALPAQA_IF_LONGD(...)
Definition config.hpp:235
#define ALPAQA_IF_FLOAT(...)
Definition config.hpp:229
#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:86
InnerStatsAccumulator< FISTAStats< Conf > > & operator+=(InnerStatsAccumulator< FISTAStats< Conf > > &acc, const FISTAStats< Conf > &s)
Definition fista.hpp:189
constexpr const auto inf
Definition config.hpp:112
typename Conf::rvec rvec
Definition config.hpp:91
typename Conf::crvec crvec
Definition config.hpp:92
unsigned iterations
Total number of inner FISTA iterations.
Definition fista.hpp:176
Double-precision double configuration.
Definition config.hpp:176
Single-precision float configuration.
Definition config.hpp:172
long double configuration.
Definition config.hpp:181