alpaqa 0.0.1
Nonconvex constrained optimization
inner/decl/panoc.hpp
Go to the documentation of this file.
1#pragma once
2
11
12#include <atomic>
13#include <chrono>
14#include <limits>
15#include <string>
16
17namespace alpaqa {
18
19/// Tuning parameters for the PANOC algorithm.
21 /// Parameters related to the Lipschitz constant estimate and step size.
23 /// Maximum number of inner PANOC iterations.
24 unsigned max_iter = 100;
25 /// Maximum duration.
26 std::chrono::microseconds max_time = std::chrono::minutes(5);
27 /// Minimum weight factor between Newton step and projected gradient step.
28 real_t τ_min = 1. / 256;
29 /// Minimum Lipschitz constant estimate.
30 real_t L_min = 1e-5;
31 /// Maximum Lipschitz constant estimate.
32 real_t L_max = 1e20;
33 /// What stopping criterion to use.
35 /// Maximum number of iterations without any progress before giving up.
36 unsigned max_no_progress = 10;
37
38 /// When to print progress. If set to zero, nothing will be printed.
39 /// If set to N != 0, progress is printed every N iterations.
40 unsigned print_interval = 0;
41
43 10 * std::numeric_limits<real_t>::epsilon();
44
47
49};
50
51struct PANOCStats {
54 std::chrono::microseconds elapsed_time;
55 unsigned iterations = 0;
56 unsigned linesearch_failures = 0;
57 unsigned lbfgs_failures = 0;
58 unsigned lbfgs_rejected = 0;
59 unsigned τ_1_accepted = 0;
60 unsigned count_τ = 0;
62};
63
65 unsigned k;
83};
84
85/// PANOC solver for ALM.
86/// @ingroup grp_InnerSolvers
87template <class DirectionProviderT>
89 public:
91 using DirectionProvider = DirectionProviderT;
94
101
102 Stats operator()(const Problem &problem, // in
103 crvec Σ, // in
104 real_t ε, // in
105 bool always_overwrite_results, // in
106 rvec x, // inout
107 rvec y, // inout
108 rvec err_z); // out
109
111 set_progress_callback(std::function<void(const ProgressInfo &)> cb) {
112 this->progress_cb = cb;
113 return *this;
114 }
115
116 std::string get_name() const;
117
118 void stop() { stop_signal.stop(); }
119
120 const Params &get_params() const { return params; }
121
122 private:
125 std::function<void(const ProgressInfo &)> progress_cb;
126
127 public:
129};
130
131template <class InnerSolverStats>
133
134template <>
136 std::chrono::microseconds elapsed_time;
137 unsigned iterations = 0;
138 unsigned linesearch_failures = 0;
139 unsigned lbfgs_failures = 0;
140 unsigned lbfgs_rejected = 0;
141 unsigned τ_1_accepted = 0;
142 unsigned count_τ = 0;
143 real_t sum_τ = 0;
144};
145
148 acc.iterations += s.iterations;
149 acc.elapsed_time += s.elapsed_time;
154 acc.count_τ += s.count_τ;
155 acc.sum_τ += s.sum_τ;
156 return acc;
157}
158
159} // namespace alpaqa
PANOC solver for ALM.
std::string get_name() const
Definition: inner/panoc.hpp:19
std::function< void(const ProgressInfo &)> progress_cb
PANOCSolver & set_progress_callback(std::function< void(const ProgressInfo &)> cb)
DirectionProviderT DirectionProvider
AtomicStopSignal stop_signal
PANOCSolver(Params params, PANOCDirection< DirectionProvider > &&direction_provider)
const Params & get_params() const
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec y, rvec err_z)
Definition: inner/panoc.hpp:25
PANOCDirection< DirectionProvider > direction_provider
PANOCSolver(Params params, const PANOCDirection< DirectionProvider > &direction_provider)
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.
const PANOCParams & params
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.
real_t quadratic_upperbound_tolerance_factor
std::chrono::microseconds elapsed_time
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.
LBFGSStepSize lbfgs_stepsize
LBFGSStepSize
Which method to use to select the L-BFGS step size.
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 PANOC algorithm.
problem
Definition: main.py:16
def cb(it)
Definition: rosenbrock.py:56
Problem description for minimization problems.