36 err_z += Σ.asDiagonal().inverse() * y;
40 err_z -= Σ.asDiagonal().inverse() * y;
58 throw std::out_of_range(
"Invalid PANOCStopCrit");
77 auto err = (1 / γ) * pₖ + (grad_ψₖ - grad_̂ψₖ);
83 auto err = (1 / γ) * pₖ + (grad_ψₖ - grad_̂ψₖ);
102 return work_n2.norm();
108 return pₖ.norm() / γ;
115 auto n = 2 * (ŷₖ.size() + x̂ₖ.size());
125 std::max(s_max, (C_lagr_mult + D_lagr_mult) / s_n) / s_max;
132 std::fmax(
real_t(1), xₖ.norm());
136 throw std::out_of_range(
"Invalid PANOCStopCrit");
159 real_t rounding_tolerance,
192 real_t margin = (1 + std::abs(ψₖ)) * rounding_tolerance;
193 while (ψx̂ₖ - ψₖ > grad_ψₖᵀpₖ +
real_t(0.5) * Lₖ * norm_sq_pₖ + margin) {
194 if (not(Lₖ * 2 <= L_max))
203 grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
204 norm_sq_pₖ = pₖ.squaredNorm();
207 ψx̂ₖ = problem.
eval_ψ(x̂ₖ, y, Σ, ŷx̂ₖ);
215 template <
class ParamsT,
class DurationT>
218 const ParamsT ¶ms,
222 DurationT time_elapsed,
230 unsigned no_progress) {
232 auto max_time = params.max_time;
234 max_time = std::min(max_time, *opts.
max_time);
236 bool out_of_time = time_elapsed > max_time;
237 bool out_of_iter = iteration == params.max_iter;
239 bool not_finite = not std::isfinite(εₖ);
240 bool converged = εₖ <= tolerance;
241 bool max_no_progress = no_progress > params.max_no_progress;
277 real_t cbrt_ε = std::cbrt(std::numeric_limits<real_t>::epsilon());
278 real_t h = cbrt_ε * (1 + xₖ.norm());
281 problem.
eval_grad_ψ(xₖh, y, Σ, Hv, work_n2, work_m);
322 auto h = grad_ψ.unaryExpr([&](
real_t g) {
323 return g > 0 ? std::max(g * ε, δ) : std::min(g * ε, -δ);
328 problem.
eval_grad_ψ(work_x, y, Σ, work_grad_ψ, work_n,
332 real_t L = (work_grad_ψ - grad_ψ).norm() / norm_h;
333 return std::clamp(L, L_min, L_max);
366 auto h = (xₖ * ε).cwiseAbs().cwiseMax(δ);
370 problem.
eval_grad_ψ(work_n1, y, Σ, work_n2, work_n3,
373 problem.
eval_grad_ψ(xₖ, y, Σ, grad_ψ, work_n1, work_m);
376 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
377 return std::clamp(L, L_min, L_max);
bool stop_requested() const
real_t eval_prox_grad_step(real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
[Required] Function that computes a proximal gradient step.
real_t eval_ψ_grad_ψ(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
[Optional] Calculate both ψ(x) and its gradient ∇ψ(x).
length_t get_m() const
[Required] Number of constraints.
real_t eval_ψ(crvec x, crvec y, crvec Σ, rvec ŷ) const
[Optional] Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ.
void eval_g(crvec x, rvec gx) const
[Required] Function that evaluates the constraints,
void eval_proj_diff_g(crvec z, rvec e) const
[Required] Function that evaluates the difference between the given point and its projection onto th...
void eval_grad_ψ(crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
[Optional] Calculate the gradient ∇ψ(x).
#define USING_ALPAQA_CONFIG(Conf)
#define ALPAQA_IF_QUADF(...)
#define ALPAQA_IF_LONGD(...)
#define ALPAQA_IF_FLOAT(...)
#define ALPAQA_EXPORT_EXTERN_TEMPLATE(...)
auto norm_inf(const Eigen::MatrixBase< Derived > &v)
Get the maximum or infinity-norm of the given vector.
auto norm_1(const Eigen::MatrixBase< Derived > &v)
Get the 1-norm of the given vector.
@ LBFGSBpp
The stopping criterion used by LBFGS++, see https://lbfgspp.statr.me/doc/classLBFGSpp_1_1LBFGSBParam....
@ ProjGradUnitNorm
∞-norm of the projected gradient with unit step size:
@ ProjGradNorm
∞-norm of the projected gradient with step size γ:
@ Ipopt
The stopping criterion used by Ipopt, see https://link.springer.com/article/10.1007/s10107-004-0559-y...
@ FPRNorm2
2-norm of fixed point residual:
@ ProjGradNorm2
2-norm of the projected gradient with step size γ:
@ ApproxKKT
Find an ε-approximate KKT point in the ∞-norm:
@ FPRNorm
∞-norm of fixed point residual:
@ ApproxKKT2
Find an ε-approximate KKT point in the 2-norm:
@ ProjGradUnitNorm2
2-norm of the projected gradient with unit step size:
std::optional< std::chrono::nanoseconds > max_time
Maximum run time (in addition to the inner solver's own timeout).
real_t tolerance
Desired tolerance (overrides the solver's own tolerance).
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.
typename Conf::real_t real_t
typename Conf::crvec crvec
Double-precision double configuration.
Single-precision float configuration.
long double configuration.
static SolverStatus check_all_stop_conditions(const ParamsT ¶ms, const InnerSolveOptions< config_t > &opts, DurationT time_elapsed, unsigned iteration, const AtomicStopSignal &stop_signal, real_t εₖ, unsigned no_progress)
Check all stop conditions (required tolerance reached, out of time, maximum number of iterations exce...
static 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 ...
static bool stop_crit_requires_grad_ψx̂(PANOCStopCrit crit)
static 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_x, rvec work_grad_ψ, rvec work_n, rvec work_m)
Estimate the Lipschitz constant of the gradient using finite differences.
static real_t calc_error_stop_crit(const Problem &problem, PANOCStopCrit crit, crvec pₖ, real_t γ, crvec xₖ, crvec x̂ₖ, crvec ŷₖ, crvec grad_ψₖ, crvec grad_̂ψₖ, rvec work_n1, rvec work_n2)
Compute the ε from the stopping criterion, see PANOCStopCrit.
static 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, rvec grad_ψ, rvec work_n1, rvec work_n2, rvec work_n3, rvec work_m)
Estimate the Lipschitz constant of the gradient using finite differences.
static void calc_err_z(const Problem &p, crvec x̂, crvec y, crvec Σ, rvec err_z)
Calculate the error between ẑ and g(x).
static void calc_augmented_lagrangian_hessian_prod_fd(const Problem &problem, crvec xₖ, crvec y, crvec Σ, crvec grad_ψ, crvec v, rvec Hv, rvec work_n1, rvec work_n2, rvec work_m)
Compute the Hessian matrix of the augmented Lagrangian function multiplied by the given vector,...