alpaqa pi-pico
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Types | Private Attributes | List of all members
CasADiControlProblem< Conf > Class Template Reference

#include <alpaqa/casadi/CasADiControlProblem.hpp>

Detailed Description

template<Config Conf>
class alpaqa::CasADiControlProblem< Conf >

Definition at line 21 of file CasADiControlProblem.hpp.

+ Collaboration diagram for CasADiControlProblem< Conf >:

Public Types

using Box = alpaqa::Box< config_t >
 

Public Member Functions

 CasADiControlProblem (const std::string &filename, length_t N, DynamicLoadFlags dl_flags={})
 
 ~CasADiControlProblem ()
 
 CasADiControlProblem (const CasADiControlProblem &)
 
CasADiControlProblemoperator= (const CasADiControlProblem &)
 
 CasADiControlProblem (CasADiControlProblem &&) noexcept
 
CasADiControlProblemoperator= (CasADiControlProblem &&) noexcept
 
void load_numerical_data (const std::filesystem::path &filepath, char sep=',')
 Load the numerical problem data (bounds and parameters) from a CSV file.
 
void get_U (Box &U) const
 
void get_D (Box &D) const
 
void get_D_N (Box &D_N) const
 
void get_x_init (rvec x_init) const
 
void eval_f (index_t timestep, crvec x, crvec u, rvec fxu) const
 
void eval_jac_f (index_t timestep, crvec x, crvec u, rmat J_fxu) const
 
void eval_grad_f_prod (index_t timestep, crvec x, crvec u, crvec p, rvec grad_fxu_p) const
 
void eval_h (index_t timestep, crvec x, crvec u, rvec h) const
 
void eval_h_N (crvec x, rvec h) const
 
real_t eval_l (index_t timestep, crvec h) const
 
real_t eval_l_N (crvec h) const
 
void eval_qr (index_t timestep, crvec xu, crvec h, rvec qr) const
 
void eval_q_N (crvec x, crvec h, rvec q) const
 
void eval_add_Q (index_t timestep, crvec xu, crvec h, rmat Q) const
 
void eval_add_Q_N (crvec x, crvec h, rmat Q) const
 
void eval_add_R_masked (index_t timestep, crvec xu, crvec h, crindexvec mask, rmat R, rvec work) const
 
void eval_add_S_masked (index_t timestep, crvec xu, crvec h, crindexvec mask, rmat S, rvec work) const
 
void eval_add_R_prod_masked (index_t timestep, crvec xu, crvec h, crindexvec mask_J, crindexvec mask_K, crvec v, rvec out, rvec work) const
 
void eval_add_S_prod_masked (index_t timestep, crvec xu, crvec h, crindexvec mask_K, crvec v, rvec out, rvec work) const
 
length_t get_R_work_size () const
 
length_t get_S_work_size () const
 
void eval_constr (index_t timestep, crvec x, rvec c) const
 
void eval_grad_constr_prod (index_t timestep, crvec x, crvec p, rvec grad_cx_p) const
 
void eval_add_gn_hess_constr (index_t timestep, crvec x, crvec M, rmat out) const
 
void eval_constr_N (crvec x, rvec c) const
 
void eval_grad_constr_prod_N (crvec x, crvec p, rvec grad_cx_p) const
 
void eval_add_gn_hess_constr_N (crvec x, crvec M, rmat out) const
 
void check () const
 
length_t get_N () const
 
length_t get_nx () const
 
length_t get_nu () const
 
length_t get_nh () const
 
length_t get_nh_N () const
 
length_t get_nc () const
 
length_t get_nc_N () const
 
void eval_proj_diff_g (crvec z, rvec e) const
 
void eval_proj_multipliers (rvec y, real_t M) const
 

Public Attributes

length_t N
 
length_t nx
 
length_t nu
 
length_t nh
 
length_t nh_N
 
length_t nc
 
length_t nc_N
 
vec x_init
 
vec param
 
Box U
 
Box D
 
Box D_N
 
vec work
 
index_t penalty_alm_split = 0
 Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.
 
index_t penalty_alm_split_N = 0
 Same as penalty_alm_split, but for the terminal constraint.
 

Private Types

using Functions = casadi_loader::CasADiControlFunctionsWithParam< Conf >
 

Private Attributes

util::copyable_unique_ptr< Functionsimpl
 

Member Typedef Documentation

◆ Box

template<Config Conf>
using Box = alpaqa::Box<config_t>

Definition at line 24 of file CasADiControlProblem.hpp.

◆ Functions

Definition at line 180 of file CasADiControlProblem.hpp.

Constructor & Destructor Documentation

◆ CasADiControlProblem() [1/3]

template<Config Conf>
CasADiControlProblem ( const std::string &  filename,
length_t  N,
DynamicLoadFlags  dl_flags = {} 
)

Definition at line 219 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:

◆ ~CasADiControlProblem()

template<Config Conf>
~CasADiControlProblem ( )
default

◆ CasADiControlProblem() [2/3]

template<Config Conf>
CasADiControlProblem ( const CasADiControlProblem< Conf > &  )
default

◆ CasADiControlProblem() [3/3]

template<Config Conf>
CasADiControlProblem ( CasADiControlProblem< Conf > &&  )
defaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

template<Config Conf>
CasADiControlProblem< Conf > & operator= ( const CasADiControlProblem< Conf > &  )
default

◆ operator=() [2/2]

template<Config Conf>
CasADiControlProblem< Conf > & operator= ( CasADiControlProblem< Conf > &&  )
defaultnoexcept

◆ load_numerical_data()

template<Config Conf>
void load_numerical_data ( const std::filesystem::path &  filepath,
char  sep = ',' 
)

Load the numerical problem data (bounds and parameters) from a CSV file.

The file should contain 8 rows, with the following contents:

  1. U lower bound [nu]
  2. U upper bound [nu]
  3. D lower bound [nc]
  4. D upper bound [nc]
  5. D_N lower bound [nc_N]
  6. D_N upper bound [nc_N]
  7. x_init [nx]
  8. param [p]

Line endings are encoded using a single line feed (\n), and the column separator can be specified using the sep argument.

Definition at line 266 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_U()

template<Config Conf>
void get_U ( Box U) const
inline

Definition at line 64 of file CasADiControlProblem.hpp.

◆ get_D()

template<Config Conf>
void get_D ( Box D) const
inline

Definition at line 65 of file CasADiControlProblem.hpp.

◆ get_D_N()

template<Config Conf>
void get_D_N ( Box D_N) const
inline

Definition at line 66 of file CasADiControlProblem.hpp.

◆ get_x_init()

template<Config Conf>
void get_x_init ( rvec  x_init) const
inline

Definition at line 67 of file CasADiControlProblem.hpp.

◆ eval_f()

template<Config Conf>
void eval_f ( index_t  timestep,
crvec  x,
crvec  u,
rvec  fxu 
) const

Definition at line 335 of file CasADiControlProblem.tpp.

◆ eval_jac_f()

template<Config Conf>
void eval_jac_f ( index_t  timestep,
crvec  x,
crvec  u,
rmat  J_fxu 
) const

Definition at line 343 of file CasADiControlProblem.tpp.

◆ eval_grad_f_prod()

template<Config Conf>
void eval_grad_f_prod ( index_t  timestep,
crvec  x,
crvec  u,
crvec  p,
rvec  grad_fxu_p 
) const

Definition at line 352 of file CasADiControlProblem.tpp.

◆ eval_h()

template<Config Conf>
void eval_h ( index_t  timestep,
crvec  x,
crvec  u,
rvec  h 
) const

Definition at line 363 of file CasADiControlProblem.tpp.

◆ eval_h_N()

template<Config Conf>
void eval_h_N ( crvec  x,
rvec  h 
) const

Definition at line 371 of file CasADiControlProblem.tpp.

◆ eval_l()

template<Config Conf>
auto eval_l ( index_t  timestep,
crvec  h 
) const

Definition at line 377 of file CasADiControlProblem.tpp.

◆ eval_l_N()

template<Config Conf>
auto eval_l_N ( crvec  h) const

Definition at line 384 of file CasADiControlProblem.tpp.

◆ eval_qr()

template<Config Conf>
void eval_qr ( index_t  timestep,
crvec  xu,
crvec  h,
rvec  qr 
) const

Definition at line 391 of file CasADiControlProblem.tpp.

◆ eval_q_N()

template<Config Conf>
void eval_q_N ( crvec  x,
crvec  h,
rvec  q 
) const

Definition at line 399 of file CasADiControlProblem.tpp.

◆ eval_add_Q()

template<Config Conf>
void eval_add_Q ( index_t  timestep,
crvec  xu,
crvec  h,
rmat  Q 
) const

Definition at line 406 of file CasADiControlProblem.tpp.

◆ eval_add_Q_N()

template<Config Conf>
void eval_add_Q_N ( crvec  x,
crvec  h,
rmat  Q 
) const

Definition at line 429 of file CasADiControlProblem.tpp.

◆ eval_add_R_masked()

template<Config Conf>
void eval_add_R_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask,
rmat  R,
rvec  work 
) const

Definition at line 452 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:

◆ eval_add_S_masked()

template<Config Conf>
void eval_add_S_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask,
rmat  S,
rvec  work 
) const

Definition at line 483 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:

◆ eval_add_R_prod_masked()

template<Config Conf>
void eval_add_R_prod_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask_J,
crindexvec  mask_K,
crvec  v,
rvec  out,
rvec  work 
) const

Definition at line 514 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:

◆ eval_add_S_prod_masked()

template<Config Conf>
void eval_add_S_prod_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask_K,
crvec  v,
rvec  out,
rvec  work 
) const

Definition at line 543 of file CasADiControlProblem.tpp.

+ Here is the call graph for this function:

◆ get_R_work_size()

template<Config Conf>
auto get_R_work_size ( ) const

Definition at line 572 of file CasADiControlProblem.tpp.

◆ get_S_work_size()

template<Config Conf>
auto get_S_work_size ( ) const

Definition at line 578 of file CasADiControlProblem.tpp.

◆ eval_constr()

template<Config Conf>
void eval_constr ( index_t  timestep,
crvec  x,
rvec  c 
) const

Definition at line 584 of file CasADiControlProblem.tpp.

◆ eval_grad_constr_prod()

template<Config Conf>
void eval_grad_constr_prod ( index_t  timestep,
crvec  x,
crvec  p,
rvec  grad_cx_p 
) const

Definition at line 593 of file CasADiControlProblem.tpp.

◆ eval_add_gn_hess_constr()

template<Config Conf>
void eval_add_gn_hess_constr ( index_t  timestep,
crvec  x,
crvec  M,
rmat  out 
) const

Definition at line 603 of file CasADiControlProblem.tpp.

◆ eval_constr_N()

template<Config Conf>
void eval_constr_N ( crvec  x,
rvec  c 
) const

Definition at line 629 of file CasADiControlProblem.tpp.

◆ eval_grad_constr_prod_N()

template<Config Conf>
void eval_grad_constr_prod_N ( crvec  x,
crvec  p,
rvec  grad_cx_p 
) const

Definition at line 638 of file CasADiControlProblem.tpp.

◆ eval_add_gn_hess_constr_N()

template<Config Conf>
void eval_add_gn_hess_constr_N ( crvec  x,
crvec  M,
rmat  out 
) const

Definition at line 647 of file CasADiControlProblem.tpp.

◆ check()

template<Config Conf>
void check ( ) const
inline

Definition at line 102 of file CasADiControlProblem.hpp.

+ Here is the call graph for this function:

◆ get_N()

template<Config Conf>
length_t get_N ( ) const
inline

Definition at line 127 of file CasADiControlProblem.hpp.

◆ get_nx()

template<Config Conf>
length_t get_nx ( ) const
inline

Definition at line 128 of file CasADiControlProblem.hpp.

◆ get_nu()

template<Config Conf>
length_t get_nu ( ) const
inline

Definition at line 129 of file CasADiControlProblem.hpp.

◆ get_nh()

template<Config Conf>
length_t get_nh ( ) const
inline

Definition at line 130 of file CasADiControlProblem.hpp.

◆ get_nh_N()

template<Config Conf>
length_t get_nh_N ( ) const
inline

Definition at line 131 of file CasADiControlProblem.hpp.

◆ get_nc()

template<Config Conf>
length_t get_nc ( ) const
inline

Definition at line 132 of file CasADiControlProblem.hpp.

◆ get_nc_N()

template<Config Conf>
length_t get_nc_N ( ) const
inline

Definition at line 133 of file CasADiControlProblem.hpp.

◆ eval_proj_diff_g()

template<Config Conf>
void eval_proj_diff_g ( crvec  z,
rvec  e 
) const
inline

◆ eval_proj_multipliers()

template<Config Conf>
void eval_proj_multipliers ( rvec  y,
real_t  M 
) const
inline

Member Data Documentation

◆ N

template<Config Conf>
length_t N

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nx

template<Config Conf>
length_t nx

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nu

template<Config Conf>
length_t nu

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nh

template<Config Conf>
length_t nh

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nh_N

template<Config Conf>
length_t nh_N

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nc

template<Config Conf>
length_t nc

Definition at line 25 of file CasADiControlProblem.hpp.

◆ nc_N

template<Config Conf>
length_t nc_N

Definition at line 25 of file CasADiControlProblem.hpp.

◆ x_init

template<Config Conf>
vec x_init

Definition at line 26 of file CasADiControlProblem.hpp.

◆ param

template<Config Conf>
vec param

Definition at line 27 of file CasADiControlProblem.hpp.

◆ U

template<Config Conf>
Box U

Definition at line 28 of file CasADiControlProblem.hpp.

◆ D

template<Config Conf>
Box D

Definition at line 28 of file CasADiControlProblem.hpp.

◆ D_N

template<Config Conf>
Box D_N

Definition at line 28 of file CasADiControlProblem.hpp.

◆ work

template<Config Conf>
vec work
mutable

Definition at line 29 of file CasADiControlProblem.hpp.

◆ penalty_alm_split

template<Config Conf>
index_t penalty_alm_split = 0

Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.

Specifically, the Lagrange multipliers for these components (which determine the shifts in ALM) are kept at zero.

Definition at line 35 of file CasADiControlProblem.hpp.

◆ penalty_alm_split_N

template<Config Conf>
index_t penalty_alm_split_N = 0

Same as penalty_alm_split, but for the terminal constraint.

Definition at line 37 of file CasADiControlProblem.hpp.

◆ impl

template<Config Conf>
util::copyable_unique_ptr<Functions> impl
private

Definition at line 181 of file CasADiControlProblem.hpp.


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