#include <interop/dl/include/alpaqa/dl/dl-problem.hpp>
Class that loads an optimal control problem using dlopen
.
The shared library should export a C function with the name <symbol_prefix>_register
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. See C++/DLProblem/main.cpp
Definition at line 206 of file dl-problem.hpp.
Public Types | |
using | Box = alpaqa::Box< config_t > |
using | instance_t = DLLoader::instance_t |
Public Member Functions | |
DLControlProblem (std::string so_filename, std::string symbol_prefix="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(auto) | call_extra_func (const std::string &name, Args &&...args) const |
template<class Signature , class... Args> | |
decltype(auto) | call_extra_func (const std::string &name, Args &&...args) |
Private Types | |
using | dl_handle_t = std::shared_ptr< void > |
Private Member Functions | |
std::shared_ptr< void > | load_lib () const |
Open the shared library using dlopen | |
template<class F > | |
F * | load_func (std::string_view name) const |
Load a function with signature F from the library using dlsym . | |
template<class Signature > requires std::is_function_v<Signature> | |
const std::function< Signature > & | extra_func (const std::string &name) const |
template<class Ret , class... FArgs, class... Args> | |
decltype(auto) | call_extra_func_helper (const void *instance, FuncTag< Ret(const instance_t *, FArgs...)>, const std::string &name, Args &&...args) const |
template<class Ret , class... FArgs, class... Args> | |
decltype(auto) | call_extra_func_helper (void *instance, FuncTag< Ret(instance_t *, FArgs...)>, const std::string &name, Args &&...args) |
template<class Ret , class... FArgs, class... Args> | |
decltype(auto) | call_extra_func_helper (const void *, FuncTag< Ret(FArgs...)>, const std::string &name, Args &&...args) const |
Private Attributes | |
std::shared_ptr< void > | instance |
Problem instance created by the registration function, including the deleter to destroy it. | |
control_problem_functions_t * | functions = nullptr |
Pointer to the struct of function pointers for evaluating the objective, constraints, their gradients, etc. | |
std::string | so_filename |
std::string | symbol_prefix |
dl_handle_t | handle |
Handle to the shared library (returned by dlopen ). | |
std::shared_ptr< function_dict_t > | extra_functions |
An associative array of additional functions exposed by the problem. | |
using Box = alpaqa::Box<config_t> |
Definition at line 209 of file dl-problem.hpp.
using instance_t = DLLoader::instance_t |
Definition at line 283 of file dl-problem.hpp.
|
protectedinherited |
Definition at line 29 of file dl-problem.hpp.
DLControlProblem | ( | std::string | so_filename, |
std::string | symbol_prefix = "alpaqa_control_problem" , |
||
void * | user_param = nullptr |
||
) |
Load a problem from a shared library.
so_filename | Filename of the shared library to load. |
symbol_prefix | Prefix of the registration function. |
user_param | Pointer to custom user data to pass to the registration function. |
Definition at line 145 of file dl-problem.cpp.
|
inline |
Definition at line 229 of file dl-problem.hpp.
|
inline |
Definition at line 230 of file dl-problem.hpp.
|
inline |
Definition at line 231 of file dl-problem.hpp.
|
inline |
Definition at line 232 of file dl-problem.hpp.
|
inline |
Definition at line 233 of file dl-problem.hpp.
|
inline |
Definition at line 234 of file dl-problem.hpp.
|
inline |
Definition at line 235 of file dl-problem.hpp.
|
inline |
Definition at line 237 of file dl-problem.hpp.
auto get_U | ( | Box & | U | ) | const |
Definition at line 161 of file dl-problem.cpp.
auto get_D | ( | Box & | D | ) | const |
Definition at line 162 of file dl-problem.cpp.
auto get_D_N | ( | Box & | D | ) | const |
Definition at line 163 of file dl-problem.cpp.
auto get_x_init | ( | rvec | x_init | ) | const |
Definition at line 164 of file dl-problem.cpp.
Definition at line 165 of file dl-problem.cpp.
Definition at line 166 of file dl-problem.cpp.
Definition at line 167 of file dl-problem.cpp.
Definition at line 168 of file dl-problem.cpp.
Definition at line 169 of file dl-problem.cpp.
Definition at line 170 of file dl-problem.cpp.
auto eval_l_N | ( | crvec | h | ) | const |
Definition at line 171 of file dl-problem.cpp.
Definition at line 172 of file dl-problem.cpp.
Definition at line 173 of file dl-problem.cpp.
Definition at line 174 of file dl-problem.cpp.
Definition at line 175 of file dl-problem.cpp.
auto eval_add_R_masked | ( | index_t | timestep, |
crvec | xu, | ||
crvec | h, | ||
crindexvec | mask, | ||
rmat | R, | ||
rvec | work | ||
) | const |
Definition at line 176 of file dl-problem.cpp.
auto eval_add_S_masked | ( | index_t | timestep, |
crvec | xu, | ||
crvec | h, | ||
crindexvec | mask, | ||
rmat | S, | ||
rvec | work | ||
) | const |
Definition at line 177 of file dl-problem.cpp.
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 178 of file dl-problem.cpp.
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 179 of file dl-problem.cpp.
auto get_R_work_size | ( | ) | const |
Definition at line 180 of file dl-problem.cpp.
auto get_S_work_size | ( | ) | const |
Definition at line 181 of file dl-problem.cpp.
Definition at line 182 of file dl-problem.cpp.
Definition at line 183 of file dl-problem.cpp.
Definition at line 184 of file dl-problem.cpp.
Definition at line 185 of file dl-problem.cpp.
Definition at line 186 of file dl-problem.cpp.
Definition at line 187 of file dl-problem.cpp.
bool provides_get_D | ( | ) | const |
Definition at line 189 of file dl-problem.cpp.
bool provides_get_D_N | ( | ) | const |
Definition at line 190 of file dl-problem.cpp.
bool provides_eval_add_Q_N | ( | ) | const |
Definition at line 191 of file dl-problem.cpp.
bool provides_eval_add_R_prod_masked | ( | ) | const |
Definition at line 192 of file dl-problem.cpp.
bool provides_eval_add_S_prod_masked | ( | ) | const |
Definition at line 193 of file dl-problem.cpp.
bool provides_get_R_work_size | ( | ) | const |
Definition at line 194 of file dl-problem.cpp.
bool provides_get_S_work_size | ( | ) | const |
Definition at line 195 of file dl-problem.cpp.
bool provides_eval_constr | ( | ) | const |
Definition at line 196 of file dl-problem.cpp.
bool provides_eval_constr_N | ( | ) | const |
Definition at line 197 of file dl-problem.cpp.
bool provides_eval_grad_constr_prod | ( | ) | const |
Definition at line 198 of file dl-problem.cpp.
bool provides_eval_grad_constr_prod_N | ( | ) | const |
Definition at line 199 of file dl-problem.cpp.
bool provides_eval_add_gn_hess_constr | ( | ) | const |
Definition at line 200 of file dl-problem.cpp.
bool provides_eval_add_gn_hess_constr_N | ( | ) | const |
Definition at line 201 of file dl-problem.cpp.
|
inline |
Definition at line 286 of file dl-problem.hpp.
|
inline |
|
protectedinherited |
Open the shared library using dlopen
Definition at line 12 of file dl-problem.cpp.
|
protectedinherited |
Load a function with signature F
from the library using dlsym
.
Definition at line 22 of file dl-problem.cpp.
|
inlineprotectedinherited |
Definition at line 44 of file dl-problem.hpp.
|
inlineprotectedinherited |
Definition at line 71 of file dl-problem.hpp.
|
inlineprotectedinherited |
|
inlineprotectedinherited |
|
private |
Problem instance created by the registration function, including the deleter to destroy it.
Definition at line 223 of file dl-problem.hpp.
|
private |
Pointer to the struct of function pointers for evaluating the objective, constraints, their gradients, etc.
Definition at line 226 of file dl-problem.hpp.
|
protectedinherited |
Definition at line 26 of file dl-problem.hpp.
|
protectedinherited |
Definition at line 27 of file dl-problem.hpp.
|
protectedinherited |
Handle to the shared library (returned by dlopen
).
Definition at line 31 of file dl-problem.hpp.
|
protectedinherited |
An associative array of additional functions exposed by the problem.
Definition at line 34 of file dl-problem.hpp.