27 std::chrono::microseconds
max_time = std::chrono::minutes(5);
40 10 * std::numeric_limits<real_t>::epsilon();
91 bool always_overwrite_results,
114using std::chrono::duration_cast;
115using std::chrono::microseconds;
121 bool always_overwrite_results,
126 auto start_time = std::chrono::steady_clock::now();
143 vec work_n(
n), work_n2(
n), work_m(
m);
177 xₖ, ψₖ, grad_ψₖ,
y,
Σ, x̂ₖ, pₖ, ŷx̂ₖ, ψx̂ₖ, pₖᵀpₖ, grad_ψₖᵀpₖ, Lₖ, γₖ);
181 std::cout <<
"[AAPGA] " << std::setw(6) << k
182 <<
": ψ = " << std::setw(13) << ψₖ
183 <<
", ‖∇ψ‖ = " << std::setw(13) << grad_ψₖ.norm()
184 <<
", ‖p‖ = " << std::setw(13) << pₖ.norm()
185 <<
", γ = " << std::setw(13) << γₖ
186 <<
", εₖ = " << std::setw(13) << εₖ <<
"\r\n";
197 grad_ψₖ, x̂ₖ, work_n2, work_n, work_m);
205 if (not std::isfinite(Lₖ)) {
214 rₖ₋₁ = -γₖ * grad_ψₖ;
219 unsigned no_progress = 0;
239 calc_x̂(γₖ, xₖ, grad_ψₖ, x̂ₖ, pₖ);
243 real_t grad_ψₖᵀpₖ = grad_ψₖ.dot(pₖ);
244 real_t pₖᵀpₖ = pₖ.squaredNorm();
254 if (newest_g_idx != 0)
255 G.col(0) = G.col(newest_g_idx);
280 progress_cb({k, xₖ, pₖ, pₖᵀpₖ, x̂ₖ, ψₖ, grad_ψₖ, ψx̂ₖ, grad_ψx̂ₖ, Lₖ,
283 auto time_elapsed = std::chrono::steady_clock::now() - start_time;
293 always_overwrite_results) {
300 s.
elapsed_time = duration_cast<microseconds>(time_elapsed);
306 gₖ = xₖ - γₖ * grad_ψₖ;
320 bool sufficient_decrease;
322 sufficient_decrease = ψₖ₊₁ <= ψₖ - 0.5 * γₖ * grad_ψₖ.squaredNorm();
324 sufficient_decrease = ψₖ₊₁ <= ψx̂ₖ;
326 if (sufficient_decrease) {
337 grad_ψₖ.swap(grad_ψx̂ₖ);
345 no_progress = (ψₖ == old_ψ) ? no_progress + 1 : 0;
347 throw std::logic_error(
"[AAPGA] loop error");
350template <
class InnerSolverStats>
356 unsigned iterations = 0;
357 unsigned accelerated_steps_accepted = 0;
Guarded Anderson Accelerated Proximal Gradient Algorithm.
std::string get_name() const
GAAPGASolver & set_progress_callback(std::function< void(const ProgressInfo &)> cb)
std::function< void(const ProgressInfo &)> progress_cb
Stats operator()(const Problem &problem, crvec Σ, real_t ε, bool always_overwrite_results, rvec x, rvec λ, rvec err_z)
AtomicStopSignal stop_signal
GAAPGASolver(const Params ¶ms)
const Params & get_params() const
std::chrono::microseconds elapsed_time
unsigned accelerated_steps_accepted
Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.
size_t ring_tail() const
Get the tail index of the circular buffer (points to one past the most recent element).
void reset()
Reset all indices, clearing the Q and R matrices.
void scale_R(real_t scal)
Multiply the matrix R by a scalar.
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 ...
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_ψ_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)
void print_progress(unsigned k, real_t ψₖ, crvec grad_ψₖ, real_t pₖᵀpₖ, real_t γₖ, real_t εₖ)
LipschitzEstimateParams Lipschitz
Parameters related to the Lipschitz constant estimate and step size.
InnerStatsAccumulator< PolymorphicInnerSolverWrapper::Stats > & operator+=(InnerStatsAccumulator< PolymorphicInnerSolverWrapper::Stats > &acc, const PolymorphicInnerSolverWrapper::Stats &s)
@ ApproxKKT
Find an ε-approximate KKT point in the ∞-norm:
void minimize_update_anderson(LimitedMemoryQR &qr, rmat G, crvec rₖ, crvec rₖ₋₁, crvec gₖ, rvec γ_LS, rvec xₖ_aa)
Solve one step of Anderson acceleration to find a fixed point of a function g(x):
real_t Lγ_factor
Factor that relates step size γ and Lipschitz constant.
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.
unsigned limitedqr_mem
Length of the history to keep in the limited-memory QR algorithm.
real_t δ
Minimum step size for initial finite difference Lipschitz estimate.
unsigned max_no_progress
Maximum number of iterations without any progress before giving up.
real_t L_max
Maximum Lipschitz constant estimate.
SolverStatus
Exit status of a numerical solver such as ALM or PANOC.
@ Interrupted
Solver was interrupted by the user.
@ Converged
Converged and reached given tolerance.
@ NotFinite
Intermediate results were infinite or not-a-number.
std::chrono::microseconds max_time
Maximum duration.
realmat mat
Default type for matrices.
realvec vec
Default type for vectors.
bool full_flush_on_γ_change
real_t L₀
Initial estimate of the Lipschitz constant of ∇ψ(x)
const GAAPGAParams & params
real_t quadratic_upperbound_tolerance_factor
std::chrono::microseconds elapsed_time
double real_t
Default floating point type.
unsigned print_interval
When to print progress.
unsigned accelerated_steps_accepted
real_t L_min
Minimum Lipschitz constant estimate.
unsigned max_iter
Maximum number of inner iterations.
PANOCStopCrit stop_crit
What stopping criterion to use.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Problem description for minimization problems.