#include <alpaqa/casadi/CasADiProblem.hpp>
Problem definition for a CasADi problem, loaded from a DLL.
Definition at line 42 of file CasADiProblem.hpp.
Public Types | |
using | Sparsity = alpaqa::Sparsity< config_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 | |
vec | param |
std::string | name = "CasADiProblem" |
length_t | n |
Number of decision variables, dimension of x. | |
length_t | m |
Number of constraints, dimension of g(x) and z. | |
Box | C {this->n} |
Constraints of the decision variables, \( x \in C \). | |
Box | D {this->m} |
Other constraints, \( g(x) \in D \). | |
vec | l1_reg {} |
\( \ell_1 \) (1-norm) regularization parameter. | |
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. | |
Private Types | |
using | Functions = casadi_loader::CasADiFunctionsWithParam< Conf > |
Private Attributes | |
util::copyable_unique_ptr< Functions > | impl |
using Sparsity = alpaqa::Sparsity<config_t> |
Definition at line 45 of file CasADiProblem.hpp.
|
private |
Definition at line 138 of file CasADiProblem.hpp.
|
inherited |
Definition at line 19 of file box-constr-problem.hpp.
CasADiProblem | ( | const std::string & | filename, |
DynamicLoadFlags | dl_flags = {} |
||
) |
Load a problem generated by CasADi (with parameters).
filename | Filename of the shared library to load the functions from. |
dl_flags | Flags passed to dlopen when loading the problem. |
The file should contain functions with the names f
, grad_f
, g
and grad_g
. These functions evaluate the objective function, its gradient, the constraints, and the constraint gradient times a vector respectively. For second order solvers, additional functions hess_L
, hess_ψ
, hess_L_prod
and hess_ψ_prod
can be provided to evaluate the Hessian of the (augmented) Lagrangian and Hessian-vector products.
std::invalid_argument | The dimensions of the loaded functions do not match. |
Definition at line 139 of file CasADiProblem.tpp.
CasADiProblem | ( | const SerializedCasADiFunctions & | functions | ) |
Create a problem from a collection of serialized CasADi functions.
Definition at line 171 of file CasADiProblem.tpp.
CasADiProblem | ( | const CasADiFunctions & | functions | ) |
Create a problem from a collection of CasADi functions.
Definition at line 198 of file CasADiProblem.tpp.
|
default |
|
default |
|
defaultnoexcept |
|
default |
|
defaultnoexcept |
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 7 rows, with the following contents:
Line endings are encoded using a single line feed (\n
), and the column separator can be specified using the sep
argument.
Definition at line 220 of file CasADiProblem.tpp.
Definition at line 285 of file CasADiProblem.tpp.
Definition at line 292 of file CasADiProblem.tpp.
Definition at line 298 of file CasADiProblem.tpp.
Definition at line 305 of file CasADiProblem.tpp.
Definition at line 315 of file CasADiProblem.tpp.
void eval_grad_ψ | ( | crvec | x, |
crvec | y, | ||
crvec | Σ, | ||
rvec | grad_ψ, | ||
rvec | work_n, | ||
rvec | work_m | ||
) | const |
Definition at line 327 of file CasADiProblem.tpp.
CasADiProblem< Conf >::real_t eval_ψ_grad_ψ | ( | crvec | x, |
crvec | y, | ||
crvec | Σ, | ||
rvec | grad_ψ, | ||
rvec | work_n, | ||
rvec | work_m | ||
) | const |
Definition at line 342 of file CasADiProblem.tpp.
Definition at line 354 of file CasADiProblem.tpp.
CasADiProblem< Conf >::real_t eval_ψ | ( | crvec | x, |
crvec | y, | ||
crvec | Σ, | ||
rvec | ŷ | ||
) | const |
Definition at line 363 of file CasADiProblem.tpp.
Definition at line 374 of file CasADiProblem.tpp.
auto get_jac_g_sparsity | ( | ) | const |
Definition at line 394 of file CasADiProblem.tpp.
Definition at line 409 of file CasADiProblem.tpp.
void eval_hess_L_prod | ( | crvec | x, |
crvec | y, | ||
real_t | scale, | ||
crvec | v, | ||
rvec | Hv | ||
) | const |
Definition at line 416 of file CasADiProblem.tpp.
auto get_hess_L_sparsity | ( | ) | const |
Definition at line 425 of file CasADiProblem.tpp.
Definition at line 439 of file CasADiProblem.tpp.
void eval_hess_ψ_prod | ( | crvec | x, |
crvec | y, | ||
crvec | Σ, | ||
real_t | scale, | ||
crvec | v, | ||
rvec | Hv | ||
) | const |
Definition at line 448 of file CasADiProblem.tpp.
auto get_hess_ψ_sparsity | ( | ) | const |
Definition at line 460 of file CasADiProblem.tpp.
void eval_hess_ψ | ( | crvec | x, |
crvec | y, | ||
crvec | Σ, | ||
real_t | scale, | ||
rvec | H_values | ||
) | const |
Definition at line 474 of file CasADiProblem.tpp.
bool provides_eval_grad_L | ( | ) | const |
Definition at line 500 of file CasADiProblem.tpp.
bool provides_eval_ψ | ( | ) | const |
Definition at line 488 of file CasADiProblem.tpp.
bool provides_eval_grad_ψ | ( | ) | const |
Definition at line 492 of file CasADiProblem.tpp.
bool provides_eval_ψ_grad_ψ | ( | ) | const |
Definition at line 496 of file CasADiProblem.tpp.
bool provides_eval_grad_gi | ( | ) | const |
Definition at line 484 of file CasADiProblem.tpp.
bool provides_eval_jac_g | ( | ) | const |
Definition at line 504 of file CasADiProblem.tpp.
bool provides_eval_hess_L_prod | ( | ) | const |
Definition at line 508 of file CasADiProblem.tpp.
bool provides_eval_hess_L | ( | ) | const |
Definition at line 512 of file CasADiProblem.tpp.
bool provides_eval_hess_ψ_prod | ( | ) | const |
Definition at line 516 of file CasADiProblem.tpp.
bool provides_eval_hess_ψ | ( | ) | const |
Definition at line 520 of file CasADiProblem.tpp.
std::string get_name | ( | ) | const |
Definition at line 525 of file CasADiProblem.tpp.
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.
|
inlineinherited |
Definition at line 140 of file box-constr-problem.hpp.
Definition at line 168 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.
|
inlineinherited |
Only supported if the ℓ₁-regularization term is zero.
Definition at line 179 of file box-constr-problem.hpp.
vec param |
Definition at line 46 of file CasADiProblem.hpp.
std::string name = "CasADiProblem" |
Definition at line 47 of file CasADiProblem.hpp.
|
private |
Definition at line 139 of file CasADiProblem.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.
Constraints of the decision variables, \( x \in C \).
Definition at line 65 of file box-constr-problem.hpp.
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.