|
PANOC-ALM
quadratic-penalty
Nonconvex constrained optimization
|
Go to the documentation of this file.
24 std::chrono::microseconds
max_time = std::chrono::minutes(5);
37 10 * std::numeric_limits<real_t>::epsilon();
80 bool always_overwrite_results,
103 using std::chrono::duration_cast;
104 using 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ₖ)) {
186 s.
status = SolverStatus::NotFinite;
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ₖ,
221 grad_ψx̂ₖ, grad_ψₖ,
problem.C);
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);
252 s.
status = conv ? SolverStatus::Converged
253 : out_of_time ? SolverStatus::MaxTime
254 : out_of_iter ? SolverStatus::MaxIter
255 : not_finite ? SolverStatus::NotFinite
256 : max_no_progress ? SolverStatus::NoProgress
267 grad_ψₖ.swap(grad_ψx̂ₖ);
270 throw std::logic_error(
"[PGA] loop error");
273 template <
class InnerSolverStats>
279 unsigned iterations = 0;
void print_progress(unsigned k, real_t ψₖ, crvec grad_ψₖ, real_t pₖᵀpₖ, real_t γₖ, real_t εₖ)
std::string get_name() const
void calc_x̂(const ProblemT &prob, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
bool stop_requested() const
real_t L_min
Minimum Lipschitz constant estimate.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec λ, rvec err_z)
realvec vec
Default type for vectors.
real_t L₀
Initial estimate of the Lipschitz constant of ∇ψ(x)
PGASolver & set_progress_callback(std::function< void(const ProgressInfo &)> cb)
unsigned print_interval
When to print progress.
real_t quadratic_upperbound_tolerance_factor
InnerStatsAccumulator< PANOCStats > & operator+=(InnerStatsAccumulator< PANOCStats > &acc, const PANOCStats &s)
real_t L_max
Maximum Lipschitz constant estimate.
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).
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 ∇ψ.
const Params & get_params() const
void calc_err_z(const Problem &p, crvec x̂, crvec y, crvec Σ, rvec err_z)
Calculate the error between ẑ and g(x).
std::chrono::microseconds max_time
Maximum duration.
real_t calc_error_stop_crit(PANOCStopCrit crit, crvec pₖ, real_t γ, crvec xₖ, crvec grad_̂ψₖ, crvec grad_ψₖ, const Box &C)
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 ...
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
LipschitzEstimateParams Lipschitz
Parameters related to the Lipschitz constant estimate and step size.
real_t δ
Minimum step size for initial finite difference Lipschitz estimate.
std::function< void(const ProgressInfo &)> progress_cb
std::chrono::microseconds elapsed_time
Standard Proximal Gradient Algorithm without any bells and whistles.
AtomicStopSignal stop_signal
PANOCStopCrit stop_crit
What stop criterion to use.
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 ŷ.
real_t Lγ_factor
Factor that relates step size γ and Lipschitz constant.
std::chrono::microseconds elapsed_time
double real_t
Default floating point type.
unsigned max_iter
Maximum number of inner iterations.
PGASolver(const Params ¶ms)
Problem description for minimization problems.