2#include <batmat/assume.hpp>
3#include <batmat/config.hpp>
4#include <guanaqo/blas/hl-blas-interface.hpp>
11 -> std::vector<value_type> {
12 std::vector<value_type> y(
static_cast<size_t>(
N_horiz *
ny +
ny_N));
19 std::span<value_type> y)
const {
22 for (index_t r = 0, j = 0; r <
ny; ++r)
24 y[r] = y_compressed[j++];
27 std::ranges::copy(y_compressed.subspan(
ny_0), y.begin() +
ny);
33 std::span<const value_type> ux_compressed,
34 std::span<const value_type> y_compressed,
35 std::span<const value_type> λ_compressed)
const
42 std::ranges::copy_n(ocp.b(0).data,
nx, sol.
solution.begin());
43 std::ranges::copy(ux_compressed, sol.
solution.begin() +
nx);
48 x0{{.data = sol.
solution.data(), .rows =
nx, .cols = 1}},
49 u0{{.data = sol.
solution.data() +
nx, .rows =
nu, .cols = 1}};
59 std::span<const value_type> ux_compressed,
60 std::span<const value_type> y_compressed,
61 std::span<const value_type> λ_compressed)
const
63 return ocp.compute_kkt_error(
70 const auto nJu0 =
static_cast<index_t
>(
Ju0.size());
72 for (index_t c = 0; c <
nu; ++c)
73 for (index_t r = 0; r <
ny; ++r)
74 Ju0[r] =
Ju0[r] || ocp.
D(0)(r, c) != 0;
75 return static_cast<index_t
>(std::ranges::count(
Ju0,
true));
96 data_F(0).right_cols(
nx).set_constant(0);
102 for (index_t r = 0; r <
ny; ++r) {
105 data_G0N(0).block(j, 0, 1,
nu) = ocp.
D(0).middle_rows(r, 1);
107 for (index_t c = 0; c <
nx; ++c)
108 t += ocp.
C(0)(r, c) * ocp.
b(0)(c, 0);
121 for (index_t r = 0; r <
nx; ++r)
122 for (index_t c = 0; c <
nx; ++c)
123 data_c(0, r, 0) += ocp.
A(0)(r, c) * ocp.
b(0)(c, 0);
127 for (index_t r = 0; r <
nu; ++r)
128 for (index_t c = 0; c <
nx; ++c)
130 for (index_t i = 1; i < N; ++i) {
151 std::vector<bool>
Ju0(
ny);
163 .Ju0 = std::move(
Ju0)};
169#define CYQLONE_INSTANTIATE_CYQLONE_STORAGE(T) template struct CyqloneStorage<T>;
170BATMAT_FOREACH_DTYPE(CYQLONE_INSTANTIATE_CYQLONE_STORAGE)
Data structure for optimal control problems where the initial states are eliminated.
void xsymv_L(T alpha, MatrixView< const T, I, UnitStride< I >, O > A, std::type_identity_t< MatrixView< const T, I > > x, T beta, MatrixView< T, I > y)
void xgemv_T(T alpha, std::type_identity_t< MatrixView< const T, I > > A, std::type_identity_t< MatrixView< const T, I > > x, T beta, MatrixView< T, I > y)
Storage for a linear-quadratic OCP with the initial states x₀ eliminated.
static index_t count_constr_0(const LinearOCPStorage &ocp, std::vector< bool > &Ju0)
Solution reconstruct_solution(const LinearOCPStorage &ocp, std::span< const value_type > ux_compressed, std::span< const value_type > y_compressed, std::span< const value_type > λ_compressed) const
std::vector< index_t > indices_G0
LinearOCPStorage::Solution Solution
void reconstruct_ineq_multipliers(std::span< const value_type > y_compressed, std::span< value_type > y) const
void update_impl(const LinearOCPStorage &ocp)
LinearOCPStorage::KKTError KKTError
void update(const LinearOCPStorage &ocp)
KKTError compute_kkt_error(const LinearOCPStorage &ocp, std::span< const value_type > ux_compressed, std::span< const value_type > y_compressed, std::span< const value_type > λ_compressed) const
static CyqloneStorage build(const LinearOCPStorage &ocp, index_t ny_0=-1)
std::vector< real_t > inequality_multipliers
std::vector< real_t > solution
std::vector< real_t > equality_multipliers
Storage for a linear-quadratic OCP of the form.
guanaqo::MatrixView< real_t, index_t > r(index_t i)
guanaqo::MatrixView< real_t, index_t > q(index_t i)
guanaqo::MatrixView< real_t, index_t > B(index_t i)
guanaqo::MatrixView< real_t, index_t > D(index_t i)
guanaqo::MatrixView< real_t, index_t > b_min()
guanaqo::MatrixView< real_t, index_t > b()
guanaqo::MatrixView< real_t, index_t > R(index_t i)
guanaqo::MatrixView< real_t, index_t > C(index_t i)
guanaqo::MatrixView< real_t, index_t > S(index_t i)
guanaqo::MatrixView< real_t, index_t > Q(index_t i)
guanaqo::MatrixView< real_t, index_t > A(index_t i)
guanaqo::MatrixView< real_t, index_t > S_trans(index_t i)
guanaqo::MatrixView< real_t, index_t > b_max()