#include <stddef.h>#include <stdint.h>#include <any>#include <exception>#include <functional>#include <map>#include <string>Go to the source code of this file.
Classes | |
| struct | alpaqa_register_arg_t |
| User-provided argument that is passed to the problem registration functions. More... | |
| struct | alpaqa_dense_t |
| struct | alpaqa_sparse_csc_t |
| struct | alpaqa_sparse_csc_l_t |
| struct | alpaqa_sparse_csc_ll_t |
| struct | alpaqa_sparse_coo_t |
| struct | alpaqa_sparse_coo_l_t |
| struct | alpaqa_sparse_coo_ll_t |
| struct | alpaqa_sparsity_t |
| Sparsity of matrices. More... | |
| struct | alpaqa_problem_functions_t |
| C API providing function pointers to problem functions. More... | |
| struct | alpaqa_problem_register_t |
| struct | alpaqa_control_problem_functions_t |
| struct | alpaqa_control_problem_register_t |
| struct | alpaqa_function_dict_s |
| struct | alpaqa_exception_ptr_s |
| struct | function_wrapper_t< Signature > |
| Custom type for which we can export the RTTI to support std::any across shared library boundaries when using libc++. More... | |
| union | alpaqa_sparsity_t.__unnamed0__ |
Namespaces | |
| namespace | alpaqa |
| namespace | alpaqa::detail |
Macros | |
| #define | ALPAQA_DL_ABI_VERSION 0xA1A000000005 |
| #define | ALPAQA_DL_PROBLEM_EXPORT |
| #define | ALPAQA_DEFAULT(...) |
| #define | ALPAQA_PROBLEM_REGISTER_INIT(self) |
| Initialize an instance of alpaqa_problem_register_t or alpaqa_control_problem_register_t. | |
Enumerations | |
| enum | alpaqa_register_arg_type_t { alpaqa_register_arg_unspecified = 0 , alpaqa_register_arg_std_any = 1 , alpaqa_register_arg_strings = 2 , alpaqa_register_arg_py_args = 3 } |
| enum | alpaqa_symmetry { alpaqa_unsymmetric = 0 , alpaqa_upper = 1 , alpaqa_lower = 2 } |
Functions | |
| static void | alpaqa_problem_register_init (alpaqa_problem_register_t *self) |
| static void | alpaqa_control_problem_register_init (alpaqa_control_problem_register_t *self) |
| template<class Signature> | |
| function_wrapper_t (std::function< Signature >) -> function_wrapper_t< Signature > | |
| template<class Func> | |
| void | register_function (function_dict_t *&extra_functions, std::string name, Func &&func) |
| Make the given function available to alpaqa. | |
| template<class Func> | |
| void | register_function (problem_register_t &result, std::string name, Func &&func) |
| template<class Func> | |
| void | register_function (control_problem_register_t &result, std::string name, Func &&func) |
| template<class Result, class T, class Ret, class... Args> | |
| void | register_member_function (Result &result, std::string name, Ret(T::*member)(Args...)) |
| template<auto Member, class Class, class Ret, class... Args> | |
| static auto | member_caller (Ret(Class::*)(Args...)) |
| Overload for non-const-qualified member functions. | |
| template<auto Member, class Class, class Ret> | |
| static auto | member_caller (Ret Class::*) |
| Overload for member variables. | |
| template<auto Member> | |
| static auto | member_caller () |
| Wrap the given member function or variable into a (possibly generic) lambda function that accepts the instance as a type-erased void pointer. | |
| void | unregister_functions (function_dict_t *&extra_functions) |
| Cleans up the extra functions registered by register_function. | |
| struct alpaqa_register_arg_t |
| Class Members | ||
|---|---|---|
| void * | data {nullptr} |
Pointer to the user-provided argument passed to the problem registration functions. Use the type member to determine its type. |
| alpaqa_register_arg_type_t | type {alpaqa_register_arg_unspecified} | Specifies the type of the data pointed to by data. |
| struct alpaqa_dense_t |
| Class Members | ||
|---|---|---|
| alpaqa_length_t | rows {0} | |
| alpaqa_length_t | cols {0} | |
| alpaqa_symmetry | symmetry {alpaqa_unsymmetric} | |
| struct alpaqa_problem_functions_t |
| Class Members | ||
|---|---|---|
| alpaqa_length_t | num_variables {0} |
Number of decision variables.
|
| alpaqa_length_t | num_constraints {0} |
Number of constraints.
|
| const char * | name {nullptr} |
Name of the problem.
|
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *x) | eval_objective |
Cost function.
|
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *grad_fx) | eval_objective_gradient |
Gradient of the cost function.
|
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *gx) | eval_constraints |
Constraints function.
|
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, alpaqa_real_t *grad_gxy) | eval_constraints_gradient_product | Gradient-vector product of the constraints function. |
| void(*)(void *instance, const alpaqa_real_t *z, alpaqa_real_t *e) | eval_projecting_difference_constraints | Difference between point and its projection onto the general constraint set D. |
| void(*)(void *instance, alpaqa_real_t *y, alpaqa_real_t M) | eval_projection_multipliers |
Project the Lagrange multipliers.
|
| alpaqa_real_t(*)(void *instance, alpaqa_real_t γ, const alpaqa_real_t *x, const alpaqa_real_t *grad_ψ, alpaqa_real_t *x̂, alpaqa_real_t *p) | eval_proximal_gradient_step |
Proximal gradient step.
|
| alpaqa_index_t(*)(void *instance, alpaqa_real_t γ, const alpaqa_real_t *x, const alpaqa_real_t *grad_ψ, alpaqa_index_t *J) | eval_inactive_indices_res_lna |
Active indices for proximal operator.
|
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *J_values) | eval_constraints_jacobian |
Jacobian of the constraints function.
|
| alpaqa_sparsity_t(*)(void *instance) | get_constraints_jacobian_sparsity | Get the sparsity pattern of the Jacobian of the constraints function. |
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_index_t i, alpaqa_real_t *grad_gi) | eval_grad_gi |
Gradient of specific constraint function.
|
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, alpaqa_real_t scale, const alpaqa_real_t *v, alpaqa_real_t *Hv) | eval_lagrangian_hessian_product | Hessian-vector product of the Lagrangian. |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, alpaqa_real_t scale, alpaqa_real_t *H_values) | eval_lagrangian_hessian |
Hessian of the Lagrangian.
|
| alpaqa_sparsity_t(*)(void *instance) | get_lagrangian_hessian_sparsity | Get the sparsity pattern of the Hessian of the Lagrangian. |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, const alpaqa_real_t *Σ, alpaqa_real_t scale, const alpaqa_real_t *zl, const alpaqa_real_t *zu, const alpaqa_real_t *v, alpaqa_real_t *Hv) | eval_augmented_lagrangian_hessian_product | Hessian-vector product of the augmented Lagrangian. |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, const alpaqa_real_t *Σ, alpaqa_real_t scale, const alpaqa_real_t *zl, const alpaqa_real_t *zu, alpaqa_real_t *H_values) | eval_augmented_lagrangian_hessian | Hessian of the augmented Lagrangian. |
| alpaqa_sparsity_t(*)(void *instance) | get_augmented_lagrangian_hessian_sparsity | Get the sparsity pattern of the Hessian of the augmented Lagrangian. |
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *grad_fx) | eval_objective_and_gradient |
Cost and its gradient.
|
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *g) | eval_objective_and_constraints |
Cost and constraints.
|
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, alpaqa_real_t *grad_f, alpaqa_real_t *grad_gxy) | eval_objective_gradient_and_constraints_gradient_product | Gradient of the cost and gradient-vector product of the constraints. |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, alpaqa_real_t *grad_L, alpaqa_real_t *work_n) | eval_lagrangian_gradient |
Gradient of the Lagrangian.
|
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, const alpaqa_real_t *Σ, const alpaqa_real_t *zl, const alpaqa_real_t *zu, alpaqa_real_t *ŷ) | eval_augmented_lagrangian |
Augmented Lagrangian.
|
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, const alpaqa_real_t *Σ, const alpaqa_real_t *zl, const alpaqa_real_t *zu, alpaqa_real_t *grad_ψ, alpaqa_real_t *work_n, alpaqa_real_t *work_m) | eval_augmented_lagrangian_gradient | Gradient of the augmented Lagrangian. |
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *y, const alpaqa_real_t *Σ, const alpaqa_real_t *zl, const alpaqa_real_t *zu, alpaqa_real_t *grad_ψ, alpaqa_real_t *work_n, alpaqa_real_t *work_m) | eval_augmented_lagrangian_and_gradient | Augmented Lagrangian and its gradient. |
| void(*)(void *instance, alpaqa_real_t *lb, alpaqa_real_t *ub) | initialize_variable_bounds |
Provide the initial values for the bounds of variable_bounds, i.e. the box constraints on the decision variables. |
| void(*)(void *instance, alpaqa_real_t *lb, alpaqa_real_t *ub) | initialize_general_bounds |
Provide the initial values for the bounds of general_bounds, i.e. the general constraints. |
| void(*)(void *instance, alpaqa_real_t *lambda, alpaqa_length_t *size) | initialize_l1_reg |
Provide the initial values for l1_reg, the ℓ₁-regularization factor. This function is called twice:
|
| struct alpaqa_problem_register_t |
| Class Members | ||
|---|---|---|
| alpaqa_dl_abi_version_t | abi_version { 0xA1A000000005 } | To check whether the loaded problem is compatible with the version of the solver. |
| void * | instance {nullptr} | Owning pointer. |
| alpaqa_problem_functions_t * | functions {nullptr} | Non-owning pointer, lifetime at least as long as instance. |
| void(*)(void *) | cleanup | Pointer to the function to clean up instance. |
| alpaqa_function_dict_t * | extra_functions {nullptr} | Pointer to a map of extra functions (C++ only). |
| alpaqa_exception_ptr_t * | exception {nullptr} | Pointer to an exception that ocurred during problem creation. |
| struct alpaqa_control_problem_functions_t |
| Class Members | ||
|---|---|---|
| alpaqa_length_t | N {0} | |
| alpaqa_length_t | nx {0} | |
| alpaqa_length_t | nu {0} | |
| alpaqa_length_t | nh {0} | |
| alpaqa_length_t | nh_N {0} | |
| alpaqa_length_t | nc {0} | |
| alpaqa_length_t | nc_N {0} | |
| void(*)(void *instance, alpaqa_real_t *lb, alpaqa_real_t *ub) | get_U | |
| void(*)(void *instance, alpaqa_real_t *lb, alpaqa_real_t *ub) | get_D | |
| void(*)(void *instance, alpaqa_real_t *lb, alpaqa_real_t *ub) | get_D_N | |
| void(*)(void *instance, alpaqa_real_t *x_init) | get_x_init | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *u, alpaqa_real_t *fxu) | eval_f | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *u, alpaqa_real_t *J_fxu) | eval_jac_f | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *u, const alpaqa_real_t *p, alpaqa_real_t *grad_fxu_p) | eval_grad_f_prod | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *u, alpaqa_real_t *h) | eval_h | |
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *h) | eval_h_N | |
| alpaqa_real_t(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *h) | eval_l | |
| alpaqa_real_t(*)(void *instance, const alpaqa_real_t *h) | eval_l_N | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, alpaqa_real_t *qr) | eval_qr | |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *h, alpaqa_real_t *q) | eval_q_N | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, alpaqa_real_t *Q) | eval_add_Q | |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *h, alpaqa_real_t *Q) | eval_add_Q_N | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, const alpaqa_index_t *mask, alpaqa_real_t *R, alpaqa_real_t *work) | eval_add_R_masked | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, const alpaqa_index_t *mask, alpaqa_real_t *S, alpaqa_real_t *work) | eval_add_S_masked | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, const alpaqa_index_t *mask_J, const alpaqa_index_t *mask_K, const alpaqa_real_t *v, alpaqa_real_t *out, alpaqa_real_t *work) | eval_add_R_prod_masked | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *xu, const alpaqa_real_t *h, const alpaqa_index_t *mask_K, const alpaqa_real_t *v, alpaqa_real_t *out, alpaqa_real_t *work) | eval_add_S_prod_masked | |
| alpaqa_length_t(*)(void *instance) | get_R_work_size | |
| alpaqa_length_t(*)(void *instance) | get_S_work_size | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, alpaqa_real_t *c) | eval_constr | |
| void(*)(void *instance, const alpaqa_real_t *x, alpaqa_real_t *c) | eval_constr_N | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *p, alpaqa_real_t *grad_cx_p) | eval_grad_constr_prod | |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *p, alpaqa_real_t *grad_cx_p) | eval_grad_constr_prod_N | |
| void(*)(void *instance, alpaqa_index_t timestep, const alpaqa_real_t *x, const alpaqa_real_t *M, alpaqa_real_t *out) | eval_add_gn_hess_constr | |
| void(*)(void *instance, const alpaqa_real_t *x, const alpaqa_real_t *M, alpaqa_real_t *out) | eval_add_gn_hess_constr_N | |
| struct alpaqa_control_problem_register_t |
| Class Members | ||
|---|---|---|
| alpaqa_dl_abi_version_t | abi_version { 0xA1A000000005 } | To check whether the loaded problem is compatible with the version of the solver. |
| void * | instance {nullptr} | Owning pointer. |
| alpaqa_control_problem_functions_t * | functions {nullptr} | Non-owning pointer, lifetime at least as long as instance. |
| void(*)(void *) | cleanup | Pointer to the function to clean up instance. |
| alpaqa_function_dict_t * | extra_functions {nullptr} | Pointer to a map of extra functions (C++ only). |
| alpaqa_exception_ptr_t * | exception {nullptr} | Pointer to an exception that ocurred during problem creation. |
| struct alpaqa_function_dict_s |
| struct alpaqa_exception_ptr_s |
| struct alpaqa::detail::function_wrapper_t |
| union alpaqa_sparsity_t.__unnamed0__ |
| Class Members | ||
|---|---|---|
| alpaqa_dense_t | dense | |
| alpaqa_sparse_csc_t | sparse_csc | |
| alpaqa_sparse_csc_l_t | sparse_csc_l | |
| alpaqa_sparse_csc_ll_t | sparse_csc_ll | |
| alpaqa_sparse_coo_t | sparse_coo | |
| alpaqa_sparse_coo_l_t | sparse_coo_l | |
| alpaqa_sparse_coo_ll_t | sparse_coo_ll | |
| #define ALPAQA_DL_ABI_VERSION 0xA1A000000005 |
Definition at line 8 of file dl-problem.h.
| #define ALPAQA_DL_PROBLEM_EXPORT |
Definition at line 16 of file dl-problem.h.
| #define ALPAQA_DEFAULT | ( | ... | ) |
Definition at line 21 of file dl-problem.h.
| #define ALPAQA_PROBLEM_REGISTER_INIT | ( | self | ) |
Initialize an instance of alpaqa_problem_register_t or alpaqa_control_problem_register_t.
It initializes all members to zero, except for the ABI version, which is initialized to the current ABI version. Available in C only (unnecessary in C++).
| self | A pointer to the instance to initialize. |
Definition at line 661 of file dl-problem.h.
| typedef double alpaqa_real_t |
Definition at line 26 of file dl-problem.h.
| typedef ptrdiff_t alpaqa_length_t |
Definition at line 27 of file dl-problem.h.
| typedef alpaqa_length_t alpaqa_index_t |
Definition at line 28 of file dl-problem.h.
| typedef uint64_t alpaqa_dl_abi_version_t |
Definition at line 29 of file dl-problem.h.
| typedef struct alpaqa_register_arg_t alpaqa_register_arg_t |
Definition at line 68 of file dl-problem.h.
| typedef struct alpaqa_dense_t alpaqa_dense_t |
Definition at line 82 of file dl-problem.h.
| typedef struct alpaqa_problem_functions_t alpaqa_problem_functions_t |
Definition at line 432 of file dl-problem.h.
| typedef struct alpaqa_function_dict_s alpaqa_function_dict_t |
Opaque type for a C++-only map of extra functions.
Definition at line 435 of file dl-problem.h.
| typedef struct alpaqa_exception_ptr_s alpaqa_exception_ptr_t |
Opaque type for a C++-only exception pointer.
Definition at line 437 of file dl-problem.h.
| typedef struct alpaqa_problem_register_t alpaqa_problem_register_t |
Definition at line 460 of file dl-problem.h.
| typedef struct alpaqa_control_problem_functions_t alpaqa_control_problem_functions_t |
Definition at line 614 of file dl-problem.h.
| typedef struct alpaqa_control_problem_register_t alpaqa_control_problem_register_t |
Definition at line 636 of file dl-problem.h.
| Enumerator | |
|---|---|
| alpaqa_register_arg_unspecified | No type was specified (discouraged). |
| alpaqa_register_arg_std_any | The data pointer points to a C++ std::any object. Use reinterpret_cast<std::any *>(data) to convert back. Then use std::any_cast to get the actual value out.
|
| alpaqa_register_arg_strings | The data pointer points to a dynamic C++ std::span of std::string_view. Use reinterpret_cast<std::span<std::string_view> *>(data) to convert back. |
| alpaqa_register_arg_py_args | The data pointer points to a C++ tuple of pybind11::args and pybind11::kwargs. Use reinterpret_cast<std::tuple<pybind11::args, pybind11::kwargs> *>(data) to convert back. |
Definition at line 31 of file dl-problem.h.
| enum alpaqa_symmetry |
| Enumerator | |
|---|---|
| alpaqa_unsymmetric | |
| alpaqa_upper | |
| alpaqa_lower | |
Definition at line 71 of file dl-problem.h.
|
inlinestatic |
Definition at line 644 of file dl-problem.h.
|
inlinestatic |
Definition at line 650 of file dl-problem.h.