PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
anderson-helpers.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace 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
pa::LimitedMemoryQR::m
size_t m() const
Definition: limited-memory-qr.hpp:28
pa::LimitedMemoryQR
Incremental QR factorization using modified Gram-Schmidt with reorthogonalization.
Definition: limited-memory-qr.hpp:14
pa::rvec
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16
pa::LimitedMemoryQR::remove_column
void remove_column()
Remove the leftmost column.
Definition: limited-memory-qr.hpp:75
pa::LimitedMemoryQR::num_columns
size_t num_columns() const
Get the number of columns that are currently stored.
Definition: limited-memory-qr.hpp:227
pa::rmat
Eigen::Ref< mat > rmat
Default type for mutable references to matrices.
Definition: vec.hpp:22
pa::minimize_update_anderson
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):
Definition: anderson-helpers.hpp:30
pa
Definition: alm.hpp:10
pa::crvec
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
panocpy.test.α
α
Definition: test.py:31
pa::LimitedMemoryQR::add_column
void add_column(const VecV &v)
Add the given column to the right.
Definition: limited-memory-qr.hpp:32
pa::LimitedMemoryQR::ring_iter
CircularRange< size_t > ring_iter() const
Get iterators in the circular buffer.
Definition: limited-memory-qr.hpp:240
pa::LimitedMemoryQR::ring_tail
size_t ring_tail() const
Get the tail index of the circular buffer (points to one past the most recent element).
Definition: limited-memory-qr.hpp:233
limited-memory-qr.hpp
pa::LimitedMemoryQR::solve_col
void solve_col(const VecB &b, VecX &x) const
Solve the least squares problem Ax = b.
Definition: limited-memory-qr.hpp:114
pa::real_t
double real_t
Default floating point type.
Definition: vec.hpp:8