alpaqa pantr
Nonconvex constrained optimization
Loading...
Searching...
No Matches
lbfgspp/include/alpaqa/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>
20
22 real_t ε = inf<config_t>;
23 std::chrono::nanoseconds elapsed_time{};
24 unsigned iterations = 0;
26};
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::template make<P>(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
73#ifdef ALPAQA_WITH_QUAD_PRECISION
75#endif
76
81#ifdef ALPAQA_WITH_QUAD_PRECISION
83#endif
84
85} // namespace alpaqa::lbfgspp
86
87namespace alpaqa {
88
89template <class InnerSolverStats>
91
92template <Config Conf>
93struct InnerStatsAccumulator<lbfgspp::LBFGSBStats<Conf>> {
95
96 /// Total elapsed time in the inner solver.
97 std::chrono::nanoseconds elapsed_time{};
98 /// Total number of inner PANOC iterations.
99 unsigned iterations = 0;
100 /// Final value of the smooth cost @f$ \psi(\hat x) @f$.
101 real_t final_ψ = 0;
102};
103
104template <Config Conf>
108 acc.iterations += s.iterations;
109 acc.elapsed_time += s.elapsed_time;
110 acc.final_ψ = s.final_ψ;
111 return acc;
112}
113
114} // namespace alpaqa
std::string get_name() const
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)
#define USING_ALPAQA_CONFIG(Conf)
Definition: config.hpp:42
#define ALPAQA_LBFGSPP_EXPORT_EXTERN_TEMPLATE(...)
InnerStatsAccumulator< PANOCOCPStats< Conf > > & operator+=(InnerStatsAccumulator< PANOCOCPStats< Conf > > &acc, const PANOCOCPStats< Conf > &s)
Definition: panoc-ocp.hpp:255
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
@ Busy
In progress.
typename Conf::real_t real_t
Definition: config.hpp:51
typename Conf::rvec rvec
Definition: config.hpp:55
typename Conf::crvec crvec
Definition: config.hpp:56
unsigned iterations
Total number of inner PANOC iterations.
Definition: panoc-ocp.hpp:221
Double-precision double configuration.
Definition: config.hpp:115
Single-precision float configuration.
Definition: config.hpp:111
long double configuration.
Definition: config.hpp:120