cyqlone develop
Fast, parallel and vectorized solver for linear systems with optimal control structure.
Loading...
Searching...
No Matches
breakpoint.tpp
Go to the documentation of this file.
1#include <cyqlone/config.hpp>
3#include <guanaqo/trace.hpp>
4#include <cmath>
5#include <ranges>
6
7namespace CYQLONE_NS(cyqlone::qpalm) {
8
9template <class Vec>
10std::span<Breakpoint>
11compute_breakpoints_default(std::vector<Breakpoint> &breakpoints, const Vec &Σ, const Vec &y,
12 const Vec &Ad, const Vec &Ax, const Vec &b_min, const Vec &b_max) {
13 GUANAQO_TRACE("linesearch breakpoints", 0);
14 using std::sqrt;
15 // Allocate memory
16 auto m = static_cast<size_t>(y.size());
17 breakpoints.resize(2 * m);
18 // Compute break points t[i] and intermediate values α[i] and δ[i]
19 auto indices = std::views::iota(index_t{});
20 for (auto [Σi, yi, Adi, Axi, li, ui, i] :
21 std::views::zip(Σ, y, Ad, Ax, b_min, b_max, indices)) {
22 const auto s = sqrt(Σi);
23 breakpoints[m + i].δ = s * Adi;
24 breakpoints[i].δ = -breakpoints[m + i].δ;
25 breakpoints[i].t = (yi + Σi * (Axi - li)) / (s * breakpoints[i].δ);
26 breakpoints[m + i].t = (Σi * (ui - Axi) - yi) / (s * breakpoints[m + i].δ);
27 }
28 return std::span{breakpoints};
29}
30
31} // namespace CYQLONE_NS(cyqlone::qpalm)
#define CYQLONE_NS(ns)
Definition config.hpp:10
#define GUANAQO_TRACE(name, instance,...)
std::span< Breakpoint > compute_breakpoints_default(std::vector< Breakpoint > &breakpoints, const Vec &Σ, const Vec &y, const Vec &Ad, const Vec &Ax, const Vec &b_min, const Vec &b_max)
Compute the break points t[i] using formula (3.6) in the QPALM paper.