alpaqa 0.0.1
Nonconvex constrained optimization
decl/second-order-panoc.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <atomic>
11#include <chrono>
12#include <limits>
13#include <string>
14
15namespace alpaqa {
16
17/// Tuning parameters for the second order PANOC algorithm.
19 /// Parameters related to the Lipschitz constant estimate and step size.
21 /// Maximum number of inner PANOC iterations.
22 unsigned max_iter = 100;
23 /// Maximum duration.
24 std::chrono::microseconds max_time = std::chrono::minutes(5);
25 /// Minimum weight factor between Newton step and projected gradient step.
26 real_t τ_min = 1. / 256;
27 /// Minimum Lipschitz constant estimate.
28 real_t L_min = 1e-5;
29 /// Maximum Lipschitz constant estimate.
30 real_t L_max = 1e20;
31 /// What stopping criterion to use.
33 /// Maximum number of iterations without any progress before giving up.
34 unsigned max_no_progress = 10;
35
36 /// When to print progress. If set to zero, nothing will be printed.
37 /// If set to N != 0, progress is printed every N iterations.
38 unsigned print_interval = 0;
39
41 10 * std::numeric_limits<real_t>::epsilon();
42
45};
46
47/// Second order PANOC solver for ALM.
48/// @ingroup grp_InnerSolvers
50 public:
52
53 struct Stats {
56 std::chrono::microseconds elapsed_time;
57 unsigned iterations = 0;
58 unsigned newton_failures = 0;
59 unsigned linesearch_failures = 0;
60 unsigned τ_1_accepted = 0;
61 unsigned count_τ = 0;
63 };
64
65 struct ProgressInfo {
66 unsigned k;
81 const Params &params;
82 };
83
85
86 Stats operator()(const Problem &problem, // in
87 crvec Σ, // in
88 real_t ε, // in
89 bool always_overwrite_results, // in
90 rvec x, // inout
91 rvec y, // inout
92 rvec err_z); // out
93
95 set_progress_callback(std::function<void(const ProgressInfo &)> cb) {
96 this->progress_cb = cb;
97 return *this;
98 }
99
100 std::string get_name() const { return "SecondOrderPANOCSolver"; }
101
102 void stop() { stop_signal.stop(); }
103
104 const Params &get_params() const { return params; }
105
106 private:
109 std::function<void(const ProgressInfo &)> progress_cb;
110};
111
112template <class InnerSolverStats>
114
115template <>
117 std::chrono::microseconds elapsed_time;
118 unsigned iterations = 0;
119 unsigned newton_failures = 0;
120 unsigned linesearch_failures = 0;
121 unsigned τ_1_accepted = 0;
122 unsigned count_τ = 0;
123 real_t sum_τ = 0;
124};
125
129 acc.elapsed_time += s.elapsed_time;
130 acc.iterations += s.iterations;
134 acc.count_τ += s.count_τ;
135 acc.sum_τ += s.sum_τ;
136 return acc;
137}
138
139} // namespace alpaqa
Second order PANOC solver for ALM.
std::function< void(const ProgressInfo &)> progress_cb
SecondOrderPANOCSolver & set_progress_callback(std::function< void(const ProgressInfo &)> cb)
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec y, rvec err_z)
int Σ
Definition: test.py:72
int ε
Definition: test.py:73
LipschitzEstimateParams Lipschitz
Parameters related to the Lipschitz constant estimate and step size.
InnerStatsAccumulator< PolymorphicInnerSolverWrapper::Stats > & operator+=(InnerStatsAccumulator< PolymorphicInnerSolverWrapper::Stats > &acc, const PolymorphicInnerSolverWrapper::Stats &s)
@ ApproxKKT
Find an ε-approximate KKT point in the ∞-norm:
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
constexpr real_t inf
Definition: vec.hpp:26
unsigned max_no_progress
Maximum number of iterations without any progress before giving up.
real_t L_max
Maximum Lipschitz constant estimate.
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
Definition: solverstatus.hpp:7
@ Unknown
Initial value.
std::chrono::microseconds max_time
Maximum duration.
double real_t
Default floating point type.
Definition: vec.hpp:8
unsigned print_interval
When to print progress.
real_t τ_min
Minimum weight factor between Newton step and projected gradient step.
real_t L_min
Minimum Lipschitz constant estimate.
unsigned max_iter
Maximum number of inner PANOC iterations.
PANOCStopCrit stop_crit
What stopping criterion to use.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16
Tuning parameters for the second order PANOC algorithm.
problem
Definition: main.py:16
def cb(it)
Definition: rosenbrock.py:56
Problem description for minimization problems.