28 ŷ +=
Σ.asDiagonal().inverse() *
y;
33 for (
unsigned i = 0; i <
p.m; ++i) {
34 dᵀŷ += ŷ(i) *
Σ(i) * ŷ(i);
53 p.grad_g_prod(
x, ŷ, work_n);
88 return p.grad_f(
x, grad_ψ);
93 work_m += (
y.array() /
Σ.array()).matrix();
97 work_m =
Σ.asDiagonal() * work_m;
101 p.grad_g_prod(
x, work_m, work_n);
138 .binaryExpr(
C.lowerbound -
x, binary_real_f(std::fmax))
139 .binaryExpr(
C.upperbound -
x, binary_real_f(std::fmin));
165 throw std::out_of_range(
"Invalid PANOCStopCrit");
182 auto err = (1 / γ) * pₖ + (grad_ψₖ - grad_̂ψₖ);
188 auto err = (1 / γ) * pₖ + (grad_ψₖ - grad_̂ψₖ);
210 return pₖ.norm() / γ;
215 auto n = 2 * (ŷₖ.size() + x̂ₖ.size());
223 std::max(s_max, (C_lagr_mult + D_lagr_mult) /
n) / s_max;
227 throw std::out_of_range(
"Invalid PANOCStopCrit");
250 real_t rounding_tolerance,
283 real_t margin = (1 + std::abs(ψₖ)) * rounding_tolerance;
284 while (ψx̂ₖ - ψₖ > grad_ψₖᵀpₖ + 0.5 * Lₖ * norm_sq_pₖ + margin) {
285 if (not(Lₖ * 2 <= L_max))
294 grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
295 norm_sq_pₖ = pₖ.squaredNorm();
306template <
class ParamsT,
class DurationT>
311 DurationT time_elapsed,
321 unsigned no_progress) {
323 bool out_of_time = time_elapsed >
params.max_time;
324 bool out_of_iter = iteration ==
params.max_iter;
326 bool not_finite = not std::isfinite(εₖ);
328 bool max_no_progress = no_progress >
params.max_no_progress;
364 for (vec::Index i = 0; i <
problem.m; ++i) {
369 problem.grad_gi(xₖ, i, work_n);
370 H += work_n *
Σ(i) * work_n.transpose();
401 real_t cbrt_ε = std::cbrt(std::numeric_limits<real_t>::epsilon());
402 real_t h = cbrt_ε * (1 + xₖ.norm());
442 auto h = (xₖ *
ε).cwiseAbs().cwiseMax(δ);
453 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
454 return std::clamp(
L, L_min, L_max);
487 auto h = (xₖ *
ε).cwiseAbs().cwiseMax(δ);
497 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
498 return std::clamp(
L, L_min, L_max);
bool stop_requested() const
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.
SolverStatus check_all_stop_conditions(const ParamsT ¶ms, DurationT time_elapsed, unsigned iteration, const AtomicStopSignal &stop_signal, real_t ε, real_t εₖ, unsigned no_progress)
Check all stop conditions (required tolerance reached, out of time, maximum number of iterations exce...
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 ...
void calc_augmented_lagrangian_hessian(const Problem &problem, crvec xₖ, crvec ŷxₖ, crvec y, crvec Σ, rvec g, mat &H, rvec work_n)
Compute the Hessian matrix of the augmented Lagrangian function.
auto projected_gradient_step(const Box &C, real_t γ, crvec x, crvec grad_ψ)
Projected gradient step.
bool stop_crit_requires_grad_̂ψₖ(PANOCStopCrit crit)
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_ψ(const Problem &p, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)
Calculate the gradient ∇ψ(x).
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,...
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)
real_t norm_1(const Vec &v)
Get the 1-norm of the given vector.
real_t norm_inf(const Vec &v)
Get the maximum or infinity-norm of the given vector.
@ 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:
auto project(const Vec &v, const Box &box)
Project a vector onto a box.
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
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.
realmat mat
Default type for matrices.
double real_t
Default floating point type.
auto projecting_difference(const Vec &v, const Box &box)
Get the difference between the given vector and its projection.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Problem description for minimization problems.