alpaqa matlab
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
DLControlProblem Class Reference

#include <alpaqa/dl/dl-problem.hpp>

Detailed Description

Class that loads an optimal control problem using dlopen.

The shared library should export a C function with the name function_name that accepts a void pointer with user data, and returns a struct of type alpaqa_control_problem_register_t that contains all data to represent the problem, as well as function pointers for all required operations.

Note
Copies are shallow, they all share the same problem instance, take that into account when using multiple threads.
See also
TypeErasedControlProblem

Definition at line 198 of file dl-problem.hpp.

+ Collaboration diagram for DLControlProblem:

Public Types

using Box = alpaqa::Box< config_t >
 
using instance_t = ExtraFuncs::instance_t
 

Public Member Functions

 DLControlProblem (const std::string &so_filename, const std::string &function_name="register_alpaqa_control_problem", void *user_param=nullptr)
 Load a problem from a shared library.
 
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 check () const
 
void get_U (Box &U) const
 
void get_D (Box &D) const
 
void get_D_N (Box &D) 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_constr_N (crvec x, rvec c) const
 
void eval_grad_constr_prod (index_t timestep, crvec x, crvec p, rvec grad_cx_p) const
 
void eval_grad_constr_prod_N (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_add_gn_hess_constr_N (crvec x, crvec M, rmat out) const
 
bool provides_get_D () const
 
bool provides_get_D_N () const
 
bool provides_eval_add_Q_N () const
 
bool provides_eval_add_R_prod_masked () const
 
bool provides_eval_add_S_prod_masked () const
 
bool provides_get_R_work_size () const
 
bool provides_get_S_work_size () const
 
bool provides_eval_constr () const
 
bool provides_eval_constr_N () const
 
bool provides_eval_grad_constr_prod () const
 
bool provides_eval_grad_constr_prod_N () const
 
bool provides_eval_add_gn_hess_constr () const
 
bool provides_eval_add_gn_hess_constr_N () const
 
template<class Signature , class... Args>
decltype(autocall_extra_func (const std::string &name, Args &&...args) const
 
template<class Signature , class... Args>
decltype(autocall_extra_func (const std::string &name, Args &&...args)
 

Private Attributes

std::shared_ptr< voidhandle
 Handle to the shared module defining the problem.
 
std::shared_ptr< voidinstance
 Problem instance created by the registration function, including the deleter to destroy it.
 
control_problem_functions_tfunctions = nullptr
 Pointer to the struct of function pointers for evaluating the objective, constraints, their gradients, etc.
 
ExtraFuncs extra_funcs
 Dictionary of extra functions that were registered by the problem.
 

Member Typedef Documentation

◆ Box

using Box = alpaqa::Box<config_t>

Definition at line 201 of file dl-problem.hpp.

◆ instance_t

using instance_t = ExtraFuncs::instance_t

Definition at line 280 of file dl-problem.hpp.

Constructor & Destructor Documentation

◆ DLControlProblem()

DLControlProblem ( const std::string &  so_filename,
const std::string &  function_name = "register_alpaqa_control_problem",
void user_param = nullptr 
)

Load a problem from a shared library.

Parameters
so_filenameFilename of the shared library to load.
function_nameName of the problem registration function. Should have signature alpaqa_control_problem_register_t(void *).
user_paramPointer to custom user data to pass to the registration function.

Definition at line 265 of file dl-problem.cpp.

Member Function Documentation

◆ get_N()

length_t get_N ( ) const
inline

Definition at line 226 of file dl-problem.hpp.

◆ get_nx()

length_t get_nx ( ) const
inline

Definition at line 227 of file dl-problem.hpp.

◆ get_nu()

length_t get_nu ( ) const
inline

Definition at line 228 of file dl-problem.hpp.

◆ get_nh()

length_t get_nh ( ) const
inline

Definition at line 229 of file dl-problem.hpp.

◆ get_nh_N()

length_t get_nh_N ( ) const
inline

Definition at line 230 of file dl-problem.hpp.

◆ get_nc()

length_t get_nc ( ) const
inline

Definition at line 231 of file dl-problem.hpp.

◆ get_nc_N()

length_t get_nc_N ( ) const
inline

Definition at line 232 of file dl-problem.hpp.

◆ check()

void check ( ) const
inline

Definition at line 234 of file dl-problem.hpp.

◆ get_U()

auto get_U ( Box U) const

Definition at line 300 of file dl-problem.cpp.

◆ get_D()

auto get_D ( Box D) const

Definition at line 301 of file dl-problem.cpp.

◆ get_D_N()

auto get_D_N ( Box D) const

Definition at line 302 of file dl-problem.cpp.

◆ get_x_init()

auto get_x_init ( rvec  x_init) const

Definition at line 303 of file dl-problem.cpp.

◆ eval_f()

auto eval_f ( index_t  timestep,
crvec  x,
crvec  u,
rvec  fxu 
) const

Definition at line 304 of file dl-problem.cpp.

◆ eval_jac_f()

auto eval_jac_f ( index_t  timestep,
crvec  x,
crvec  u,
rmat  J_fxu 
) const

Definition at line 305 of file dl-problem.cpp.

◆ eval_grad_f_prod()

auto eval_grad_f_prod ( index_t  timestep,
crvec  x,
crvec  u,
crvec  p,
rvec  grad_fxu_p 
) const

Definition at line 306 of file dl-problem.cpp.

◆ eval_h()

auto eval_h ( index_t  timestep,
crvec  x,
crvec  u,
rvec  h 
) const

Definition at line 307 of file dl-problem.cpp.

◆ eval_h_N()

auto eval_h_N ( crvec  x,
rvec  h 
) const

Definition at line 308 of file dl-problem.cpp.

◆ eval_l()

auto eval_l ( index_t  timestep,
crvec  h 
) const

Definition at line 309 of file dl-problem.cpp.

◆ eval_l_N()

auto eval_l_N ( crvec  h) const

Definition at line 310 of file dl-problem.cpp.

◆ eval_qr()

auto eval_qr ( index_t  timestep,
crvec  xu,
crvec  h,
rvec  qr 
) const

Definition at line 311 of file dl-problem.cpp.

◆ eval_q_N()

auto eval_q_N ( crvec  x,
crvec  h,
rvec  q 
) const

Definition at line 312 of file dl-problem.cpp.

◆ eval_add_Q()

auto eval_add_Q ( index_t  timestep,
crvec  xu,
crvec  h,
rmat  Q 
) const

Definition at line 313 of file dl-problem.cpp.

◆ eval_add_Q_N()

auto eval_add_Q_N ( crvec  x,
crvec  h,
rmat  Q 
) const

Definition at line 314 of file dl-problem.cpp.

◆ eval_add_R_masked()

auto eval_add_R_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask,
rmat  R,
rvec  work 
) const

Definition at line 315 of file dl-problem.cpp.

◆ eval_add_S_masked()

auto eval_add_S_masked ( index_t  timestep,
crvec  xu,
crvec  h,
crindexvec  mask,
rmat  S,
rvec  work 
) const

Definition at line 316 of file dl-problem.cpp.

◆ eval_add_R_prod_masked()

auto 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 317 of file dl-problem.cpp.

◆ eval_add_S_prod_masked()

auto 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 318 of file dl-problem.cpp.

◆ get_R_work_size()

auto get_R_work_size ( ) const

Definition at line 319 of file dl-problem.cpp.

◆ get_S_work_size()

auto get_S_work_size ( ) const

Definition at line 320 of file dl-problem.cpp.

◆ eval_constr()

auto eval_constr ( index_t  timestep,
crvec  x,
rvec  c 
) const

Definition at line 321 of file dl-problem.cpp.

◆ eval_constr_N()

auto eval_constr_N ( crvec  x,
rvec  c 
) const

Definition at line 322 of file dl-problem.cpp.

◆ eval_grad_constr_prod()

auto eval_grad_constr_prod ( index_t  timestep,
crvec  x,
crvec  p,
rvec  grad_cx_p 
) const

Definition at line 323 of file dl-problem.cpp.

◆ eval_grad_constr_prod_N()

auto eval_grad_constr_prod_N ( crvec  x,
crvec  p,
rvec  grad_cx_p 
) const

Definition at line 324 of file dl-problem.cpp.

◆ eval_add_gn_hess_constr()

auto eval_add_gn_hess_constr ( index_t  timestep,
crvec  x,
crvec  M,
rmat  out 
) const

Definition at line 325 of file dl-problem.cpp.

◆ eval_add_gn_hess_constr_N()

auto eval_add_gn_hess_constr_N ( crvec  x,
crvec  M,
rmat  out 
) const

Definition at line 326 of file dl-problem.cpp.

◆ provides_get_D()

bool provides_get_D ( ) const

Definition at line 328 of file dl-problem.cpp.

◆ provides_get_D_N()

bool provides_get_D_N ( ) const

Definition at line 329 of file dl-problem.cpp.

◆ provides_eval_add_Q_N()

bool provides_eval_add_Q_N ( ) const

Definition at line 330 of file dl-problem.cpp.

◆ provides_eval_add_R_prod_masked()

bool provides_eval_add_R_prod_masked ( ) const

Definition at line 331 of file dl-problem.cpp.

◆ provides_eval_add_S_prod_masked()

bool provides_eval_add_S_prod_masked ( ) const

Definition at line 332 of file dl-problem.cpp.

◆ provides_get_R_work_size()

bool provides_get_R_work_size ( ) const

Definition at line 333 of file dl-problem.cpp.

◆ provides_get_S_work_size()

bool provides_get_S_work_size ( ) const

Definition at line 334 of file dl-problem.cpp.

◆ provides_eval_constr()

bool provides_eval_constr ( ) const

Definition at line 335 of file dl-problem.cpp.

◆ provides_eval_constr_N()

bool provides_eval_constr_N ( ) const

Definition at line 336 of file dl-problem.cpp.

◆ provides_eval_grad_constr_prod()

bool provides_eval_grad_constr_prod ( ) const

Definition at line 337 of file dl-problem.cpp.

◆ provides_eval_grad_constr_prod_N()

bool provides_eval_grad_constr_prod_N ( ) const

Definition at line 338 of file dl-problem.cpp.

◆ provides_eval_add_gn_hess_constr()

bool provides_eval_add_gn_hess_constr ( ) const

Definition at line 339 of file dl-problem.cpp.

◆ provides_eval_add_gn_hess_constr_N()

bool provides_eval_add_gn_hess_constr_N ( ) const

Definition at line 340 of file dl-problem.cpp.

◆ call_extra_func() [1/2]

template<class Signature , class... Args>
decltype(auto) call_extra_func ( const std::string &  name,
Args &&...  args 
) const
inline

Definition at line 283 of file dl-problem.hpp.

+ Here is the call graph for this function:

◆ call_extra_func() [2/2]

template<class Signature , class... Args>
decltype(auto) call_extra_func ( const std::string &  name,
Args &&...  args 
)
inline

Definition at line 291 of file dl-problem.hpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ handle

std::shared_ptr<void> handle
private

Handle to the shared module defining the problem.

Definition at line 215 of file dl-problem.hpp.

◆ instance

std::shared_ptr<void> instance
private

Problem instance created by the registration function, including the deleter to destroy it.

Definition at line 218 of file dl-problem.hpp.

◆ functions

control_problem_functions_t* functions = nullptr
private

Pointer to the struct of function pointers for evaluating the objective, constraints, their gradients, etc.

Definition at line 221 of file dl-problem.hpp.

◆ extra_funcs

ExtraFuncs extra_funcs
private

Dictionary of extra functions that were registered by the problem.

Definition at line 223 of file dl-problem.hpp.


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