alpaqa 0.0.1
Nonconvex constrained optimization
CasADiLoader.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <string>
6
7namespace alpaqa {
8
9/// @addtogroup grp_ExternalProblemLoaders
10/// @{
11
12#if 0
13/// Load an objective function generated by CasADi.
14std::function<alpaqa::Problem::f_sig>
15load_CasADi_objective(const std::string &so_name,
16 const std::string &fun_name = "f");
17/// Load the gradient of an objective function generated by CasADi.
18std::function<alpaqa::Problem::grad_f_sig>
19load_CasADi_gradient_objective(const std::string &so_name,
20 const std::string &fun_name = "grad_f");
21/// Load a constraint function generated by CasADi.
22std::function<alpaqa::Problem::g_sig>
23load_CasADi_constraints(const std::string &so_name,
24 const std::string &fun_name = "g");
25/// Load the gradient-vector product of a constraint function generated by
26/// CasADi.
27std::function<alpaqa::Problem::grad_g_prod_sig>
28load_CasADi_gradient_constraints_prod(const std::string &so_name,
29 const std::string &fun_name = "grad_g");
30/// Load the Hessian of a Lagrangian function generated by CasADi.
31std::function<alpaqa::Problem::hess_L_sig>
32load_CasADi_hessian_lagrangian(const std::string &so_name,
33 const std::string &fun_name = "hess_L");
34/// Load the Hessian-vector product of a Lagrangian function generated by
35/// CasADi.
36std::function<alpaqa::Problem::hess_L_prod_sig> load_CasADi_hessian_lagrangian_prod(
37 const std::string &so_name, const std::string &fun_name = "hess_L_prod");
38#endif
39
40/// Load a problem generated by CasADi (without parameters).
41///
42/// @param filename
43/// Filename of the shared library to load the functions from.
44/// @param n
45/// Number of decision variables (@f$ x \in \mathbb{R}^n @f$).
46/// @param m
47/// Number of general constraints (@f$ g(x) \in \mathbb{R}^m @f$).
48/// @param second_order
49/// Load the additional functions required for second-order PANOC.
50///
51/// The file should contain functions with the names `f`, `grad_f`, `g` and
52/// `grad_g`. These functions evaluate the objective function, its gradient,
53/// the constraints, and the constraint gradient times a vector respecitvely.
54/// If @p second_order is true, additional functions `hess_L` and
55/// `hess_L_prod` should be provided to evaluate the Hessian of the Lagrangian
56/// and Hessian-vector products.
57///
58/// If any of the dimensions are zero, they are determined from the `g` function
59/// in the given file.
60///
61/// @throws std::invalid_argument
62/// The dimensions of the loaded functions do not match.
63alpaqa::Problem load_CasADi_problem(const std::string &filename, unsigned n = 0,
64 unsigned m = 0, bool second_order = false);
65/// Load a problem generated by CasADi (with parameters).
66///
67/// @param filename
68/// Filename of the shared library to load the functions from.
69/// @param n
70/// Number of decision variables (@f$ x \in \mathbb{R}^n @f$).
71/// @param m
72/// Number of general constraints (@f$ g(x) \in \mathbb{R}^m @f$).
73/// @param p
74/// The number of parameters of the problem (second argument to all
75/// CasADi functions).
76/// @param second_order
77/// Load the additional functions required for second-order PANOC.
78///
79/// The file should contain functions with the names `f`, `grad_f`, `g` and
80/// `grad_g`. These functions evaluate the objective function, its gradient,
81/// the constraints, and the constraint gradient times a vector respecitvely.
82/// If @p second_order is true, additional functions `hess_L` and
83/// `hess_L_prod` should be provided to evaluate the Hessian of the Lagrangian
84/// and Hessian-vector products.
85///
86/// If any of the dimensions are zero, they are determined from the `g` function
87/// in the given file.
88///
89/// @throws std::invalid_argument
90/// The dimensions of the loaded functions do not match.
91///
92ProblemWithParam load_CasADi_problem_with_param(const std::string &filename,
93 unsigned n = 0, unsigned m = 0,
94 unsigned p = 0,
95 bool second_order = false);
96
97/// @}
98
99} // namespace alpaqa
ProblemWithParam load_CasADi_problem_with_param(const std::string &filename, unsigned n=0, unsigned m=0, unsigned p=0, bool second_order=false)
Load a problem generated by CasADi (with parameters).
alpaqa::Problem load_CasADi_problem(const std::string &filename, unsigned n=0, unsigned m=0, bool second_order=false)
Load a problem generated by CasADi (without parameters).
int m
Definition: test.py:41
int n
Definition: test.py:40
Problem description for minimization problems.