24 std::chrono::microseconds
max_time = std::chrono::minutes(5);
37 10 * std::numeric_limits<real_t>::epsilon();
80 bool always_overwrite_results,
103using std::chrono::duration_cast;
104using std::chrono::microseconds;
110 bool always_overwrite_results,
115 auto start_time = std::chrono::steady_clock::now();
128 vec work_n(
n), work_m(
m);
157 xₖ, ψₖ, grad_ψₖ,
y,
Σ, x̂ₖ, pₖ, ŷx̂ₖ, ψx̂ₖ, pₖᵀpₖ, grad_ψₖᵀpₖ, Lₖ, γₖ);
161 std::cout <<
"[PGA] " << std::setw(6) << k
162 <<
": ψ = " << std::setw(13) << ψₖ
163 <<
", ‖∇ψ‖ = " << std::setw(13) << grad_ψₖ.norm()
164 <<
", ‖p‖ = " << std::setw(13) << pₖ.norm()
165 <<
", γ = " << std::setw(13) << γₖ
166 <<
", εₖ = " << std::setw(13) << εₖ <<
"\r\n";
177 ψₖ, grad_ψₖ, x̂ₖ, grad_ψx̂ₖ, work_n, work_m);
185 if (not std::isfinite(Lₖ)) {
191 unsigned no_progress = 0;
204 calc_x̂(γₖ, xₖ, grad_ψₖ, x̂ₖ, pₖ);
208 real_t grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
209 real_t pₖᵀpₖ = pₖ.squaredNorm();
212 descent_lemma(xₖ, ψₖ, grad_ψₖ, x̂ₖ, pₖ, ŷₖ, ψx̂ₖ, pₖᵀpₖ, grad_ψₖᵀpₖ, Lₖ,
227 progress_cb({k, xₖ, pₖ, pₖᵀpₖ, x̂ₖ, ψₖ, grad_ψₖ, ψx̂ₖ, grad_ψx̂ₖ, Lₖ,
230 auto time_elapsed = std::chrono::steady_clock::now() - start_time;
234 bool not_finite = not std::isfinite(εₖ);
236 bool max_no_progress = no_progress > 1;
237 bool exit = conv || out_of_iter || out_of_time || not_finite ||
238 interrupted || max_no_progress;
244 if (conv || interrupted || always_overwrite_results) {
251 s.
elapsed_time = duration_cast<microseconds>(time_elapsed);
267 grad_ψₖ.swap(grad_ψx̂ₖ);
270 throw std::logic_error(
"[PGA] loop error");
273template <
class InnerSolverStats>
279 unsigned iterations = 0;
bool stop_requested() const
Standard Proximal Gradient Algorithm without any bells and whistles.
std::string get_name() const
std::function< void(const ProgressInfo &)> progress_cb
PGASolver & set_progress_callback(std::function< void(const ProgressInfo &)> cb)
AtomicStopSignal stop_signal
const Params & get_params() const
std::chrono::microseconds elapsed_time
PGASolver(const Params ¶ms)
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec λ, rvec err_z)
real_t calc_error_stop_crit(const Box &C, PANOCStopCrit crit, crvec pₖ, real_t γ, crvec xₖ, crvec x̂ₖ, crvec ŷₖ, crvec grad_ψₖ, crvec grad_̂ψₖ)
Compute the ε from the stopping criterion, see PANOCStopCrit.
real_t calc_ψ_ŷ(const Problem &p, crvec x, crvec y, crvec Σ, rvec ŷ)
Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ.
real_t descent_lemma(const Problem &problem, real_t rounding_tolerance, real_t L_max, crvec xₖ, real_t ψₖ, crvec grad_ψₖ, crvec y, crvec Σ, rvec x̂ₖ, rvec pₖ, rvec ŷx̂ₖ, real_t &ψx̂ₖ, real_t &norm_sq_pₖ, real_t &grad_ψₖᵀpₖ, real_t &Lₖ, real_t &γₖ)
Increase the estimate of the Lipschitz constant of the objective gradient and decrease the step size ...
real_t calc_ψ_grad_ψ(const Problem &p, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)
Calculate both ψ(x) and its gradient ∇ψ(x).
void calc_err_z(const Problem &p, crvec x̂, crvec y, crvec Σ, rvec err_z)
Calculate the error between ẑ and g(x).
real_t initial_lipschitz_estimate(const Problem &problem, crvec xₖ, crvec y, crvec Σ, real_t ε, real_t δ, real_t L_min, real_t L_max, real_t &ψ, rvec grad_ψ, rvec work_n1, rvec work_n2, rvec work_n3, rvec work_m)
Estimate the Lipschitz constant of the gradient using finite differences.
void calc_grad_ψ_from_ŷ(const Problem &p, crvec x, crvec ŷ, rvec grad_ψ, rvec work_n)
Calculate ∇ψ(x) using ŷ.
void calc_x̂(const Problem &prob, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
void print_progress(unsigned k, real_t ψₖ, crvec grad_ψₖ, real_t pₖᵀpₖ, real_t γₖ, real_t εₖ)
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:
real_t Lγ_factor
Factor that relates step size γ and Lipschitz constant.
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
real_t δ
Minimum step size for initial finite difference Lipschitz estimate.
real_t L_max
Maximum Lipschitz constant estimate.
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
@ Interrupted
Solver was interrupted by the user.
@ MaxTime
Maximum allowed execution time exceeded.
@ NoProgress
No progress was made in the last iteration.
@ MaxIter
Maximum number of iterations exceeded.
@ Converged
Converged and reached given tolerance.
@ NotFinite
Intermediate results were infinite or not-a-number.
std::chrono::microseconds max_time
Maximum duration.
realvec vec
Default type for vectors.
real_t L₀
Initial estimate of the Lipschitz constant of ∇ψ(x)
real_t quadratic_upperbound_tolerance_factor
std::chrono::microseconds elapsed_time
double real_t
Default floating point type.
unsigned print_interval
When to print progress.
real_t L_min
Minimum Lipschitz constant estimate.
unsigned max_iter
Maximum number of inner iterations.
PANOCStopCrit stop_crit
What stop criterion to use.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Problem description for minimization problems.