cyqlone develop
Fast, parallel and vectorized solver for linear systems with optimal control structure.
Loading...
Searching...
No Matches
cyqlone Namespace Reference

Namespaces

namespace  detail
namespace  linalg
namespace  parallel
namespace  qpalm

Classes

struct  EmptyCompletion
 No-op completion function for the TreeBarrier. More...
class  TreeBarrier
 Fairly vanilla combining tree barrier. More...
struct  LinearOCPSparseQP
 Represents a sparse multiple shooting formulation of the standard optimal control problem. More...
struct  TricyqleParams
 Parameters and settings for the Tricyqle block-tridiagonal solver. More...
struct  CyqloneParams
 Parameters and settings for the Cyqlone solver. More...
struct  CyqloneStorage
 Storage for a linear-quadratic OCP with the initial states x₀ eliminated. More...
struct  TricyqleSolver
 Solver for block-tridiagonal systems using cyclic reduction (CR), parallel cyclic reduction (PCR), and preconditioned conjugate gradient (PCG) methods. More...
struct  CyqloneSolver
 Linear solver for systems with optimal control structure. More...
class  NeumaierSum
 Kahan-Babuška-Neumaier compensated summation. More...
struct  OCPDim
 Dimensions of an optimal control problem. More...
struct  LinearOCPStorage
 Storage for a linear-quadratic OCP of the form. More...
struct  norms
 Utilities for computing vector norms. More...
struct  norms< T, void >
struct  SparseMatrix
 A sparse matrix in COO format. More...
struct  SparseMatrixBuilder
 A builder for constructing a SparseMatrix incrementally. More...
struct  matio_traits
struct  matio_traits< float >
struct  matio_traits< double >
struct  matio_traits< I >
struct  PCRFactorTest
struct  SparseCSC
struct  SparseCOO

Typedefs

using mat_t = ::_mat_t
 Incomplete matio struct type.
using MatFilePtr = std::unique_ptr<mat_t, int (*)(mat_t *)>
 Owning handle to a matio file. The file will be closed when the handle goes out of scope.
using DefaultTimings = batmat::DefaultTimings
using MatVarPtr = std::unique_ptr<matvar_t, decltype(&Mat_VarFree)>

Enumerations

enum class  SolveMethod { SolveMethod::StairPCG , SolveMethod::JacobiPCG , SolveMethod::PCR }
 Defines how to solve the small linear system that remains after cyclic reduction. More...
enum class  MatioOpenMode { MatioOpenMode::Read , MatioOpenMode::Write }
enum  StorageOrder
enum class  Symmetry

Functions

void reference_to_gradient (const LinearOCPStorage &ocp, std::span< const real_t > ref, std::span< real_t > qr)
 Simply computes the gradient of the quadratic cost \( J(x, u) = \sum_{j=1}^{N-1} \ell_j(x^j, u^j) + \ell_N(x^N) \), with \( \ell_j(x, u) = \tfrac12 \left\| \begin{pmatrix} x - x^j_\text{ref} \\ u - u^j_\text{ref} \end{pmatrix} \right\|_{H_j}^2 \), with the Hessian \( H_j = \begin{pmatrix} Q_j & S_j^\top \\ S_j & R_j \end{pmatrix} \).
void reference_to_gradient (LinearOCPStorage &ocp, std::span< const real_t > ref)
 Simply computes the gradient of the quadratic cost \( J(x, u) = \sum_{j=1}^{N-1} \ell_j(x^j, u^j) + \ell_N(x^N) \), with \( \ell_j(x, u) = \tfrac12 \left\| \begin{pmatrix} x - x^j_\text{ref} \\ u - u^j_\text{ref} \end{pmatrix} \right\|_{H_j}^2 \), with the Hessian \( H_j = \begin{pmatrix} Q_j & S_j^\top \\ S_j & R_j \end{pmatrix} \).
const char * enum_name (SolveMethod s)
constexpr bool is_pow_2 (index_t n)
constexpr index_t ceil_log2 (index_t n)
constexpr index_t get_level (index_t i)
constexpr index_t get_index_in_level (index_t i)
MatFilePtr open_mat (const std::filesystem::path &filename, MatioOpenMode mode=MatioOpenMode::Read)
 Opens a .mat file for reading or writing.
MatFilePtr create_mat (const std::filesystem::path &filename)
 Create and open a new .mat file for writing.
void add_to_mat (mat_t *mat, const std::string &varname, float value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, double value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, short value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, int value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, long value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, long long value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, unsigned short value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, unsigned int value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, unsigned long value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, unsigned long long value)
 Add a value to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, guanaqo::MatrixView< const double, index_t > data)
 Add a matrix to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, guanaqo::MatrixView< const float, index_t > data)
 Add a matrix to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, batmat::matrix::View< const double, index_t > data)
 Add a batch of matrices to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, batmat::matrix::View< const float, index_t > data)
 Add a batch of matrices to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const float > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const double > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const unsigned short > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const unsigned int > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const unsigned long > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const unsigned long long > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const short > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const int > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const long > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, std::span< const long long > data)
 Add a vector to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, const SparseMatrix &matrix)
 Add a sparse matrix to an open .mat file.
void add_to_mat (mat_t *mat, const std::string &varname, const LinearOCPStorage &ocp)
 Add the data from a LinearOCPStorage to an open .mat file.
void read_from_mat (mat_t *mat, const std::string &varname, LinearOCPStorage &ocp)
 Load a LinearOCPStorage from a .mat file.
void read_from_mat (mat_t *mat, const std::string &varname, std::vector< float > &data)
 Load a vector from an open .mat file.
void read_from_mat (mat_t *mat, const std::string &varname, std::vector< double > &data)
 Load a vector from an open .mat file.
void read_from_mat (mat_t *mat, const std::string &varname, std::span< float > data)
 Load a vector from an open .mat file.
void read_from_mat (mat_t *mat, const std::string &varname, std::span< double > data)
 Load a vector from an open .mat file.
void ocp_dump_mat (const std::filesystem::path &filename, const LinearOCPStorage &ocp)
 Dump the data from a LinearOCPStorage to a new .mat file.
LinearOCPStorage generate_random_ocp (OCPDim dim, uint_fast32_t seed=0)
 Generates a random linear OCP with the given dimensions and random seed.
template<class T, size_t N>
MatVarPtr create_tensor_var (const char *name, std::span< const T > buffer, std::array< index_t, N > dims)
template<class T, size_t N>
void write_tensor (mat_t *matfp, const char *name, std::span< const T > buffer, std::array< index_t, N > dims)
template<class T>
void add_to_mat_impl (mat_t *mat, const std::string &varname, guanaqo::MatrixView< const T, index_t > data)
template<class T>
void add_to_mat_impl (mat_t *mat, const std::string &varname, batmat::matrix::View< const T, index_t > data)
void validate_mat_var (const matvar_t *var, const std::string &name, int expected_rank)
auto open_vector_var (mat_t *mat, const std::string &varname)
constexpr index_t get_depth (index_t n)
template<class Mat>
auto λ_max_power (const Mat &M, const Mat &K, int max_it, typename Mat::value_type tol)
template<class M>
auto unpacked (const M &matrix)
constexpr auto simdify (simdifiable auto &&a) -> simdified_view_t< decltype(a)>

Class Documentation

◆ cyqlone::matio_traits

struct cyqlone::matio_traits

Typedef Documentation

◆ DefaultTimings

Definition at line 7 of file timing.hpp.

◆ MatVarPtr

using cyqlone::MatVarPtr = std::unique_ptr<matvar_t, decltype(&Mat_VarFree)>

Definition at line 67 of file matio.cpp.

Enumeration Type Documentation

◆ StorageOrder

◆ Symmetry

Function Documentation

◆ reference_to_gradient()

void cyqlone::reference_to_gradient ( LinearOCPStorage & ocp,
std::span< const real_t > ref )

Simply computes the gradient of the quadratic cost \( J(x, u) = \sum_{j=1}^{N-1} \ell_j(x^j, u^j) + \ell_N(x^N) \), with \( \ell_j(x, u) = \tfrac12 \left\| \begin{pmatrix} x - x^j_\text{ref} \\ u - u^j_\text{ref} \end{pmatrix} \right\|_{H_j}^2 \), with the Hessian \( H_j = \begin{pmatrix} Q_j & S_j^\top \\ S_j & R_j \end{pmatrix} \).

Stores \( \nabla J(0, 0) \) to qr.

Definition at line 37 of file conversion.cpp.

◆ enum_name()

const char * cyqlone::enum_name ( SolveMethod s)
inline

Definition at line 17 of file cyqlone-params.hpp.

◆ is_pow_2()

bool cyqlone::is_pow_2 ( index_t n)
nodiscardconstexpr
Examples
solve-block-tridiagonal.cpp, and solve-ocp.cpp.

Definition at line 32 of file cyqlone.hpp.

◆ ceil_log2()

index_t cyqlone::ceil_log2 ( index_t n)
nodiscardconstexpr

Definition at line 38 of file cyqlone.hpp.

◆ get_level()

index_t cyqlone::get_level ( index_t i)
nodiscardconstexpr

Definition at line 45 of file cyqlone.hpp.

◆ get_index_in_level()

index_t cyqlone::get_index_in_level ( index_t i)
nodiscardconstexpr

Definition at line 51 of file cyqlone.hpp.

◆ create_tensor_var()

template<class T, size_t N>
MatVarPtr cyqlone::create_tensor_var ( const char * name,
std::span< const T > buffer,
std::array< index_t, N > dims )

Definition at line 70 of file matio.cpp.

◆ write_tensor()

template<class T, size_t N>
void cyqlone::write_tensor ( mat_t * matfp,
const char * name,
std::span< const T > buffer,
std::array< index_t, N > dims )

Definition at line 80 of file matio.cpp.

◆ add_to_mat_impl() [1/2]

template<class T>
void cyqlone::add_to_mat_impl ( mat_t * mat,
const std::string & varname,
guanaqo::MatrixView< const T, index_t > data )

Definition at line 105 of file matio.cpp.

◆ add_to_mat_impl() [2/2]

template<class T>
void cyqlone::add_to_mat_impl ( mat_t * mat,
const std::string & varname,
batmat::matrix::View< const T, index_t > data )

Definition at line 173 of file matio.cpp.

◆ validate_mat_var()

void cyqlone::validate_mat_var ( const matvar_t * var,
const std::string & name,
int expected_rank )

Definition at line 351 of file matio.cpp.

◆ open_vector_var()

auto cyqlone::open_vector_var ( mat_t * mat,
const std::string & varname )

Definition at line 481 of file matio.cpp.

◆ get_depth()

index_t cyqlone::get_depth ( index_t n)
nodiscardconstexpr
Examples
test/test-pcr.cpp.

Definition at line 23 of file test-pcr.cpp.

◆ λ_max_power()

template<class Mat>
auto cyqlone::λ_max_power ( const Mat & M,
const Mat & K,
int max_it,
typename Mat::value_type tol )
Examples
test/test-pcr.cpp.

Definition at line 105 of file test-pcr.cpp.

◆ unpacked()

template<class M>
auto cyqlone::unpacked ( const M & matrix)
Examples
test/test-pcr.cpp.

Definition at line 128 of file test-pcr.cpp.

◆ simdify()

auto batmat::linalg::simdify ( simdifiable auto && a) -> simdified_view_t< decltype(a)>