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