#include <alpaqa/dl/dl-problem.hpp>
Class that loads a 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_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 and problems/sparse-logistic-regression.cpp for examples.
Definition at line 103 of file dl-problem.hpp.
Public Types | |
using | Sparsity = alpaqa::Sparsity< config_t > |
using | instance_t = ExtraFuncs::instance_t |
using | Box = alpaqa::Box< config_t > |
Static Public Member Functions | |
static real_t | eval_proj_grad_step_box (const Box &C, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) |
Projected gradient step for rectangular box C. | |
static void | eval_prox_grad_step_box_l1_impl (const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) |
Proximal gradient step for rectangular box C with ℓ₁-regularization. | |
static real_t | eval_prox_grad_step_box_l1 (const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) |
Proximal gradient step for rectangular box C with ℓ₁-regularization. | |
static real_t | eval_prox_grad_step_box_l1_scal (const Box &C, real_t λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) |
Proximal gradient step for rectangular box C with ℓ₁-regularization. | |
static void | eval_proj_multipliers_box (const Box &D, rvec y, real_t M, index_t penalty_alm_split) |
Public Attributes | |
length_t | n |
Number of decision variables, dimension of x. | |
length_t | m |
Number of constraints, dimension of g(x) and z. | |
Box | C |
Constraints of the decision variables, \( x \in C \). | |
Box | D |
Other constraints, \( g(x) \in D \). | |
vec | l1_reg |
\( \ell_1 \) (1-norm) regularization parameter. | |
index_t | penalty_alm_split |
Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method. | |
Private Attributes | |
std::filesystem::path | file |
Path to the shared module file. | |
std::shared_ptr< void > | handle |
Handle to the shared module defining the problem. | |
std::shared_ptr< void > | instance |
Problem instance created by the registration function, including the deleter to destroy it. | |
problem_functions_t * | functions = 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. | |
using Sparsity = alpaqa::Sparsity<config_t> |
Definition at line 106 of file dl-problem.hpp.
using instance_t = ExtraFuncs::instance_t |
Definition at line 212 of file dl-problem.hpp.
|
inherited |
Definition at line 19 of file box-constr-problem.hpp.
DLProblem | ( | const std::filesystem::path & | so_filename, |
const std::string & | function_name = "register_alpaqa_problem" , |
||
alpaqa_register_arg_t | user_param = {} , |
||
DynamicLoadFlags | dl_flags = {} |
||
) |
Load a problem from a shared library.
so_filename | Filename of the shared library to load. |
function_name | Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param) . |
user_param | Pointer to custom user data to pass to the registration function. |
dl_flags | Flags passed to dlopen when loading the problem. |
Definition at line 137 of file dl-problem.cpp.
DLProblem | ( | const std::filesystem::path & | so_filename, |
const std::string & | function_name, | ||
std::any & | user_param, | ||
DynamicLoadFlags | dl_flags = {} |
||
) |
Load a problem from a shared library.
so_filename | Filename of the shared library to load. |
function_name | Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param) . |
user_param | Custom user data to pass to the registration function. |
dl_flags | Flags passed to dlopen when loading the problem. |
Definition at line 206 of file dl-problem.cpp.
DLProblem | ( | const std::filesystem::path & | so_filename, |
const std::string & | function_name, | ||
std::span< std::string_view > | user_param, | ||
DynamicLoadFlags | dl_flags = {} |
||
) |
Load a problem from a shared library.
so_filename | Filename of the shared library to load. |
function_name | Name of the problem registration function. Should have signature alpaqa_problem_register_t(alpaqa_register_arg_t user_param) . |
user_param | Custom string arguments to pass to the registration function. |
dl_flags | Flags passed to dlopen when loading the problem. |
Definition at line 214 of file dl-problem.cpp.
Definition at line 243 of file dl-problem.cpp.
Definition at line 259 of file dl-problem.cpp.
Definition at line 260 of file dl-problem.cpp.
Definition at line 261 of file dl-problem.cpp.
Definition at line 262 of file dl-problem.cpp.
Definition at line 264 of file dl-problem.cpp.
auto get_jac_g_sparsity | ( | ) | const |
Definition at line 265 of file dl-problem.cpp.
Definition at line 263 of file dl-problem.cpp.
Definition at line 266 of file dl-problem.cpp.
Definition at line 267 of file dl-problem.cpp.
auto get_hess_L_sparsity | ( | ) | const |
Definition at line 268 of file dl-problem.cpp.
Definition at line 269 of file dl-problem.cpp.
Definition at line 270 of file dl-problem.cpp.
auto get_hess_ψ_sparsity | ( | ) | const |
Definition at line 271 of file dl-problem.cpp.
Definition at line 272 of file dl-problem.cpp.
Definition at line 273 of file dl-problem.cpp.
Definition at line 274 of file dl-problem.cpp.
Definition at line 275 of file dl-problem.cpp.
Definition at line 276 of file dl-problem.cpp.
Definition at line 277 of file dl-problem.cpp.
Definition at line 278 of file dl-problem.cpp.
auto get_name | ( | ) | const |
Definition at line 252 of file dl-problem.cpp.
bool provides_eval_f | ( | ) | const |
Definition at line 280 of file dl-problem.cpp.
bool provides_eval_grad_f | ( | ) | const |
Definition at line 281 of file dl-problem.cpp.
bool provides_eval_g | ( | ) | const |
Definition at line 282 of file dl-problem.cpp.
bool provides_eval_grad_g_prod | ( | ) | const |
Definition at line 283 of file dl-problem.cpp.
bool provides_eval_jac_g | ( | ) | const |
Definition at line 284 of file dl-problem.cpp.
bool provides_get_jac_g_sparsity | ( | ) | const |
Definition at line 285 of file dl-problem.cpp.
bool provides_eval_grad_gi | ( | ) | const |
Definition at line 286 of file dl-problem.cpp.
bool provides_eval_hess_L_prod | ( | ) | const |
Definition at line 287 of file dl-problem.cpp.
bool provides_eval_hess_L | ( | ) | const |
Definition at line 288 of file dl-problem.cpp.
bool provides_get_hess_L_sparsity | ( | ) | const |
Definition at line 289 of file dl-problem.cpp.
bool provides_eval_hess_ψ_prod | ( | ) | const |
Definition at line 290 of file dl-problem.cpp.
bool provides_eval_hess_ψ | ( | ) | const |
Definition at line 291 of file dl-problem.cpp.
bool provides_get_hess_ψ_sparsity | ( | ) | const |
Definition at line 292 of file dl-problem.cpp.
bool provides_eval_f_grad_f | ( | ) | const |
Definition at line 293 of file dl-problem.cpp.
bool provides_eval_f_g | ( | ) | const |
Definition at line 294 of file dl-problem.cpp.
bool provides_eval_grad_f_grad_g_prod | ( | ) | const |
Definition at line 295 of file dl-problem.cpp.
bool provides_eval_grad_L | ( | ) | const |
Definition at line 296 of file dl-problem.cpp.
bool provides_eval_ψ | ( | ) | const |
Definition at line 297 of file dl-problem.cpp.
bool provides_eval_grad_ψ | ( | ) | const |
Definition at line 298 of file dl-problem.cpp.
bool provides_eval_ψ_grad_ψ | ( | ) | const |
Definition at line 299 of file dl-problem.cpp.
bool provides_get_box_C | ( | ) | const |
bool provides_get_box_D | ( | ) | const |
Definition at line 301 of file dl-problem.cpp.
bool provides_eval_inactive_indices_res_lna | ( | ) | const |
Definition at line 302 of file dl-problem.cpp.
Definition at line 215 of file dl-problem.hpp.
Change the dimensions of the problem (number of decision variables and number of constaints).
Destructive: resizes and/or resets the members C, D, l1_reg and penalty_alm_split.
n | Number of decision variables |
m | Number of constraints |
Definition at line 45 of file box-constr-problem.hpp.
|
inlineinherited |
Number of decision variables, n.
Definition at line 81 of file box-constr-problem.hpp.
|
inlineinherited |
Number of constraints, m.
Definition at line 83 of file box-constr-problem.hpp.
|
inlinestaticinherited |
Projected gradient step for rectangular box C.
\[ \begin{aligned} \hat x &= \Pi_C(x - \gamma\nabla\psi(x)) \\ p &= \hat x - x \\ &= \max(\underline x - x, \;\min(-\gamma\nabla\psi(x), \overline x - x) \end{aligned} \]
Definition at line 90 of file box-constr-problem.hpp.
|
inlinestaticinherited |
Proximal gradient step for rectangular box C with ℓ₁-regularization.
\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]
Definition at line 113 of file box-constr-problem.hpp.
|
inlinestaticinherited |
Proximal gradient step for rectangular box C with ℓ₁-regularization.
\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]
Definition at line 122 of file box-constr-problem.hpp.
|
inlinestaticinherited |
Proximal gradient step for rectangular box C with ℓ₁-regularization.
\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]
Definition at line 130 of file box-constr-problem.hpp.
|
inlinestaticinherited |
Definition at line 152 of file box-constr-problem.hpp.
Definition at line 173 of file box-constr-problem.hpp.
Definition at line 175 of file box-constr-problem.hpp.
|
private |
Path to the shared module file.
Definition at line 147 of file dl-problem.hpp.
|
private |
Handle to the shared module defining the problem.
Definition at line 149 of file dl-problem.hpp.
|
private |
Problem instance created by the registration function, including the deleter to destroy it.
Definition at line 152 of file dl-problem.hpp.
|
private |
Pointer to the struct of function pointers for evaluating the objective, constraints, their gradients, etc.
Definition at line 155 of file dl-problem.hpp.
|
private |
Dictionary of extra functions that were registered by the problem.
Definition at line 157 of file dl-problem.hpp.
|
inherited |
Number of decision variables, dimension of x.
Definition at line 22 of file box-constr-problem.hpp.
|
inherited |
Number of constraints, dimension of g(x) and z.
Definition at line 24 of file box-constr-problem.hpp.
|
inherited |
Constraints of the decision variables, \( x \in C \).
Definition at line 65 of file box-constr-problem.hpp.
|
inherited |
Other constraints, \( g(x) \in D \).
Definition at line 67 of file box-constr-problem.hpp.
|
inherited |
\( \ell_1 \) (1-norm) regularization parameter.
Possible dimensions are: \( 0 \) (no regularization), \( 1 \) (a single scalar factor), or \( n \) (a different factor for each variable).
Definition at line 72 of file box-constr-problem.hpp.
|
inherited |
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 78 of file box-constr-problem.hpp.