alpaqa 1.0.0a10
Nonconvex constrained optimization
Loading...
Searching...
No Matches
dl-problem.h
Go to the documentation of this file.
1// NOLINTBEGIN(modernize-use-using,modernize-deprecated-headers)
2
3#pragma once
4
5#include <stddef.h>
6#include <stdint.h>
7#include <string.h>
8
9#define ALPAQA_DL_ABI_VERSION 0xA1A000000001
10
11#ifdef __cplusplus
12extern "C" {
13#define ALPAQA_DEFAULT(...) \
14 { __VA_ARGS__ }
15#else
16#define ALPAQA_DEFAULT(...)
17#endif
18
19typedef double alpaqa_real_t;
20typedef ptrdiff_t alpaqa_length_t;
22
23/// C API providing function pointers to problem functions.
24/// Used by @ref alpaqa::dl::DLProblem.
25typedef struct {
26 /// Number of decision variables.
27 /// @see @ref alpaqa::TypeErasedProblem::get_n()
29 /// Number of constraints.
30 /// @see @ref alpaqa::TypeErasedProblem::get_m()
32
33 // clang-format off
34 /// Cost function.
35 /// @see @ref alpaqa::TypeErasedProblem::eval_f()
36 alpaqa_real_t (*eval_f)(
37 void *instance,
38 const alpaqa_real_t *x) ALPAQA_DEFAULT(nullptr);
39 /// Gradient of the cost function.
40 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_f()
41 void (*eval_grad_f)(
42 void *instance,
43 const alpaqa_real_t *x,
44 alpaqa_real_t *grad_fx) ALPAQA_DEFAULT(nullptr);
45 /// Constraints function.
46 /// @see @ref alpaqa::TypeErasedProblem::eval_g()
47 void (*eval_g)(
48 void *instance,
49 const alpaqa_real_t *x,
50 alpaqa_real_t *gx) ALPAQA_DEFAULT(nullptr);
51 /// Gradient-vector product of the constraints function.
52 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_g_prod()
53 void (*eval_grad_g_prod)(
54 void *instance,
55 const alpaqa_real_t *x,
56 const alpaqa_real_t *y,
57 alpaqa_real_t *grad_gxy) ALPAQA_DEFAULT(nullptr);
58 /// Jacobian of the constraints function.
59 /// @see @ref alpaqa::TypeErasedProblem::eval_jac_g()
60 void (*eval_jac_g)(
61 void *instance,
62 const alpaqa_real_t *x,
63 alpaqa_index_t *inner_idx,
64 alpaqa_index_t *outer_ptr,
65 alpaqa_real_t *J_values) ALPAQA_DEFAULT(nullptr);
66 /// Number of nonzeros of the sparse Jacobian of the constraints function.
67 /// @see @ref alpaqa::TypeErasedProblem::get_jac_g_num_nonzeros()
68 alpaqa_length_t (*get_jac_g_num_nonzeros)(
69 void *instance) ALPAQA_DEFAULT(nullptr);
70 /// Gradient of specific constraint function.
71 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_gi()
72 void (*eval_grad_gi)(
73 void *instance,
74 const alpaqa_real_t *x,
76 alpaqa_real_t *grad_gi) ALPAQA_DEFAULT(nullptr);
77 /// Hessian-vector product of the Lagrangian.
78 /// @see @ref alpaqa::TypeErasedProblem::eval_hess_L_prod()
79 void (*eval_hess_L_prod)(
80 void *instance,
81 const alpaqa_real_t *x,
82 const alpaqa_real_t *y,
83 alpaqa_real_t scale,
84 const alpaqa_real_t *v,
85 alpaqa_real_t *Hv) ALPAQA_DEFAULT(nullptr);
86 /// Hessian of the Lagrangian.
87 /// @see @ref alpaqa::TypeErasedProblem::eval_hess_L()
88 void (*eval_hess_L)(
89 void *instance,
90 const alpaqa_real_t *x,
91 const alpaqa_real_t *y,
92 alpaqa_real_t scale,
93 alpaqa_index_t *inner_idx,
94 alpaqa_index_t *outer_ptr,
95 alpaqa_real_t *H_values) ALPAQA_DEFAULT(nullptr);
96 /// Number of nonzeros of the sparse Hessian of the Lagrangian.
97 /// @see @ref alpaqa::TypeErasedProblem::get_hess_L_num_nonzeros()
98 alpaqa_length_t (*get_hess_L_num_nonzeros)(
99 void *instance) ALPAQA_DEFAULT(nullptr);
100 /// Hessian-vector product of the augmented Lagrangian.
101 /// @see @ref alpaqa::TypeErasedProblem::eval_hess_ψ_prod()
102 void (*eval_hess_ψ_prod)(
103 void *instance,
104 const alpaqa_real_t *x,
105 const alpaqa_real_t *y,
106 const alpaqa_real_t *Σ,
107 alpaqa_real_t scale,
108 const alpaqa_real_t *zl,
109 const alpaqa_real_t *zu,
110 const alpaqa_real_t *v,
111 alpaqa_real_t *Hv) ALPAQA_DEFAULT(nullptr);
112 /// Hessian of the augmented Lagrangian.
113 /// @see @ref alpaqa::TypeErasedProblem::eval_hess_ψ()
114 void (*eval_hess_ψ)(
115 void *instance,
116 const alpaqa_real_t *x,
117 const alpaqa_real_t *y,
118 const alpaqa_real_t *Σ,
119 alpaqa_real_t scale,
120 const alpaqa_real_t *zl,
121 const alpaqa_real_t *zu,
122 alpaqa_index_t *inner_idx,
123 alpaqa_index_t *outer_ptr,
124 alpaqa_real_t *H_values) ALPAQA_DEFAULT(nullptr);
125 /// Number of nonzeros of the sparse Hessian of the augmented Lagrangian.
126 /// @see @ref alpaqa::TypeErasedProblem::get_hess_ψ_num_nonzeros()
127 alpaqa_length_t (*get_hess_ψ_num_nonzeros)(
128 void *instance) ALPAQA_DEFAULT(nullptr);
129 /// Cost and its gradient.
130 /// @see @ref alpaqa::TypeErasedProblem::eval_f_grad_f()
131 alpaqa_real_t (*eval_f_grad_f)(
132 void *instance,
133 const alpaqa_real_t *x,
134 alpaqa_real_t *grad_fx) ALPAQA_DEFAULT(nullptr);
135 /// Cost and constraints.
136 /// @see @ref alpaqa::TypeErasedProblem::eval_f_g()
137 alpaqa_real_t (*eval_f_g)(
138 void *instance,
139 const alpaqa_real_t *x,
140 alpaqa_real_t *g) ALPAQA_DEFAULT(nullptr);
141 /// Gradient of the cost and gradient-vector product of the constraints.
142 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_f_grad_g_prod()
143 void (*eval_grad_f_grad_g_prod)(
144 void *instance,
145 const alpaqa_real_t *x,
146 const alpaqa_real_t *y,
147 alpaqa_real_t *grad_f,
148 alpaqa_real_t *grad_gxy) ALPAQA_DEFAULT(nullptr);
149 /// Gradient of the Lagrangian.
150 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_L()
151 void (*eval_grad_L)(
152 void *instance,
153 const alpaqa_real_t *x,
154 const alpaqa_real_t *y,
155 alpaqa_real_t *grad_L,
156 alpaqa_real_t *work_n) ALPAQA_DEFAULT(nullptr);
157 /// Augmented Lagrangian.
158 /// @see @ref alpaqa::TypeErasedProblem::eval_ψ()
159 alpaqa_real_t (*eval_ψ)(
160 void *instance,
161 const alpaqa_real_t *x,
162 const alpaqa_real_t *y,
163 const alpaqa_real_t *Σ,
164 const alpaqa_real_t *zl,
165 const alpaqa_real_t *zu,
166 alpaqa_real_t *ŷ) ALPAQA_DEFAULT(nullptr);
167 /// Gradient of the augmented Lagrangian.
168 /// @see @ref alpaqa::TypeErasedProblem::eval_grad_ψ()
169 void (*eval_grad_ψ)(
170 void *instance,
171 const alpaqa_real_t *x,
172 const alpaqa_real_t *y,
173 const alpaqa_real_t *Σ,
174 const alpaqa_real_t *zl,
175 const alpaqa_real_t *zu,
176 alpaqa_real_t *grad_ψ,
177 alpaqa_real_t *work_n,
178 alpaqa_real_t *work_m) ALPAQA_DEFAULT(nullptr);
179 /// Augmented Lagrangian and its gradient.
180 /// @see @ref alpaqa::TypeErasedProblem::eval_ψ_grad_ψ()
181 alpaqa_real_t (*eval_ψ_grad_ψ)(
182 void *instance,
183 const alpaqa_real_t *x,
184 const alpaqa_real_t *y,
185 const alpaqa_real_t *Σ,
186 const alpaqa_real_t *zl,
187 const alpaqa_real_t *zu,
188 alpaqa_real_t *grad_ψ,
189 alpaqa_real_t *work_n,
190 alpaqa_real_t *work_m) ALPAQA_DEFAULT(nullptr);
191 /// Proximal gradient step.
192 /// @see @ref alpaqa::TypeErasedProblem::eval_prox_grad_step()
193 /// If not set, the default implementation from
194 /// @ref alpaqa::BoxConstrProblem is used.
195 alpaqa_real_t (*eval_prox_grad_step)(
196 void *instance,
197 alpaqa_real_t γ,
198 const alpaqa_real_t *x,
199 const alpaqa_real_t *grad_ψ,
200 alpaqa_real_t *x̂,
201 alpaqa_real_t *p) ALPAQA_DEFAULT(nullptr);
202 /// Provide the initial values for the bounds of
203 /// @ref alpaqa::BoxConstrProblem::C, i.e. the constraints on the decision
204 /// variables.
205 void (*initialize_box_C)(
206 void *instance,
207 alpaqa_real_t *lb,
208 alpaqa_real_t *ub) ALPAQA_DEFAULT(nullptr);
209 /// Provide the initial values for the bounds of
210 /// @ref alpaqa::BoxConstrProblem::D, i.e. the general constraints.
211 void (*initialize_box_D)(
212 void *instance,
213 alpaqa_real_t *lb,
214 alpaqa_real_t *ub) ALPAQA_DEFAULT(nullptr);
215 /// Provide the initial values for @ref alpaqa::BoxConstrProblem::l1_reg,
216 /// the ℓ₁-regularization factor.
217 /// This function is called twice:
218 /// 1. with @p lambda set to `nullptr`, and the user should set the size.
219 /// 2. with @p lambda pointing to an array of that size, and the user
220 /// should initialize this array.
221 void (*initialize_l1_reg)(
222 void *instance,
223 alpaqa_real_t *lambda,
224 alpaqa_length_t *size) ALPAQA_DEFAULT(nullptr);
225 // clang-format on
227
228/// Opaque type for a C++-only map of extra functions.
230/// Opaque type for a C++-only exception pointer.
232
233/// @note When used in C, you should initialize this struct by passing a pointer
234/// to your instance to the @ref ALPAQA_PROBLEM_REGISTER_INIT macro.
235/// In C++, this is not necessary, because all members have default
236/// initializers.
237typedef struct {
238 /// To check whether the loaded problem is compatible with the version of
239 /// the solver.
241 /// Owning pointer.
242 void *instance ALPAQA_DEFAULT(nullptr);
243 /// Non-owning pointer, lifetime at least as long as @ref instance.
245 /// Pointer to the function to clean up @ref instance.
246 void (*cleanup)(void *) ALPAQA_DEFAULT(nullptr);
247 /// Pointer to a map of extra functions (C++ only).
248 /// @see @ref alpaqa::register_function
249 /// @see @ref alpaqa::register_member_function
250 alpaqa_function_dict_t *extra_functions ALPAQA_DEFAULT(nullptr);
251 /// Pointer to an exception that ocurred during problem creation.
254
255typedef struct {
259
260 // clang-format off
261 void (*get_U)(
262 void *instance,
263 alpaqa_real_t *lb,
264 alpaqa_real_t *ub) ALPAQA_DEFAULT(nullptr);
265 void (*get_D)(
266 void *instance,
267 alpaqa_real_t *lb,
268 alpaqa_real_t *ub) ALPAQA_DEFAULT(nullptr);
269 void (*get_D_N)(
270 void *instance,
271 alpaqa_real_t *lb,
272 alpaqa_real_t *ub) ALPAQA_DEFAULT(nullptr);
273 void (*get_x_init)(
274 void *instance,
275 alpaqa_real_t *x_init) ALPAQA_DEFAULT(nullptr);
276 void (*eval_f)(
277 void *instance,
278 alpaqa_index_t timestep,
279 const alpaqa_real_t *x,
280 const alpaqa_real_t *u,
281 alpaqa_real_t *fxu) ALPAQA_DEFAULT(nullptr);
282 void (*eval_jac_f)(
283 void *instance,
284 alpaqa_index_t timestep,
285 const alpaqa_real_t *x,
286 const alpaqa_real_t *u,
287 alpaqa_real_t *J_fxu) ALPAQA_DEFAULT(nullptr);
288 void (*eval_grad_f_prod)(
289 void *instance,
290 alpaqa_index_t timestep,
291 const alpaqa_real_t *x,
292 const alpaqa_real_t *u,
293 const alpaqa_real_t *p,
294 alpaqa_real_t *grad_fxu_p) ALPAQA_DEFAULT(nullptr);
295 void (*eval_h)(
296 void *instance,
297 alpaqa_index_t timestep,
298 const alpaqa_real_t *x,
299 const alpaqa_real_t *u,
300 alpaqa_real_t *h) ALPAQA_DEFAULT(nullptr);
301 void (*eval_h_N)(
302 void *instance,
303 const alpaqa_real_t *x,
304 alpaqa_real_t *h) ALPAQA_DEFAULT(nullptr);
305 alpaqa_real_t (*eval_l)(
306 void *instance,
307 alpaqa_index_t timestep,
308 const alpaqa_real_t *h) ALPAQA_DEFAULT(nullptr);
309 alpaqa_real_t (*eval_l_N)(
310 void *instance,
311 const alpaqa_real_t *h) ALPAQA_DEFAULT(nullptr);
312 void (*eval_qr)(
313 void *instance,
314 alpaqa_index_t timestep,
315 const alpaqa_real_t *xu,
316 const alpaqa_real_t *h,
317 alpaqa_real_t *qr) ALPAQA_DEFAULT(nullptr);
318 void (*eval_q_N)(
319 void *instance,
320 const alpaqa_real_t *x,
321 const alpaqa_real_t *h,
322 alpaqa_real_t *q) ALPAQA_DEFAULT(nullptr);
323 void (*eval_add_Q)(
324 void *instance,
325 alpaqa_index_t timestep,
326 const alpaqa_real_t *xu,
327 const alpaqa_real_t *h,
328 alpaqa_real_t *Q) ALPAQA_DEFAULT(nullptr);
329 void (*eval_add_Q_N)(
330 void *instance,
331 const alpaqa_real_t *x,
332 const alpaqa_real_t *h,
333 alpaqa_real_t *Q) ALPAQA_DEFAULT(nullptr);
334 void (*eval_add_R_masked)(
335 void *instance,
336 alpaqa_index_t timestep,
337 const alpaqa_real_t *xu,
338 const alpaqa_real_t *h,
339 const alpaqa_index_t *mask,
340 alpaqa_real_t *R,
341 alpaqa_real_t *work) ALPAQA_DEFAULT(nullptr);
342 void (*eval_add_S_masked)(
343 void *instance,
344 alpaqa_index_t timestep,
345 const alpaqa_real_t *xu,
346 const alpaqa_real_t *h,
347 const alpaqa_index_t *mask,
348 alpaqa_real_t *S,
349 alpaqa_real_t *work) ALPAQA_DEFAULT(nullptr);
350 void (*eval_add_R_prod_masked)(
351 void *instance,
352 alpaqa_index_t timestep,
353 const alpaqa_real_t *xu,
354 const alpaqa_real_t *h,
355 const alpaqa_index_t *mask_J,
356 const alpaqa_index_t *mask_K,
357 const alpaqa_real_t *v,
358 alpaqa_real_t *out,
359 alpaqa_real_t *work) ALPAQA_DEFAULT(nullptr);
360 void (*eval_add_S_prod_masked)(
361 void *instance,
362 alpaqa_index_t timestep,
363 const alpaqa_real_t *xu,
364 const alpaqa_real_t *h,
365 const alpaqa_index_t *mask_K,
366 const alpaqa_real_t *v,
367 alpaqa_real_t *out,
368 alpaqa_real_t *work) ALPAQA_DEFAULT(nullptr);
369 alpaqa_length_t (*get_R_work_size)(
370 void *instance) ALPAQA_DEFAULT(nullptr);
371 alpaqa_length_t (*get_S_work_size)(
372 void *instance) ALPAQA_DEFAULT(nullptr);
373 void (*eval_constr)(
374 void *instance,
375 alpaqa_index_t timestep,
376 const alpaqa_real_t *x,
377 alpaqa_real_t *c) ALPAQA_DEFAULT(nullptr);
378 void (*eval_constr_N)(
379 void *instance,
380 const alpaqa_real_t *x,
381 alpaqa_real_t *c) ALPAQA_DEFAULT(nullptr);
382 void (*eval_grad_constr_prod)(
383 void *instance,
384 alpaqa_index_t timestep,
385 const alpaqa_real_t *x,
386 const alpaqa_real_t *p,
387 alpaqa_real_t *grad_cx_p) ALPAQA_DEFAULT(nullptr);
388 void (*eval_grad_constr_prod_N)(
389 void *instance,
390 const alpaqa_real_t *x,
391 const alpaqa_real_t *p,
392 alpaqa_real_t *grad_cx_p) ALPAQA_DEFAULT(nullptr);
393 void (*eval_add_gn_hess_constr)(
394 void *instance,
395 alpaqa_index_t timestep,
396 const alpaqa_real_t *x,
397 const alpaqa_real_t *M,
398 alpaqa_real_t *out) ALPAQA_DEFAULT(nullptr);
399 void (*eval_add_gn_hess_constr_N)(
400 void *instance,
401 const alpaqa_real_t *x,
402 const alpaqa_real_t *M,
403 alpaqa_real_t *out) ALPAQA_DEFAULT(nullptr);
404 // clang-format on
406
407/// @note When used in C, you should initialize this struct by passing a pointer
408/// to your instance to the @ref ALPAQA_PROBLEM_REGISTER_INIT macro.
409/// In C++, this is not necessary, because all members have default
410/// initializers.
411typedef struct {
412 /// To check whether the loaded problem is compatible with the version of
413 /// the solver.
415 /// Owning pointer.
416 void *instance ALPAQA_DEFAULT(nullptr);
417 /// Non-owning pointer, lifetime at least as long as @ref instance.
419 /// Pointer to the function to clean up @ref instance.
420 void (*cleanup)(void *) ALPAQA_DEFAULT(nullptr);
421 /// Pointer to a map of extra functions (C++ only).
422 alpaqa_function_dict_t *extra_functions ALPAQA_DEFAULT(nullptr);
423 /// Pointer to an exception that ocurred during problem creation.
426
427#ifdef __cplusplus
428}
429#endif
430
431#if !defined(__cplusplus) || defined(DOXYGEN)
432inline static void
436 };
437}
438inline static void
442 };
443}
444/// Initialize an instance of @ref alpaqa_problem_register_t or
445/// @ref alpaqa_control_problem_register_t. It initializes all members to zero,
446/// except for the ABI version, which is initialized to the current ABI version.
447/// Available in C only (unnecessary in C++).
448/// @param self
449/// A pointer to the instance to initialize.
450#define ALPAQA_PROBLEM_REGISTER_INIT(self) \
451 _Generic((self), \
452 alpaqa_problem_register_t *: alpaqa_problem_register_init, \
453 alpaqa_control_problem_register_t *: alpaqa_control_problem_register_init)( \
454 self)
455#endif
456
457#if defined(__cplusplus) && __cplusplus > 201703L
458
459#include <any>
460#include <exception>
461#include <functional>
462#include <map>
463#include <string>
464
466 std::map<std::string, std::any> dict{};
467};
468
470 std::exception_ptr exc{};
471};
472
473namespace alpaqa {
474
480
481/// Make the given function available to alpaqa.
482/// @see @ref alpaqa::dl::DLProblem::call_extra_func
483/// @see @ref alpaqa::dl::DLControlProblem::call_extra_func
484template <class Func>
485void register_function(function_dict_t *&extra_functions, std::string name,
486 Func &&func) {
487 if (extra_functions == nullptr)
488 extra_functions = new function_dict_t{};
489 extra_functions->dict.insert_or_assign(
490 std::move(name), std::function{std::forward<Func>(func)});
491}
492
493template <class Func>
494void register_function(problem_register_t &result, std::string name,
495 Func &&func) {
496 register_function(result.extra_functions, std::move(name),
497 std::forward<Func>(func));
498}
499
500template <class Func>
501void register_function(control_problem_register_t &result, std::string name,
502 Func &&func) {
503 register_function(result.extra_functions, std::move(name),
504 std::forward<Func>(func));
505}
506
507template <class Result, class T, class Ret, class... Args>
508void register_member_function(Result &result, std::string name,
509 Ret (T::*member)(Args...)) {
510 register_function(result, std::move(name),
511 [member](void *self_, Args... args) -> Ret {
512 auto *self = reinterpret_cast<T *>(self_);
513 return (self->*member)(std::forward<Args>(args)...);
514 });
515}
516
517template <class Result, class T, class Ret, class... Args>
518void register_member_function(Result &result, std::string name,
519 Ret (T::*member)(Args...) const) {
520 register_function(result, std::move(name),
521 [member](const void *self_, Args... args) -> Ret {
522 const auto *self = reinterpret_cast<const T *>(self_);
523 return (self->*member)(std::forward<Args>(args)...);
524 });
525}
526
527namespace detail {
528/// Overload for non-const-qualified member functions.
529/// @see @ref alpaqa::member_caller
530template <auto Member, class Class, class Ret, class... Args>
531static auto member_caller(Ret (Class::*)(Args...)) {
532 return [](void *self_, Args... args) -> Ret {
533 auto *self = reinterpret_cast<Class *>(self_);
534 return (self->*Member)(std::forward<Args>(args)...);
535 };
536}
537/// Overload for const-qualified member functions.
538/// @see @ref alpaqa::member_caller
539template <auto Member, class Class, class Ret, class... Args>
540static auto member_caller(Ret (Class::*)(Args...) const) {
541 return []<class Self>(Self * self_, Args... args) -> Ret
542 requires std::is_void_v<Self>
543 {
544 const auto *self = reinterpret_cast<const Class *>(self_);
545 return (self->*Member)(std::forward<Args>(args)...);
546 };
547}
548/// Overload for member variables.
549/// @see @ref alpaqa::member_caller
550template <auto Member, class Class, class Ret>
551static auto member_caller(Ret Class::*) {
552 return []<class Self>(Self * self_) -> decltype(auto)
553 requires std::is_void_v<Self>
554 {
555 using CClass = std::conditional_t<std::is_const_v<Self>,
556 std::add_const_t<Class>, Class>;
557 auto *self = reinterpret_cast<CClass *>(self_);
558 return self->*Member;
559 };
560}
561} // namespace detail
562
563/// Wrap the given member function or variable into a (possibly generic) lambda
564/// function that accepts the instance as a type-erased void pointer.
565///
566/// The signature of the resulting function depends on the signature of the
567/// member function:
568///
569/// - `Ret Class::member(args...)` → `Ret(void *self, args...)`
570/// - `Ret Class::member(args...) const` → `Ret(void *self, args...)`
571/// - `Ret Class::member(args...) const` → `Ret(const void *self, args...)`
572///
573/// If the given member is a variable:
574///
575/// - `Type Class::member` → `Type &(void *self)`
576/// - `Type Class::member` → `const Type &(const void *self)`
577template <auto Member>
578static auto member_caller() {
579 return detail::member_caller<Member>(Member);
580}
581
582/// Cleans up the extra functions registered by @ref register_function.
583/// @note This does not need to be called for the functions returned by the
584/// registration function, those functions will be cleaned up by alpaqa.
585/// @note The @ref alpaqa_problem_register_t and
586/// @ref alpaqa_control_problem_register_t structs are part of the C API
587/// and do not automatically clean up their resources when destroyed,
588/// you have to do it manually by calling this function.
589inline void unregister_functions(function_dict_t *&extra_functions) {
590 delete extra_functions;
591 extra_functions = nullptr;
592}
593
594} // namespace alpaqa
595
596#endif
597
598#undef ALPAQA_DEFAULT
599
600// NOLINTEND(modernize-use-using,modernize-deprecated-headers)
static void alpaqa_control_problem_register_init(alpaqa_control_problem_register_t *self)
Definition: dl-problem.h:439
#define ALPAQA_DL_ABI_VERSION
Definition: dl-problem.h:9
struct alpaqa_function_dict_s alpaqa_function_dict_t
Opaque type for a C++-only map of extra functions.
Definition: dl-problem.h:229
ptrdiff_t alpaqa_length_t
Definition: dl-problem.h:20
#define ALPAQA_DEFAULT(...)
Definition: dl-problem.h:13
alpaqa_length_t alpaqa_index_t
Definition: dl-problem.h:21
std::exception_ptr exc
Definition: dl-problem.h:470
double alpaqa_real_t
Definition: dl-problem.h:19
std::map< std::string, std::any > dict
Definition: dl-problem.h:466
static void alpaqa_problem_register_init(alpaqa_problem_register_t *self)
Definition: dl-problem.h:433
void unregister_functions(function_dict_t *&extra_functions)
Cleans up the extra functions registered by register_function.
Definition: dl-problem.h:589
void register_function(function_dict_t *&extra_functions, std::string name, Func &&func)
Make the given function available to alpaqa.
Definition: dl-problem.h:485
void register_member_function(Result &result, std::string name, Ret(T::*member)(Args...))
Definition: dl-problem.h:508
static auto member_caller()
Wrap the given member function or variable into a (possibly generic) lambda function that accepts the...
Definition: dl-problem.h:578
alpaqa_function_dict_t * extra_functions
Pointer to a map of extra functions (C++ only).
Definition: dl-problem.h:422
uint64_t abi_version
To check whether the loaded problem is compatible with the version of the solver.
Definition: dl-problem.h:414
C API providing function pointers to problem functions.
Definition: dl-problem.h:25
alpaqa_function_dict_t * extra_functions
Pointer to a map of extra functions (C++ only).
Definition: dl-problem.h:250
uint64_t abi_version
To check whether the loaded problem is compatible with the version of the solver.
Definition: dl-problem.h:240