cyqlone develop
Fast, parallel and vectorized solver for linear systems with optimal control structure.
Loading...
Searching...
No Matches
cyqlone::CyqloneStorage< T > Struct Template Reference

#include <cyqlone/cyqlone-storage.hpp>

Detailed Description

template<class T = real_t>
struct cyqlone::CyqloneStorage< T >

Storage for a linear-quadratic OCP with the initial states x₀ eliminated.

ₙ₋₁
minimize ∑ [½ uᵢᵀ Rᵢ uᵢ + uᵢᵀ Sᵢ xᵢ + ½ xᵢᵀ Qᵢ xᵢ + rᵢᵀuᵢ + qᵢᵀxᵢ]
ⁱ⁼¹
+ ½ u₀ᵀ R₀ u₀ + (r₀ + S₀ xᵢₙᵢₜ)ᵀ u₀
+ ½ xₙᵀ Qₙ xₙ + qₙᵀ xₙ
s.t. xᵢ₊₁ = Aᵢ xᵢ + Bᵢ uᵢ + cᵢ
lᵢ ≤ Cᵢ xᵢ + Dᵢ uᵢ ≤ uᵢ
l₀ - C₀ xᵢₙᵢₜ ≤ D₀ U₀ ≤ u₀ - C₀ xᵢₙᵢₜ
lₙ ≤ Cₙ xₙ ≤ uₙ

The matrices are combined per stage, with inputs ordered first. The first and last stage are special because of the lack of x₀ and uₙ.

Hᵢ = [ Rᵢ Sᵢ ], H₀ = [ R₀ 0 ], Fᵢ = [ Bᵢ Aᵢ ], Gᵢ = [ Dᵢ Cᵢ ], G₀ = [ D₀ Cₙ ]
[ Sᵢᵀ Qᵢ ] [ 0 Qₙ ]

Due to the elimination of x₀, there may be fewer constraints for the first stage, which is tracked by the Ju0 mask. When reconstructing the solution, the multipliers for eliminated constraints are set to zero (we assume that the initial state is feasible w.r.t. the state constraints).

Definition at line 39 of file cyqlone-storage.hpp.

Public Types

using value_type = T
using matrix = batmat::matrix::Matrix<value_type, index_t>
using Solution = LinearOCPStorage::Solution
using KKTError = LinearOCPStorage::KKTError

Public Member Functions

void update_impl (const LinearOCPStorage &ocp)
void update (const LinearOCPStorage &ocp)
void reconstruct_ineq_multipliers (std::span< const value_type > y_compressed, std::span< value_type > y) const
std::vector< value_typereconstruct_ineq_multipliers (std::span< const value_type > y_compressed) const
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
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 Public Member Functions

static CyqloneStorage build (const LinearOCPStorage &ocp, index_t ny_0=-1)
static index_t count_constr_0 (const LinearOCPStorage &ocp, std::vector< bool > &Ju0)

Public Attributes

index_t N_horiz
index_t nx
index_t nu
index_t ny
index_t ny_0
index_t ny_N
std::vector< bool > Ju0
matrix data_H
matrix data_F = [this] { return matrix{{.depth = N_horiz, .rows = nx, .cols = nu + nx}}; }()
matrix data_G
matrix data_G0N
matrix data_rq = [this] { return matrix{{.depth = N_horiz, .rows = nu + nx, .cols = 1}}; }()
matrix data_c = [this] { return matrix{{.depth = N_horiz, .rows = nx, .cols = 1}}; }()
matrix data_lb = [this] { return matrix{{.depth = N_horiz - 1, .rows = ny, .cols = 1}}; }()
matrix data_lb0N = [this] { return matrix{{.depth = 1, .rows = ny_0 + ny_N, .cols = 1}}; }()
matrix data_ub = [this] { return matrix{{.depth = N_horiz - 1, .rows = ny, .cols = 1}}; }()
matrix data_ub0N = [this] { return matrix{{.depth = 1, .rows = ny_0 + ny_N, .cols = 1}}; }()
std::vector< index_t > indices_G0 = std::vector<index_t>(ny_0)

Member Typedef Documentation

◆ value_type

template<class T = real_t>
using cyqlone::CyqloneStorage< T >::value_type = T

Definition at line 40 of file cyqlone-storage.hpp.

◆ matrix

template<class T = real_t>
using cyqlone::CyqloneStorage< T >::matrix = batmat::matrix::Matrix<value_type, index_t>

Definition at line 44 of file cyqlone-storage.hpp.

◆ Solution

template<class T = real_t>
using cyqlone::CyqloneStorage< T >::Solution = LinearOCPStorage::Solution

Definition at line 72 of file cyqlone-storage.hpp.

◆ KKTError

template<class T = real_t>
using cyqlone::CyqloneStorage< T >::KKTError = LinearOCPStorage::KKTError

Definition at line 73 of file cyqlone-storage.hpp.

Member Function Documentation

◆ update_impl()

template<class T>
void cyqlone::CyqloneStorage< T >::update_impl ( const LinearOCPStorage & ocp)

Definition at line 86 of file cyqlone-storage.cpp.

◆ update()

template<class T>
void cyqlone::CyqloneStorage< T >::update ( const LinearOCPStorage & ocp)

Definition at line 79 of file cyqlone-storage.cpp.

◆ build()

template<class T>
CyqloneStorage< T > cyqlone::CyqloneStorage< T >::build ( const LinearOCPStorage & ocp,
index_t ny_0 = -1 )
static
Examples
benchmarks/cyqpalm/spring-mass.cpp, and solve-ocp.cpp.

Definition at line 148 of file cyqlone-storage.cpp.

◆ reconstruct_ineq_multipliers() [1/2]

template<class T>
void cyqlone::CyqloneStorage< T >::reconstruct_ineq_multipliers ( std::span< const value_type > y_compressed,
std::span< value_type > y ) const

Definition at line 18 of file cyqlone-storage.cpp.

◆ reconstruct_ineq_multipliers() [2/2]

template<class T>
auto cyqlone::CyqloneStorage< T >::reconstruct_ineq_multipliers ( std::span< const value_type > y_compressed) const

Definition at line 10 of file cyqlone-storage.cpp.

◆ count_constr_0()

template<class T>
index_t cyqlone::CyqloneStorage< T >::count_constr_0 ( const LinearOCPStorage & ocp,
std::vector< bool > & Ju0 )
static

Definition at line 68 of file cyqlone-storage.cpp.

◆ reconstruct_solution()

template<class T>
auto cyqlone::CyqloneStorage< T >::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

Definition at line 32 of file cyqlone-storage.cpp.

◆ compute_kkt_error()

template<class T>
auto cyqlone::CyqloneStorage< T >::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

Definition at line 58 of file cyqlone-storage.cpp.

Member Data Documentation

◆ N_horiz

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::N_horiz

Definition at line 41 of file cyqlone-storage.hpp.

◆ nx

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::nx

Definition at line 42 of file cyqlone-storage.hpp.

◆ nu

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::nu

Definition at line 42 of file cyqlone-storage.hpp.

◆ ny

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::ny

Definition at line 42 of file cyqlone-storage.hpp.

◆ ny_0

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::ny_0

Definition at line 42 of file cyqlone-storage.hpp.

◆ ny_N

template<class T = real_t>
index_t cyqlone::CyqloneStorage< T >::ny_N

Definition at line 42 of file cyqlone-storage.hpp.

◆ Ju0

template<class T = real_t>
std::vector<bool> cyqlone::CyqloneStorage< T >::Ju0

Definition at line 43 of file cyqlone-storage.hpp.

◆ data_H

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_H
Initial value:
= [this] {
return matrix{{.depth = N_horiz, .rows = nu + nx, .cols = nu + nx}};
}()
batmat::matrix::Matrix< value_type, index_t > matrix

Definition at line 45 of file cyqlone-storage.hpp.

◆ data_F

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_F = [this] { return matrix{{.depth = N_horiz, .rows = nx, .cols = nu + nx}}; }()

Definition at line 48 of file cyqlone-storage.hpp.

◆ data_G

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_G
Initial value:
= [this] {
return matrix{{.depth = N_horiz - 1, .rows = ny, .cols = nu + nx}};
}()

Definition at line 49 of file cyqlone-storage.hpp.

◆ data_G0N

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_G0N
Initial value:
= [this] {
return matrix{{.depth = 1, .rows = ny_0 + ny_N, .cols = nu + nx}};
}()

Definition at line 52 of file cyqlone-storage.hpp.

◆ data_rq

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_rq = [this] { return matrix{{.depth = N_horiz, .rows = nu + nx, .cols = 1}}; }()

Definition at line 55 of file cyqlone-storage.hpp.

◆ data_c

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_c = [this] { return matrix{{.depth = N_horiz, .rows = nx, .cols = 1}}; }()

Definition at line 56 of file cyqlone-storage.hpp.

◆ data_lb

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_lb = [this] { return matrix{{.depth = N_horiz - 1, .rows = ny, .cols = 1}}; }()

Definition at line 57 of file cyqlone-storage.hpp.

◆ data_lb0N

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_lb0N = [this] { return matrix{{.depth = 1, .rows = ny_0 + ny_N, .cols = 1}}; }()

Definition at line 58 of file cyqlone-storage.hpp.

◆ data_ub

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_ub = [this] { return matrix{{.depth = N_horiz - 1, .rows = ny, .cols = 1}}; }()

Definition at line 59 of file cyqlone-storage.hpp.

◆ data_ub0N

template<class T = real_t>
matrix cyqlone::CyqloneStorage< T >::data_ub0N = [this] { return matrix{{.depth = 1, .rows = ny_0 + ny_N, .cols = 1}}; }()

Definition at line 60 of file cyqlone-storage.hpp.

◆ indices_G0

template<class T = real_t>
std::vector<index_t> cyqlone::CyqloneStorage< T >::indices_G0 = std::vector<index_t>(ny_0)

Definition at line 61 of file cyqlone-storage.hpp.


The documentation for this struct was generated from the following files: