PANOC-ALM main
Nonconvex constrained optimization
anderson-helpers.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace pa {
6
31 crvec rₖ₋₁, crvec gₖ, rvec γ_LS,
32 rvec xₖ_aa) {
33 // Update QR factorization for Anderson acceleration
34 if (qr.num_columns() == qr.m()) // if the history buffer is full
35 qr.remove_column();
36 qr.add_column(rₖ - rₖ₋₁);
37
38 // Solve least squares problem Anderson acceleration
39 // γ = argmin ‖ ΔR γ - rₖ ‖²
40 qr.solve_col(rₖ, γ_LS);
41
42 // Iterate over columns of G, whose indices match the indices of the matrix
43 // R in the QR factorization, stored as a circular buffer.
44 auto g_it = qr.ring_iter().begin();
45 auto g_end = qr.ring_iter().end();
46 assert(g_it != g_end);
47
48 // Compute Anderson acceleration next iterate yₑₓₜ = ∑ₙ₌₀ αₙ gₙ
49 // α₀ = γ₀ if n = 0
50 // αₙ = γₙ - γₙ₋₁ if 0 < n < mₖ
51 // αₘ = 1 - γₘ₋₁ if n = mₖ
52 real_t α = γ_LS(0);
53 xₖ_aa = α * G.col((*g_it).circular);
54 while (++g_it != g_end) {
55 auto [i, g_idx] = *g_it; // [zero based index, circular index]
56 α = γ_LS(i) - γ_LS(i - 1);
57 xₖ_aa += α * G.col(g_idx);
58 }
59 α = 1 - γ_LS(qr.num_columns() - 1);
60 xₖ_aa += α * gₖ;
61
62 // Add the new column to G
63 G.col(qr.ring_tail()) = gₖ; // TODO: avoid copy, make G an array of vectors
64}
65
66} // namespace pa
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 remove_column()
Remove the leftmost column.
void add_column(const VecV &v)
Add the given column to the right.
void solve_col(const VecB &b, VecX &x) const
Solve the least squares problem Ax = b.
size_t num_columns() const
Get the number of columns that are currently stored.
CircularRange< size_t > ring_iter() const
Get iterators in the circular buffer.
Definition: alm.hpp:9
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
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):
Eigen::Ref< mat > rmat
Default type for mutable references to matrices.
Definition: vec.hpp:22
double real_t
Default floating point type.
Definition: vec.hpp:8
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16