|
PANOC-ALM
quadratic-penalty
Nonconvex constrained optimization
|
Go to the documentation of this file.
25 ŷ +=
Σ.asDiagonal().inverse() *
y;
30 for (
unsigned i = 0; i <
p.m; ++i) {
31 dᵀŷ += ŷ(i) *
Σ(i) * ŷ(i);
55 ŷ1 += Σ1.asDiagonal().inverse() *
y;
60 for (
unsigned i = 0; i <
p.m1; ++i) {
61 dᵀŷ1 += ŷ1(i) * Σ1(i) * ŷ1(i);
62 ŷ1(i) = Σ1(i) * ŷ1(i);
70 for (
unsigned i = 0; i <
p.m2; ++i) {
71 dᵀŷ2 += ŷ2(i) * Σ2(i) * ŷ2(i);
72 ŷ2(i) = Σ2(i) * ŷ2(i);
75 real_t ψ =
p.f(
x) + 0.5 * dᵀŷ1 + 0.5 * dᵀŷ2;
89 p.grad_g_prod(
x, ŷ, work_n);
103 p.grad_g1_prod(
x, ŷ1, work_n);
105 p.grad_g2_prod(
x, ŷ2, work_n);
162 work_m += (
y.array() /
Σ.array()).matrix();
166 work_m =
Σ.asDiagonal() * work_m;
170 p.grad_g_prod(
x, work_m, work_n);
189 work_m1 += (
y.array() / Σ1.array()).matrix();
193 work_m1 = Σ1.asDiagonal() * work_m1;
200 work_m2 = Σ2.asDiagonal() * work_m2;
204 p.grad_g1_prod(
x, work_m1, work_n);
206 p.grad_g2_prod(
x, work_m2, work_n);
241 err_z1 = err_z1 -
project(err_z1 + Σ1.asDiagonal().inverse() *
y,
p.D1);
247 err_z2 = err_z2 -
project(err_z2,
p.D2);
266 .binaryExpr(
C.lowerbound -
x, binary_real_f(std::fmax))
267 .binaryExpr(
C.upperbound -
x, binary_real_f(std::fmin));
270 template <
typename ProblemT>
294 case PANOCStopCrit::ApproxKKT: {
295 auto err = (1 / γ) * pₖ + (grad_ψₖ - grad_̂ψₖ);
301 case PANOCStopCrit::ProjGradUnitNorm: {
305 case PANOCStopCrit::ProjGradNorm: {
312 throw std::out_of_range(
"Invalid PANOCStopCrit");
335 real_t rounding_tolerance,
368 real_t margin = (1 + std::abs(ψₖ)) * rounding_tolerance;
369 while (ψx̂ₖ - ψₖ > grad_ψₖᵀpₖ + 0.5 * Lₖ * norm_sq_pₖ + margin) {
370 if (not(Lₖ * 2 <= L_max))
379 grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
380 norm_sq_pₖ = pₖ.squaredNorm();
408 real_t rounding_tolerance,
445 real_t margin = (1 + std::abs(ψₖ)) * rounding_tolerance;
446 while (ψx̂ₖ - ψₖ > grad_ψₖᵀpₖ + 0.5 * Lₖ * norm_sq_pₖ + margin) {
447 if (not(Lₖ * 2 <= L_max))
456 grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
457 norm_sq_pₖ = pₖ.squaredNorm();
468 template <
class ParamsT,
class DurationT>
473 DurationT time_elapsed,
483 unsigned no_progress) {
485 bool out_of_time = time_elapsed >
params.max_time;
486 bool out_of_iter = iteration ==
params.max_iter;
488 bool not_finite = not std::isfinite(εₖ);
490 bool max_no_progress = no_progress >
params.max_no_progress;
491 return conv ? SolverStatus::Converged
492 : out_of_time ? SolverStatus::MaxTime
493 : out_of_iter ? SolverStatus::MaxIter
494 : not_finite ? SolverStatus::NotFinite
495 : max_no_progress ? SolverStatus::NoProgress
497 : SolverStatus::Unknown;
526 for (vec::Index i = 0; i <
problem.m; ++i) {
531 problem.grad_gi(xₖ, i, work_n);
532 H += work_n *
Σ(i) * work_n.transpose();
563 real_t cbrt_ε = std::cbrt(std::numeric_limits<real_t>::epsilon());
564 real_t h = cbrt_ε * (1 + xₖ.norm());
604 auto h = (xₖ *
ε).cwiseAbs().cwiseMax(δ);
615 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
616 return std::clamp(
L, L_min, L_max);
649 auto h = (xₖ *
ε).cwiseAbs().cwiseMax(δ);
659 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
660 return std::clamp(
L, L_min, L_max);
693 auto h = (xₖ *
ε).cwiseAbs().cwiseMax(δ);
704 real_t L = (work_n2 - grad_ψ).norm() / norm_h;
705 if (
L < std::numeric_limits<real_t>::epsilon())
706 L = std::numeric_limits<real_t>::epsilon();
void calc_x̂(const ProblemT &prob, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
bool stop_requested() const
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
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 project(const Vec &v, const Box &box)
Project a vector onto a box.
auto projected_gradient_step(const Box &C, real_t γ, crvec x, crvec grad_ψ)
Projected gradient step.
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_grad_ψ(const Problem &p, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)
Calculate the gradient ∇ψ(x).
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 ∇ψ.
void calc_err_z(const Problem &p, crvec x̂, crvec y, crvec Σ, rvec err_z)
Calculate the error between ẑ and g(x).
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.
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,...
realmat mat
Default type for matrices.
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.
real_t norm_inf(const Vec &v)
Get the maximum or infinity-norm of the given vector.
auto projecting_difference(const Vec &v, const Box &box)
Get the difference between the given vector and its projection.
void calc_grad_ψ_from_ŷ(const Problem &p, crvec x, crvec ŷ, rvec grad_ψ, rvec work_n)
Calculate ∇ψ(x) using ŷ.
Problem description for minimization problems.
@ ApproxKKT
Find a ε-approximate KKT point.
double real_t
Default floating point type.
Problem description for minimization problems.