|
PANOC-ALM
quadratic-penalty
Nonconvex constrained optimization
|
Go to the documentation of this file.
15 using std::chrono::duration_cast;
16 using std::chrono::microseconds;
26 bool always_overwrite_results,
34 auto start_time = std::chrono::steady_clock::now();
58 vec work_n(
n), work_m(
m);
63 using indexvec = std::vector<vec::Index>;
69 unsigned no_progress = 0;
98 xₖ, ψₖ, grad_ψₖ,
y,
Σ, x̂ₖ, pₖ, ŷx̂ₖ, ψx̂ₖ, pₖᵀpₖ, grad_ψₖᵀpₖ, Lₖ, γₖ);
102 std::cout <<
"[PANOC] " << std::setw(6) << k
103 <<
": ψ = " << std::setw(13) << ψₖ
104 <<
", ‖∇ψ‖ = " << std::setw(13) << grad_ψₖ.norm()
105 <<
", ‖p‖ = " << std::setw(13) << std::sqrt(pₖᵀpₖ)
106 <<
", γ = " << std::setw(13) << γₖ
107 <<
", εₖ = " << std::setw(13) << εₖ <<
"\r\n";
118 ψₖ, grad_ψₖ, x̂ₖ, grad_̂ψₖ, work_n, work_m);
126 if (not std::isfinite(Lₖ)) {
127 s.
status = SolverStatus::NotFinite;
136 calc_x̂(γₖ, xₖ, grad_ψₖ, x̂ₖ, pₖ);
139 real_t grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
140 real_t pₖᵀpₖ = pₖ.squaredNorm();
142 real_t φₖ = ψₖ + 1 / (2 * γₖ) * pₖᵀpₖ + grad_ψₖᵀpₖ;
155 ψx̂ₖ, pₖᵀpₖ, grad_ψₖᵀpₖ, Lₖ, γₖ);
157 φₖ = ψₖ + 1 / (2 * γₖ) * pₖᵀpₖ + grad_ψₖᵀpₖ;
170 progress_cb({k, xₖ, pₖ, pₖᵀpₖ, x̂ₖ, φₖ, ψₖ, grad_ψₖ, ψx̂ₖ, grad_̂ψₖ,
173 auto time_elapsed = std::chrono::steady_clock::now() - start_time;
176 if (stop_status != SolverStatus::Unknown) {
181 if (stop_status == SolverStatus::Converged ||
183 always_overwrite_results) {
190 s.
elapsed_time = duration_cast<microseconds>(time_elapsed);
200 for (vec::Index i = 0; i <
n; ++i) {
201 real_t gd = xₖ(i) - γₖ * grad_ψₖ(i);
202 if (gd <
problem.C.lowerbound(i)) {
204 }
else if (
problem.C.upperbound(i) < gd) {
218 problem, xₖ,
y,
Σ, grad_ψₖ, qₖ, HqK, work_n,
221 problem.hess_L_prod(xₖ,
y, qₖ, HqK);
225 for (vec::Index i = 0; i <
m; ++i) {
227 bool inactive =
problem.D.lowerbound(i) < ζ &&
230 problem.grad_gi(xₖ, i, work_n);
231 auto t =
Σ(i) * work_n.dot(qₖ);
235 HqK(j) += work_n(j) *
t;
242 qₖ(j) = -grad_ψₖ(j) - HqK(j);
246 LBFGSStepSize::BasedOnGradientStepSize
270 real_t σₖγₖ⁻¹pₖᵀpₖ = (1 - γₖ * Lₖ) * pₖᵀpₖ / (2 * γₖ);
271 real_t φₖ₊₁, ψₖ₊₁, ψx̂ₖ₊₁, grad_ψₖ₊₁ᵀpₖ₊₁, pₖ₊₁ᵀpₖ₊₁;
275 nmΦₖ = k == 0 ? φₖ :
w * nmΦₖ + (1 -
w) * φₖ;
283 }
else if (not qₖ.allFinite()) {
286 }
else if (J.empty()) {
299 grad_ψₖ₊₁.swap(grad_̂ψₖ);
304 xₖ₊₁ = xₖ + (1 - τ) * pₖ + τ * qₖ;
310 calc_x̂(γₖ₊₁, xₖ₊₁, grad_ψₖ₊₁, x̂ₖ₊₁, pₖ₊₁);
315 grad_ψₖ₊₁ᵀpₖ₊₁ = grad_ψₖ₊₁.dot(pₖ₊₁);
316 pₖ₊₁ᵀpₖ₊₁ = pₖ₊₁.squaredNorm();
317 real_t pₖ₊₁ᵀpₖ₊₁_ₖ = pₖ₊₁ᵀpₖ₊₁;
324 grad_ψₖ₊₁ᵀpₖ₊₁, Lₖ₊₁, γₖ₊₁);
328 φₖ₊₁ = ψₖ₊₁ + 1 / (2 * γₖ₊₁) * pₖ₊₁ᵀpₖ₊₁ + grad_ψₖ₊₁ᵀpₖ₊₁;
330 ls_cond = φₖ₊₁ - (nmΦₖ - σₖγₖ⁻¹pₖᵀpₖ);
332 ls_cond -= (0.5 / γₖ₊₁ - 0.5 / γₖ) * pₖ₊₁ᵀpₖ₊₁_ₖ;
351 no_progress = xₖ == xₖ₊₁ ? no_progress + 1 : 0;
354 const bool force =
true;
370 grad_ψₖ.swap(grad_ψₖ₊₁);
371 grad_ψₖᵀpₖ = grad_ψₖ₊₁ᵀpₖ₊₁;
374 throw std::logic_error(
"[PANOC] loop error");
void print_progress(unsigned k, real_t ψₖ, crvec grad_ψₖ, real_t pₖᵀpₖ, real_t γₖ, real_t εₖ)
void calc_x̂(const ProblemT &prob, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec y, rvec err_z)
real_t L_min
Minimum Lipschitz constant estimate.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
bool hessian_vec_finited_differences
constexpr real_t NaN
Not a number.
std::chrono::microseconds elapsed_time
realvec vec
Default type for vectors.
bool full_augmented_hessian
real_t L₀
Initial estimate of the Lipschitz constant of ∇ψ(x)
real_t nonmonotone_linesearch
Factor used in update for exponentially weighted nonmonotone line search.
unsigned print_interval
When to print progress.
real_t quadratic_upperbound_tolerance_factor
real_t τ_min
Minimum weight factor between Newton step and projected gradient step.
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).
LBFGSStepSize lbfgs_stepsize
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 ∇ψ.
bool update(crvec xₖ, crvec xₖ₊₁, crvec pₖ, crvec pₖ₊₁, Sign sign, bool forced=false)
Update the inverse Hessian approximation using the new vectors xₖ₊₁ and pₖ₊₁.
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 ε
Relative step size for initial finite difference Lipschitz estimate.
unsigned linesearch_failures
void resize(size_t n)
Re-allocate storage for a problem with a different size.
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.
AtomicStopSignal stop_signal
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,...
PANOCStopCrit stop_crit
What stopping criterion to use.
std::function< void(const ProgressInfo &)> progress_cb
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.
unsigned max_no_progress
Maximum number of iterations without any progress before giving up.
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.
bool apply(Vec &&q, real_t γ)
Apply the inverse Hessian approximation to the given vector q.
double real_t
Default floating point type.
unsigned max_iter
Maximum number of inner PANOC iterations.
Problem description for minimization problems.
bool update_lipschitz_in_linesearch
bool alternative_linesearch_cond