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

#include <cyqlone/cyqlone.hpp>

Detailed Description

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
struct cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >

Linear solver for systems with optimal control structure.

Template Parameters
VLVector length.
TScalar type.
DefaultOrderStorage order for the matrix workspaces (row/column major).
CtxParallel execution context type, see parallel::Context.
Examples
solve-ocp.cpp.

Definition at line 561 of file cyqlone.hpp.

Parallelization and vectorization

using tricyqle_t = TricyqleSolver<VL, T, DefaultOrder, Ctx>
 Tricyqle solver type for solving block-tridiagonal systems in parallel.
using Context = tricyqle_t::Context
using SharedContext = tricyqle_t::SharedContext
using simd = tricyqle_t::simd
const index_t p
 Number of processors/threads.
const index_t n = (N_horiz + p * v - 1) / (p * v)
 Number of stages per thread per vector lane (rounded up).
static constexpr index_t v = VL
 Vector length.
constexpr index_t lv () const
 log₂(v), logarithm of the vector length.
constexpr index_t lp () const
 log₂(p), logarithm of the number of processors/threads, rounded up.
constexpr index_t ceil_p () const
 The number of processors p rounded up to the next power of two.
constexpr index_t ceil_P () const
 The number of parallel execution units P rounded up to the next power of two.
std::unique_ptr< SharedContextcreate_parallel_context () const
void foreach_stage (Context &ctx, auto &&func, auto &&...xs) const
 Call a function for each stage in the horizon, passing the stage index, the data batch index, and optionally the corresponding batches of the given arrays.
void foreach_stage_fwd (Context &ctx, auto &&func, auto &&...xs) const
 Call a function for each stage in the horizon, passing the stage index, the data batch index, and optionally the corresponding batches of the given arrays.

Matrix data structures

template<StorageOrder O = column_major>
using matrix = typename tricyqle_t::template matrix<O>
 Owning type for a batch of matrices (with batch size v).
template<StorageOrder O = column_major>
using view = typename tricyqle_t::template view<O>
 Non-owning immutable view type for matrix.
template<StorageOrder O = column_major>
using mut_view = typename tricyqle_t::template mut_view<O>
 Non-owning mutable view type for matrix.
using layer_stride = typename tricyqle_t::layer_stride
template<StorageOrder O = column_major>
using batch_view = typename tricyqle_t::template batch_view<O>
 Non-owning immutable view type for a single batch of v matrices.
template<StorageOrder O = column_major>
using mut_batch_view = typename tricyqle_t::template mut_batch_view<O>
 Non-owning mutable view type for a single batch of v matrices.
static constexpr auto default_order = tricyqle_t::default_order
 Default storage order for most matrices.
static constexpr auto column_major = tricyqle_t::column_major
 Column-major storage order for column vectors and update matrices.

Problem dimensions

const index_t N_horiz
 Horizon length of the optimal control problem.
const index_t nx
 Number of states of the OCP.
const index_t nu
 Number of controls of the OCP.
const index_t ny
 Number of general constraints of the OCP per stage.
const index_t ny_0
 Number of general constraints at stage 0, D(0) u(0).
const index_t ny_N
 Number of general constraints at the final stage, C(N) x(N).
index_t num_variables () const
 Get the total number of primal variables in the OCP.
index_t num_dynamics_constraints () const
 Get the total number of dynamics constraints in the OCP.
index_t num_general_constraints () const
 Get the total number of general constraints in the OCP.

Solver parameters

CyqloneParams< value_typeparams {}
 Solver parameters and settings.
CyqloneParams< value_typeget_params () const
 Get the current Cyqlone solver parameters.
void update_params (const CyqloneParams< value_type > &new_params)
 Update the Cyqlone solver parameters.
TricyqleParams< value_typeget_tricyqle_params () const
 Get the current Tricyqle solver parameters.
void update_tricyqle_params (const TricyqleParams< value_type > &new_params)
 Update the Tricyqle solver parameters.
std::string get_params_string () const
 Get a string representation of the main solver parameters. Used mainly for file names.

Tricyqle solver for block-tridiagonal systems

tricyqle_t tricyqle
 Block-tridiagonal solver (CR/PCR/PCG).

OCP data (reordered for use during the Cyqlone algorithm)

matrix< default_orderdata_H
 Stage-wise Hessian blocks H(j) = [ R(j) S(j); S(j)ᵀ Q(j) ] of the OCP cost function.
matrix< default_orderdata_F
 Stage-wise dynamics matrices F(j) = [ B(j) A(j) ] of the OCP.
matrix< default_orderdata_Gᵀ
 Stage-wise constraint Jacobians G(j)ᵀ = [ D(j) C(j) ]ᵀ of the OCP.

Modified Riccati data structures

matrix< default_orderriccati_LH
 Cholesky factors of the Hessian blocks for the Riccati recursion.
matrix< default_orderriccati_LAB
 Storage for the matrices LB(j), Acl(j) and LA(j₁) for the Riccati recursion.
matrix< default_orderriccati_V
 Temporary storage for the V(j) = [ B(j)ᵀ LQ(j); A(j)ᵀ LQ(j) ] matrices during the Riccati recursion.
matrix< column_majorriccati_work
 Temporary workspace for the Riccati solve phase.

Riccati factorization update data structures

matrix< column_majorwork_Σ
 Compressed representation of the nonzero diagonal elements of the matrix Σ, populated for each thread separately during the factorization update of the Riccati recursion.
matrix< column_majorriccati_Υ1
 Workspace to store the update matrices Υu, Υx, Υλ, Φu, Φx and Φλ during the factorization update of the Riccati recursion.
matrix< column_majorriccati_Υ2
 Alternate workspace to riccati_Υ1.

Indexing utilities

index_t ceil_N () const
 Horizon length, rounded up to a multiple of the number of parallel execution units.
index_t ν2 (index_t i) const
 2-adic valuation ν₂.
index_t ν2p (index_t i) const
 2-adic valuation modulo p, i.e. ν2p(0) = ν2p(p) = lp().
index_t add_wrap_ceil_N (index_t a, index_t b) const
 Add b to a modulo N_horiz.
index_t sub_wrap_ceil_N (index_t a, index_t b) const
 Subtract b from a modulo N_horiz.
index_t add_wrap_p (index_t a, index_t b) const
 Add b to a modulo p.
index_t sub_wrap_p (index_t a, index_t b) const
 Subtract b from a modulo p.
index_t add_wrap_ceil_p (index_t a, index_t b) const
 Add b to a modulo ceil_p().
index_t sub_wrap_ceil_p (index_t a, index_t b) const
 Subtract b from a modulo ceil_p().
index_t sub_wrap_ceil_P (index_t a, index_t b) const
index_t add_wrap_ceil_P (index_t a, index_t b) const
index_t get_linear_batch_offset (index_t biA) const

Packing and unpacking of OCP data to Cyqlone storage format

void update_data (const CyqloneStorage< value_type > &ocp)
 Update the internal data structures to reflect changes in the OCP data (without changing the problem size).
void initialize_rhs (const CyqloneStorage< value_type > &ocp, mut_view<> rhs) const
 Initialize the right-hand side vector for the dynamics constraints of the OCP, using the custom Cyqlone storage format.
matrix initialize_rhs (const CyqloneStorage< value_type > &ocp) const
 Initialize the right-hand side vector for the dynamics constraints of the OCP, using the custom Cyqlone storage format.
void initialize_gradient (const CyqloneStorage< value_type > &ocp, mut_view<> grad) const
 Initialize the gradient vector for the OCP cost function, using the custom Cyqlone storage format.
matrix initialize_gradient (const CyqloneStorage< value_type > &ocp) const
 Initialize the gradient vector for the OCP cost function, using the custom Cyqlone storage format.
void initialize_bounds (const CyqloneStorage< value_type > &ocp, mut_view<> b_min, mut_view<> b_max) const
 Initialize the lower and upper bounds for the general constraints of the OCP, using the custom Cyqlone storage format.
std::pair< matrix<>, matrix<> > initialize_bounds (const CyqloneStorage< value_type > &ocp) const
 Initialize the lower and upper bounds for the general constraints of the OCP, using the custom Cyqlone storage format.
void pack_variables (std::span< const value_type > ux_lin, mut_view<> ux) const
matrix pack_variables (std::span< const value_type > ux_lin) const
void unpack_variables (view<> ux, std::span< value_type > ux_lin) const
std::vector< value_typeunpack_variables (view<> ux) const
void pack_dynamics (std::span< const value_type > λ_lin, mut_view<> λ) const
matrix pack_dynamics (std::span< const value_type > λ_lin) const
void unpack_dynamics (view<> λ, std::span< value_type > λ_lin) const
std::vector< value_typeunpack_dynamics (view<> λ) const
void pack_constraints (std::span< const value_type > y_lin, mut_view<> y, value_type fill=0) const
matrix pack_constraints (std::span< const value_type > y_lin, value_type fill=0) const
void unpack_constraints (view<> y, std::span< value_type > y_lin) const
std::vector< value_typeunpack_constraints (view<> y) const
matrix initialize_variables () const
 Get a zero-initialized matrix for the primal variables u and x.
matrix initialize_dynamics_constraints () const
 Get a zero-initialized matrix for the dynamics constraints (or their multipliers).
matrix initialize_general_constraints () const
 Get a zero-initialized matrix for the general constraints (or their multipliers).
static CyqloneSolver build (const CyqloneStorage< value_type > &ocp, index_t p)
 Initialize a Cyqlone solver for the given OCP.

OCP cost gradient and constraints evaluation

void residual_dynamics_constr (Context &ctx, view<> x, view<> b, mut_view<> Mxb) const
 Compute Mx + b, where M is the dynamics constraint Jacobian matrix of the OCP.
void transposed_dynamics_constr (Context &ctx, view<> λ, mut_view<> Mᵀλ, bool accum=false) const
 Compute Mᵀλ, where M is the dynamics constraint Jacobian matrix of the OCP.
void general_constr (Context &ctx, view<> ux, mut_view<> DCux) const
 Compute the general constraints Gx, where G is the general constraint Jacobian matrix of the OCP.
void transposed_general_constr (Context &ctx, view<> y, mut_view<> DCᵀy) const
 Compute Gᵀy, where G is the general constraint Jacobian matrix of the OCP.
void transposed_general_constr (view<> y, mut_view<> DCᵀy) const
 Compute Gᵀy, where G is the general constraint Jacobian matrix of the OCP.
void cost_gradient (Context &ctx, view<> ux, value_type α, view<> q, value_type β, mut_view<> grad_f) const
 Compute the cost gradient, with optional scaling factors.
void cost_gradient_regularized (Context &ctx, value_type γ, view<> ux, view<> ux0, view<> q, mut_view<> grad_f) const
 Compute the regularized cost gradient, with regularization parameter γ⁻¹, with respect to the point ux0.
void cost_gradient_remove_regularization (Context &ctx, value_type γ, view<> x, view<> x0, mut_view<> grad_f) const
 Subtract the regularization term from the cost gradient.

Factorization and solve routines

void factor_solve (Context &ctx, value_type γ, view<> Σ, mut_view<> ux, mut_view<> λ)
 Compute the Cyqlone factorization of the KKT matrix of the OCP and perform a forward solve (fused for improved locality).
void factor (Context &ctx, value_type γ, view<> Σ)
 Compute the Cyqlone factorization of the KKT matrix of the OCP.
void solve_forward (Context &ctx, mut_view<> ux, mut_view<> λ)
 Perform a forward solve with the Cyqlone factorization.
void solve_reverse (Context &ctx, mut_view<> ux, mut_view<> λ)
 Perform a reverse solve with the Cyqlone factorization.
void solve_reverse_mul (Context &ctx, mut_view<> ux, mut_view<> λ, mut_view<> Mᵀλ)
 Fused variant of solve_reverse and transposed_dynamics_constr (for improved locality of the dynamics Jacobians).
void update (Context &ctx, view<> ΔΣ)
 Perform factorization updates of the Cyqlone factorization as described by Algorithm 4 in the paper.
void update_solve (Context &ctx, view<> ΔΣ, mut_view<> ux, mut_view<> λ)
 Fused variant of update and solve_forward.

Low-level factorization and forward solve routines

index_t riccati_thread_assignment (Context &ctx) const
template<bool Factor = true, bool Solve = true>
void factor_riccati_solve (Context &ctx, value_type γ, view<> Σ, mut_view<> ux, mut_view<> λ)
 [Modified Riccati factorization and fused forward solve]
template<bool Factor = true, bool Solve = true>
void compute_schur (Context &ctx, mut_view<> ux, mut_view<> λ)
 [Cyqlone compute Schur]

Low-level factorization and forward solve routines for parallel cyclic reduction

template<bool Factor = true, bool Solve = true>
void factor_solve_impl (Context &ctx, value_type γ, view<> Σ, mut_view<> ux, mut_view<> λ)
 [Cyqlone factorization and fused forward solve]

Low-level reverse solve routines

void solve_riccati_reverse (Context &ctx, mut_view<> ux, mut_view<> λ, mut_view<> work, std::optional< mut_view<> > Mᵀλ) const
 [Modified Riccati factorization and fused forward solve]
void solve_reverse (Context &ctx, mut_view<> ux, mut_view<> λ, mut_view<> work, std::optional< mut_view<> > Mᵀλ=std::nullopt) const

Low-level factorization update routines

template<bool Solve = true>
void update_riccati_solve (Context &ctx, view<> ΔΣ, mut_view<> ux, mut_view<> λ)
 Update the modified Riccati factorization of a single block column as described by Algorithm 3 in the paper.
void update_riccati (Context &ctx, view<> ΔΣ)
template<bool Solve = true>
void update_solve_impl (Context &ctx, view<> ΔΣ, mut_view<> ux, mut_view<> λ)
 [PCR update]

Build sparse representations for debugging and testing

SparseMatrix build_sparse (const CyqloneStorage< value_type > &ocp, std::span< const value_type > Σ) const
std::vector< value_typebuild_rhs (view<> rq, view<> b, value_type scale_rq=-1, value_type scale_b=-1) const
std::vector< value_typebuild_sol (view<> ux, view<> λ) const
SparseMatrix build_sparse_factor () const
SparseMatrix build_sparse_diag () const

Public Types

using value_type = T

Member Typedef Documentation

◆ value_type

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::value_type = T

Definition at line 562 of file cyqlone.hpp.

◆ tricyqle_t

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::tricyqle_t = TricyqleSolver<VL, T, DefaultOrder, Ctx>

Tricyqle solver type for solving block-tridiagonal systems in parallel.

Definition at line 595 of file cyqlone.hpp.

◆ Context

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::Context = tricyqle_t::Context
Examples
solve-ocp.cpp.

Definition at line 596 of file cyqlone.hpp.

◆ SharedContext

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::SharedContext = tricyqle_t::SharedContext

Definition at line 597 of file cyqlone.hpp.

◆ simd

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::simd = tricyqle_t::simd

Definition at line 598 of file cyqlone.hpp.

◆ matrix

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
template<StorageOrder O = column_major>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::matrix = typename tricyqle_t::template matrix<O>

Owning type for a batch of matrices (with batch size v).

Definition at line 690 of file cyqlone.hpp.

◆ view

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
template<StorageOrder O = column_major>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::view = typename tricyqle_t::template view<O>

Non-owning immutable view type for matrix.

Definition at line 693 of file cyqlone.hpp.

◆ mut_view

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
template<StorageOrder O = column_major>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::mut_view = typename tricyqle_t::template mut_view<O>

Non-owning mutable view type for matrix.

Definition at line 696 of file cyqlone.hpp.

◆ layer_stride

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::layer_stride = typename tricyqle_t::layer_stride

Definition at line 697 of file cyqlone.hpp.

◆ batch_view

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
template<StorageOrder O = column_major>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::batch_view = typename tricyqle_t::template batch_view<O>

Non-owning immutable view type for a single batch of v matrices.

Definition at line 700 of file cyqlone.hpp.

◆ mut_batch_view

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
template<StorageOrder O = column_major>
using cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::mut_batch_view = typename tricyqle_t::template mut_batch_view<O>

Non-owning mutable view type for a single batch of v matrices.

Definition at line 703 of file cyqlone.hpp.

Member Function Documentation

◆ num_variables()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::num_variables ( ) const
inlinenodiscard

Get the total number of primal variables in the OCP.

Note
The actual number of variable stored in Cyqlone's internal data structures may be larger.

Definition at line 577 of file cyqlone.hpp.

◆ num_dynamics_constraints()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::num_dynamics_constraints ( ) const
inlinenodiscard

Get the total number of dynamics constraints in the OCP.

Note
The actual number of constraints stored in Cyqlone's internal data structures may be larger.

Definition at line 581 of file cyqlone.hpp.

◆ num_general_constraints()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::num_general_constraints ( ) const
inlinenodiscard

Get the total number of general constraints in the OCP.

Note
The actual number of constraints stored in Cyqlone's internal data structures may be larger.

Definition at line 585 of file cyqlone.hpp.

◆ lv()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::lv ( ) const
inlinenodiscardconstexpr

log₂(v), logarithm of the vector length.

Definition at line 608 of file cyqlone.hpp.

◆ lp()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::lp ( ) const
inlinenodiscardconstexpr

log₂(p), logarithm of the number of processors/threads, rounded up.

Definition at line 610 of file cyqlone.hpp.

◆ ceil_p()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ceil_p ( ) const
inlinenodiscardconstexpr

The number of processors p rounded up to the next power of two.

Definition at line 612 of file cyqlone.hpp.

◆ ceil_P()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ceil_P ( ) const
inlinenodiscardconstexpr

The number of parallel execution units P rounded up to the next power of two.

Definition at line 614 of file cyqlone.hpp.

◆ create_parallel_context()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
std::unique_ptr< SharedContext > cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::create_parallel_context ( ) const
inline
Examples
solve-ocp.cpp.

Definition at line 616 of file cyqlone.hpp.

◆ foreach_stage()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::foreach_stage ( Context & ctx,
auto && func,
auto &&... xs ) const
inline

Call a function for each stage in the horizon, passing the stage index, the data batch index, and optionally the corresponding batches of the given arrays.

Iterates backwards in time (decreasing stage index j).

Definition at line 623 of file cyqlone.hpp.

◆ foreach_stage_fwd()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::foreach_stage_fwd ( Context & ctx,
auto && func,
auto &&... xs ) const
inline

Call a function for each stage in the horizon, passing the stage index, the data batch index, and optionally the corresponding batches of the given arrays.

Iterates forward in time (increasing stage index j).

Definition at line 636 of file cyqlone.hpp.

◆ ceil_N()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ceil_N ( ) const
inlinenodiscard

Horizon length, rounded up to a multiple of the number of parallel execution units.

Definition at line 653 of file cyqlone.hpp.

◆ ν2()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ν2 ( index_t i) const
nodiscard

2-adic valuation ν₂.

Definition at line 121 of file indexing.tpp.

◆ ν2p()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ν2p ( index_t i) const
nodiscard

2-adic valuation modulo p, i.e. ν2p(0) = ν2p(p) = lp().

Definition at line 125 of file indexing.tpp.

◆ add_wrap_ceil_N()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::add_wrap_ceil_N ( index_t a,
index_t b ) const
nodiscard

Add b to a modulo N_horiz.

Definition at line 42 of file indexing.tpp.

◆ sub_wrap_ceil_N()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::sub_wrap_ceil_N ( index_t a,
index_t b ) const
nodiscard

Subtract b from a modulo N_horiz.

Definition at line 53 of file indexing.tpp.

◆ add_wrap_p()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::add_wrap_p ( index_t a,
index_t b ) const
nodiscard

Add b to a modulo p.

Definition at line 73 of file indexing.tpp.

◆ sub_wrap_p()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::sub_wrap_p ( index_t a,
index_t b ) const
nodiscard

Subtract b from a modulo p.

Definition at line 64 of file indexing.tpp.

◆ add_wrap_ceil_p()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::add_wrap_ceil_p ( index_t a,
index_t b ) const
nodiscard

Add b to a modulo ceil_p().

Definition at line 87 of file indexing.tpp.

◆ sub_wrap_ceil_p()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::sub_wrap_ceil_p ( index_t a,
index_t b ) const
nodiscard

Subtract b from a modulo ceil_p().

Definition at line 82 of file indexing.tpp.

◆ sub_wrap_ceil_P()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::sub_wrap_ceil_P ( index_t a,
index_t b ) const
nodiscard

Definition at line 92 of file indexing.tpp.

◆ add_wrap_ceil_P()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::add_wrap_ceil_P ( index_t a,
index_t b ) const
nodiscard

Definition at line 102 of file indexing.tpp.

◆ get_linear_batch_offset()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::get_linear_batch_offset ( index_t biA) const
nodiscard

Definition at line 112 of file indexing.tpp.

◆ get_params()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
CyqloneParams< value_type > cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::get_params ( ) const
inlinenodiscard

Get the current Cyqlone solver parameters.

Definition at line 714 of file cyqlone.hpp.

◆ update_params()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_params ( const CyqloneParams< value_type > & new_params)
inline

Update the Cyqlone solver parameters.

Definition at line 717 of file cyqlone.hpp.

◆ get_tricyqle_params()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
TricyqleParams< value_type > cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::get_tricyqle_params ( ) const
inlinenodiscard

Get the current Tricyqle solver parameters.

Examples
solve-ocp.cpp.

Definition at line 720 of file cyqlone.hpp.

◆ update_tricyqle_params()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_tricyqle_params ( const TricyqleParams< value_type > & new_params)
inline

Update the Tricyqle solver parameters.

Examples
solve-ocp.cpp.

Definition at line 725 of file cyqlone.hpp.

◆ get_params_string()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
std::string cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::get_params_string ( ) const
inlinenodiscard

Get a string representation of the main solver parameters. Used mainly for file names.

Examples
solve-ocp.cpp.

Definition at line 730 of file cyqlone.hpp.

◆ build()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
CyqloneSolver< VL, T, DefaultOrder, Ctx > cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build ( const CyqloneStorage< value_type > & ocp,
index_t p )
static

Initialize a Cyqlone solver for the given OCP.

Note: constraints on u(0) and x(N) should be independent.

ocp.CD(0) = [ 0 | D ] ny₀
[ 0 | 0 ] ny - ny₀
const index_t ny
Number of general constraints of the OCP per stage.
Definition cyqlone.hpp:570
const index_t nu
Number of controls of the OCP.
Definition cyqlone.hpp:569
const index_t nx
Number of states of the OCP.
Definition cyqlone.hpp:568

Since ocp.D(0) and ocp.C(N) will be merged, the top ny₀ rows of ocp.C(N) should be zero.

Examples
solve-ocp.cpp.

Definition at line 41 of file data.tpp.

◆ update_data()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_data ( const CyqloneStorage< value_type > & ocp)

Update the internal data structures to reflect changes in the OCP data (without changing the problem size).

Definition at line 94 of file data.tpp.

◆ initialize_rhs() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_rhs ( const CyqloneStorage< value_type > & ocp,
mut_view<> rhs ) const

Initialize the right-hand side vector for the dynamics constraints of the OCP, using the custom Cyqlone storage format.

Examples
solve-ocp.cpp.

Definition at line 147 of file data.tpp.

◆ initialize_rhs() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_rhs ( const CyqloneStorage< value_type > & ocp) const

Initialize the right-hand side vector for the dynamics constraints of the OCP, using the custom Cyqlone storage format.

Definition at line 429 of file data.tpp.

◆ initialize_gradient() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_gradient ( const CyqloneStorage< value_type > & ocp,
mut_view<> grad ) const

Initialize the gradient vector for the OCP cost function, using the custom Cyqlone storage format.

Examples
solve-ocp.cpp.

Definition at line 170 of file data.tpp.

◆ initialize_gradient() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_gradient ( const CyqloneStorage< value_type > & ocp) const

Initialize the gradient vector for the OCP cost function, using the custom Cyqlone storage format.

Definition at line 437 of file data.tpp.

◆ initialize_bounds() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_bounds ( const CyqloneStorage< value_type > & ocp,
mut_view<> b_min,
mut_view<> b_max ) const

Initialize the lower and upper bounds for the general constraints of the OCP, using the custom Cyqlone storage format.

Definition at line 204 of file data.tpp.

◆ initialize_bounds() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_bounds ( const CyqloneStorage< value_type > & ocp) const

Initialize the lower and upper bounds for the general constraints of the OCP, using the custom Cyqlone storage format.

Definition at line 445 of file data.tpp.

◆ pack_variables() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_variables ( std::span< const value_type > ux_lin,
mut_view<> ux ) const

Definition at line 242 of file data.tpp.

◆ pack_variables() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_variables ( std::span< const value_type > ux_lin) const

Definition at line 453 of file data.tpp.

◆ unpack_variables() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_variables ( view<> ux,
std::span< value_type > ux_lin ) const
Examples
solve-ocp.cpp.

Definition at line 281 of file data.tpp.

◆ unpack_variables() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_variables ( view<> ux) const

Definition at line 461 of file data.tpp.

◆ pack_dynamics() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_dynamics ( std::span< const value_type > λ_lin,
mut_view<> λ ) const

Definition at line 316 of file data.tpp.

◆ pack_dynamics() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_dynamics ( std::span< const value_type > λ_lin) const

Definition at line 469 of file data.tpp.

◆ unpack_dynamics() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_dynamics ( view<> λ,
std::span< value_type > λ_lin ) const
Examples
solve-ocp.cpp.

Definition at line 342 of file data.tpp.

◆ unpack_dynamics() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_dynamics ( view<> λ) const

Definition at line 477 of file data.tpp.

◆ pack_constraints() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_constraints ( std::span< const value_type > y_lin,
mut_view<> y,
value_type fill = 0 ) const

Definition at line 366 of file data.tpp.

◆ pack_constraints() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::pack_constraints ( std::span< const value_type > y_lin,
value_type fill = 0 ) const

Definition at line 485 of file data.tpp.

◆ unpack_constraints() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_constraints ( view<> y,
std::span< value_type > y_lin ) const

Definition at line 401 of file data.tpp.

◆ unpack_constraints() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::unpack_constraints ( view<> y) const

Definition at line 493 of file data.tpp.

◆ initialize_variables()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_variables ( ) const

Get a zero-initialized matrix for the primal variables u and x.

Examples
solve-ocp.cpp.

Definition at line 501 of file data.tpp.

◆ initialize_dynamics_constraints()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_dynamics_constraints ( ) const

Get a zero-initialized matrix for the dynamics constraints (or their multipliers).

Examples
solve-ocp.cpp.

Definition at line 506 of file data.tpp.

◆ initialize_general_constraints()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::initialize_general_constraints ( ) const

Get a zero-initialized matrix for the general constraints (or their multipliers).

Definition at line 511 of file data.tpp.

◆ residual_dynamics_constr()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::residual_dynamics_constr ( Context & ctx,
view<> x,
view<> b,
mut_view<> Mxb ) const

Compute Mx + b, where M is the dynamics constraint Jacobian matrix of the OCP.

In other words, evaluate the residuals for all stages, i.e., \( A_j x^j + B_j u^j - x^{j+1} + b^j \).

Examples
solve-ocp.cpp.

Definition at line 17 of file mat-vec.tpp.

◆ transposed_dynamics_constr()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::transposed_dynamics_constr ( Context & ctx,
view<> λ,
mut_view<> Mᵀλ,
bool accum = false ) const

Compute Mᵀλ, where M is the dynamics constraint Jacobian matrix of the OCP.

Optionally add the result to the existing contents of Mᵀλ by setting accum to true.

Examples
solve-ocp.cpp.

Definition at line 52 of file mat-vec.tpp.

◆ general_constr()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::general_constr ( Context & ctx,
view<> ux,
mut_view<> DCux ) const

Compute the general constraints Gx, where G is the general constraint Jacobian matrix of the OCP.

In other words, evaluate the constraints for all stages, i.e., \( C_j x^j + D_j u^j \).

Definition at line 95 of file mat-vec.tpp.

◆ transposed_general_constr() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::transposed_general_constr ( Context & ctx,
view<> y,
mut_view<> DCᵀy ) const

Compute Gᵀy, where G is the general constraint Jacobian matrix of the OCP.

Definition at line 105 of file mat-vec.tpp.

◆ transposed_general_constr() [2/2]

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::transposed_general_constr ( view<> y,
mut_view<> DCᵀy ) const

Compute Gᵀy, where G is the general constraint Jacobian matrix of the OCP.

◆ cost_gradient()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::cost_gradient ( Context & ctx,
view<> ux,
value_type α,
view<> q,
value_type β,
mut_view<> grad_f ) const

Compute the cost gradient, with optional scaling factors.

grad_f ← Q ux + α q + β grad_f

Examples
solve-ocp.cpp.

Definition at line 115 of file mat-vec.tpp.

◆ cost_gradient_regularized()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::cost_gradient_regularized ( Context & ctx,
value_type γ,
view<> ux,
view<> ux0,
view<> q,
mut_view<> grad_f ) const

Compute the regularized cost gradient, with regularization parameter γ⁻¹, with respect to the point ux0.

Definition at line 129 of file mat-vec.tpp.

◆ cost_gradient_remove_regularization()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::cost_gradient_remove_regularization ( Context & ctx,
value_type γ,
view<> x,
view<> x0,
mut_view<> grad_f ) const

Subtract the regularization term from the cost gradient.

Definition at line 147 of file mat-vec.tpp.

◆ factor_solve()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::factor_solve ( Context & ctx,
value_type γ,
view<> Σ,
mut_view<> ux,
mut_view<> λ )

Compute the Cyqlone factorization of the KKT matrix of the OCP and perform a forward solve (fused for improved locality).

Parameters
ctxParallel context.
γReciprocal primal regularization.
ΣALM penalty factors.
[in,out]uxNegative augmented Lagrangian gradient on entry; solution of forward solve on exit.
[in,out]λConstant term of the dynamics constraints on entry; solution of forward solve on exit. To obtain the solution of the KKT system, a reverse solve with the same factorization must be performed afterwards.
See also
solve_reverse
Examples
solve-ocp.cpp.

Definition at line 132 of file factor.tpp.

◆ factor()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::factor ( Context & ctx,
value_type γ,
view<> Σ )

Compute the Cyqlone factorization of the KKT matrix of the OCP.

See also
factor_solve

Definition at line 137 of file factor.tpp.

◆ solve_forward()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::solve_forward ( Context & ctx,
mut_view<> ux,
mut_view<> λ )

Perform a forward solve with the Cyqlone factorization.

See also
factor_solve

Definition at line 141 of file factor.tpp.

◆ solve_reverse() [1/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::solve_reverse ( Context & ctx,
mut_view<> ux,
mut_view<> λ )

Perform a reverse solve with the Cyqlone factorization.

[Cyqlone solve CR serial]

Parameters
ctxParallel context.
uxOn entry, the result of the forward solve; on exit the solution of the primal variables of the KKT system.
λOn entry, the result of the forward solve; on exit the solution of the dual variables corresponding to the dynamics constraints of the KKT system.
Examples
solve-ocp.cpp.

Definition at line 255 of file factor.tpp.

◆ solve_reverse_mul()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::solve_reverse_mul ( Context & ctx,
mut_view<> ux,
mut_view<> λ,
mut_view<> Mᵀλ )

Fused variant of solve_reverse and transposed_dynamics_constr (for improved locality of the dynamics Jacobians).

Definition at line 261 of file factor.tpp.

◆ update()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update ( Context & ctx,
view<> ΔΣ )

Perform factorization updates of the Cyqlone factorization as described by Algorithm 4 in the paper.

[Cyqlone update]

Parameters
ctxParallel context.
ΔΣChanges to the ALM penalty factors Σ.

Definition at line 284 of file update.tpp.

◆ update_solve()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_solve ( Context & ctx,
view<> ΔΣ,
mut_view<> ux,
mut_view<> λ )

Fused variant of update and solve_forward.

Definition at line 289 of file update.tpp.

◆ riccati_thread_assignment()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_thread_assignment ( Context & ctx) const
inline

Definition at line 972 of file cyqlone.hpp.

◆ factor_riccati_solve()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
template<bool Factor, bool Solve>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::factor_riccati_solve ( Context & ctx,
value_type γ,
view<> Σ,
mut_view<> ux,
mut_view<> λ )

[Modified Riccati factorization and fused forward solve]

Definition at line 23 of file riccati.tpp.

◆ compute_schur()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
template<bool Factor, bool Solve>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::compute_schur ( Context & ctx,
mut_view<> ux,
mut_view<> λ )

[Cyqlone compute Schur]

Definition at line 31 of file schur.tpp.

◆ factor_solve_impl()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
template<bool Factor, bool Solve>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::factor_solve_impl ( Context & ctx,
value_type γ,
view<> Σ,
mut_view<> ux,
mut_view<> λ )

[Cyqlone factorization and fused forward solve]

Definition at line 13 of file factor.tpp.

◆ solve_riccati_reverse()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::solve_riccati_reverse ( Context & ctx,
mut_view<> ux,
mut_view<> λ,
mut_view<> work,
std::optional< mut_view<> > Mᵀλ ) const

[Modified Riccati factorization and fused forward solve]

Definition at line 145 of file riccati.tpp.

◆ solve_reverse() [2/2]

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::solve_reverse ( Context & ctx,
mut_view<> ux,
mut_view<> λ,
mut_view<> work,
std::optional< mut_view<> > Mᵀλ = std::nullopt ) const

Definition at line 155 of file factor.tpp.

◆ update_riccati_solve()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
template<bool Solve>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_riccati_solve ( Context & ctx,
view<> ΔΣ,
mut_view<> ux,
mut_view<> λ )

Update the modified Riccati factorization of a single block column as described by Algorithm 3 in the paper.

[Cyqlone update CR]

[Cyqlone update Riccati]

Definition at line 352 of file update.tpp.

◆ update_riccati()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_riccati ( Context & ctx,
view<> ΔΣ )
inline

Definition at line 1005 of file cyqlone.hpp.

◆ update_solve_impl()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
template<bool Solve>
void cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::update_solve_impl ( Context & ctx,
view<> ΔΣ,
mut_view<> ux,
mut_view<> λ )

[PCR update]

[Cyqlone update]

Definition at line 263 of file update.tpp.

◆ build_sparse()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build_sparse ( const CyqloneStorage< value_type > & ocp,
std::span< const value_type > Σ ) const
nodiscard

Definition at line 15 of file sparse.tpp.

◆ build_rhs()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build_rhs ( view<> rq,
view<> b,
value_type scale_rq = -1,
value_type scale_b = -1 ) const
nodiscard

Definition at line 105 of file sparse.tpp.

◆ build_sol()

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
std::vector< value_type > cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build_sol ( view<> ux,
view<> λ ) const
inlinenodiscard

Definition at line 1018 of file cyqlone.hpp.

◆ build_sparse_factor()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build_sparse_factor ( ) const
nodiscard

Definition at line 159 of file sparse.tpp.

◆ build_sparse_diag()

template<index_t VL, class T, StorageOrder DefaultOrder, class Ctx>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::build_sparse_diag ( ) const
nodiscard

Definition at line 283 of file sparse.tpp.

Member Data Documentation

◆ N_horiz

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::N_horiz

Horizon length of the optimal control problem.

Definition at line 567 of file cyqlone.hpp.

◆ nx

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::nx

Number of states of the OCP.

Definition at line 568 of file cyqlone.hpp.

◆ nu

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::nu

Number of controls of the OCP.

Definition at line 569 of file cyqlone.hpp.

◆ ny

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ny

Number of general constraints of the OCP per stage.

Definition at line 570 of file cyqlone.hpp.

◆ ny_0

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ny_0

Number of general constraints at stage 0, D(0) u(0).

Definition at line 571 of file cyqlone.hpp.

◆ ny_N

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::ny_N

Number of general constraints at the final stage, C(N) x(N).

Definition at line 572 of file cyqlone.hpp.

◆ p

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::p

Number of processors/threads.

Definition at line 601 of file cyqlone.hpp.

◆ v

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::v = VL
staticconstexpr

Vector length.

Definition at line 603 of file cyqlone.hpp.

◆ n

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
const index_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::n = (N_horiz + p * v - 1) / (p * v)

Number of stages per thread per vector lane (rounded up).

Definition at line 605 of file cyqlone.hpp.

◆ default_order

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::default_order = tricyqle_t::default_order
staticconstexpr

Default storage order for most matrices.

Definition at line 684 of file cyqlone.hpp.

◆ column_major

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
auto cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::column_major = tricyqle_t::column_major
staticconstexpr

Column-major storage order for column vectors and update matrices.

Definition at line 686 of file cyqlone.hpp.

◆ params

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
CyqloneParams<value_type> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::params {}

Solver parameters and settings.

Definition at line 711 of file cyqlone.hpp.

◆ tricyqle

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
tricyqle_t cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::tricyqle
Initial value:
= {
.block_size = nx,
.max_rank = std::max(ny, ny_0 + ny_N) * N_horiz,
.p = p,
}
const index_t N_horiz
Horizon length of the optimal control problem.
Definition cyqlone.hpp:567
const index_t ny_0
Number of general constraints at stage 0, D(0) u(0).
Definition cyqlone.hpp:571
const index_t p
Number of processors/threads.
Definition cyqlone.hpp:601
const index_t ny_N
Number of general constraints at the final stage, C(N) x(N).
Definition cyqlone.hpp:572

Block-tridiagonal solver (CR/PCR/PCG).

Definition at line 747 of file cyqlone.hpp.

◆ data_H

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::data_H
Initial value:
= [this] {
return matrix<default_order>{{.depth = ceil_N(), .rows = nu + nx, .cols = nu + nx}};
}()
index_t ceil_N() const
Horizon length, rounded up to a multiple of the number of parallel execution units.
Definition cyqlone.hpp:653
typename tricyqle_t::template matrix< O > matrix
Owning type for a batch of matrices (with batch size v).
Definition cyqlone.hpp:690

Stage-wise Hessian blocks H(j) = [ R(j) S(j); S(j)ᵀ Q(j) ] of the OCP cost function.

Definition at line 762 of file cyqlone.hpp.

◆ data_F

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::data_F
Initial value:
= [this] {
return matrix<default_order>{{.depth = ceil_N(), .rows = nx, .cols = nu + nx}};
}()

Stage-wise dynamics matrices F(j) = [ B(j) A(j) ] of the OCP.

Definition at line 766 of file cyqlone.hpp.

◆ data_Gᵀ

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::data_Gᵀ
Initial value:
= [this] {
const auto nyM = std::max(ny, ny_0 + ny_N);
return matrix<default_order>{{.depth = ceil_N(), .rows = nu + nx, .cols = nyM}};
}()

Stage-wise constraint Jacobians G(j)ᵀ = [ D(j) C(j) ]ᵀ of the OCP.

Definition at line 770 of file cyqlone.hpp.

◆ riccati_LH

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_LH
Initial value:
= [this] {
return matrix<default_order>{{.depth = p * v, .rows = nu + nx, .cols = n * (nu + nx)}};
}()
const index_t n
Number of stages per thread per vector lane (rounded up).
Definition cyqlone.hpp:605
static constexpr index_t v
Vector length.
Definition cyqlone.hpp:603

Cholesky factors of the Hessian blocks for the Riccati recursion.

LH(j) = [ LR(j) 0; LS(j) LQ(j) ]

Definition at line 782 of file cyqlone.hpp.

◆ riccati_LAB

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_LAB
Initial value:
= [this] {
return matrix<default_order>{{.depth = p * v, .rows = nx, .cols = n * nx + n * nu}};
}()

Storage for the matrices LB(j), Acl(j) and LA(j₁) for the Riccati recursion.

Grouped per thread, with layout [ Acl(jₙ) ... Acl(j₂) LA(j₁) | LB(jₙ) ... LB(j₁) ], so that LA(j₁) and LB(j) are contiguous (useful when evaluating the Schur complement).

Definition at line 788 of file cyqlone.hpp.

◆ riccati_V

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<default_order> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_V
Initial value:
= [this] {
const auto nyM = std::max(ny, ny_0 + ny_N);
return matrix<default_order>{{.depth = p * v, .rows = nu + nx, .cols = nx + nyM}};
}()

Temporary storage for the V(j) = [ B(j)ᵀ LQ(j); A(j)ᵀ LQ(j) ] matrices during the Riccati recursion.

The workspace is wider than just V to also accommodate the active constraint Jacobians, since both are used to update the Hessian blocks during the Riccati recursion.

Definition at line 794 of file cyqlone.hpp.

◆ riccati_work

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<column_major> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_work
Initial value:
= [this] {
return matrix<column_major>{{.depth = p * v, .rows = nx, .cols = 1}};
}()

Temporary workspace for the Riccati solve phase.

Definition at line 799 of file cyqlone.hpp.

◆ work_Σ

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<column_major> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::work_Σ
Initial value:
= [this] {
const auto nyM = std::max(ny, ny_0 + ny_N);
return matrix<column_major>{{.depth = p * v, .rows = n * nyM, .cols = 1}};
}()

Compressed representation of the nonzero diagonal elements of the matrix Σ, populated for each thread separately during the factorization update of the Riccati recursion.

Definition at line 808 of file cyqlone.hpp.

◆ riccati_Υ1

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<column_major> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_Υ1
Initial value:
= [this] {
const auto nyM = std::max(ny, ny_0 + ny_N);
return matrix<column_major>{{.depth = p * v, .rows = nu + nx + nx, .cols = n * nyM}};
}()

Workspace to store the update matrices Υu, Υx, Υλ, Φu, Φx and Φλ during the factorization update of the Riccati recursion.

Both riccati_Υ1 and riccati_Υ2 are used alternately.

Definition at line 815 of file cyqlone.hpp.

◆ riccati_Υ2

template<index_t VL = 4, class T = real_t, StorageOrder DefaultOrder = StorageOrder::ColMajor, class Ctx = parallel::Context<>>
matrix<column_major> cyqlone::CyqloneSolver< VL, T, DefaultOrder, Ctx >::riccati_Υ2
Initial value:
= [this] {
const auto nyM = std::max(ny, ny_0 + ny_N);
return matrix<column_major>{{.depth = p * v, .rows = nu + nx + nx, .cols = n * nyM}};
}()

Alternate workspace to riccati_Υ1.

Definition at line 820 of file cyqlone.hpp.


The documentation for this struct was generated from the following files:
  • src/cyqlone/include/cyqlone/cyqlone.hpp
  • src/cyqlone/include/cyqlone/implementation/data.tpp
  • src/cyqlone/include/cyqlone/implementation/factor.tpp
  • src/cyqlone/include/cyqlone/implementation/indexing.tpp
  • src/cyqlone/include/cyqlone/implementation/mat-vec.tpp
  • src/cyqlone/include/cyqlone/implementation/riccati.tpp
  • src/cyqlone/include/cyqlone/implementation/schur.tpp
  • src/cyqlone/include/cyqlone/implementation/sparse.tpp
  • src/cyqlone/include/cyqlone/implementation/update.tpp