alpaqa 1.0.0a17
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
dl-problem.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <any>
#include <exception>
#include <functional>
#include <map>
#include <string>
+ Include dependency graph for dl-problem.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  alpaqa_register_arg_t
 User-provided argument that is passed to the problem registration functions. More...
 
struct  alpaqa_dense_t
 
struct  alpaqa_sparse_csc_t
 
struct  alpaqa_sparse_csc_l_t
 
struct  alpaqa_sparse_csc_ll_t
 
struct  alpaqa_sparse_coo_t
 
struct  alpaqa_sparse_coo_l_t
 
struct  alpaqa_sparse_coo_ll_t
 
struct  alpaqa_sparsity_t
 Sparsity of matrices. More...
 
struct  alpaqa_problem_functions_t
 C API providing function pointers to problem functions. More...
 
struct  alpaqa_problem_register_t
 
struct  alpaqa_control_problem_functions_t
 
struct  alpaqa_control_problem_register_t
 
struct  alpaqa_function_dict_s
 
struct  alpaqa_exception_ptr_s
 
struct  function_wrapper_t< Signature >
 Custom type for which we can export the RTTI to support std::any across shared library boundaries when using libc++. More...
 
union  alpaqa_sparsity_t.__unnamed7__
 

Namespaces

namespace  alpaqa
 
namespace  alpaqa::detail
 

Macros

#define ALPAQA_DL_ABI_VERSION   0xA1A000000005
 
#define ALPAQA_DL_PROBLEM_EXPORT
 
#define ALPAQA_BEGIN_STRUCT(name)   struct name
 
#define ALPAQA_END_STRUCT(name)
 
#define ALPAQA_DEFAULT(...)    { __VA_ARGS__ }
 
#define ALPAQA_PROBLEM_REGISTER_INIT(self)
 Initialize an instance of alpaqa_problem_register_t or alpaqa_control_problem_register_t.
 

Typedefs

typedef double alpaqa_real_t
 
typedef ptrdiff_t alpaqa_length_t
 
typedef alpaqa_length_t alpaqa_index_t
 
typedef uint64_t alpaqa_dl_abi_version_t
 
typedef struct alpaqa_function_dict_s alpaqa_function_dict_t
 Opaque type for a C++-only map of extra functions.
 
typedef struct alpaqa_exception_ptr_s alpaqa_exception_ptr_t
 Opaque type for a C++-only exception pointer.
 
using function_dict_t = alpaqa_function_dict_t
 
using problem_register_t = alpaqa_problem_register_t
 
using control_problem_register_t = alpaqa_control_problem_register_t
 
using problem_functions_t = alpaqa_problem_functions_t
 
using control_problem_functions_t = alpaqa_control_problem_functions_t
 

Enumerations

enum  alpaqa_register_arg_type_t { alpaqa_register_arg_unspecified = 0 , alpaqa_register_arg_std_any = 1 , alpaqa_register_arg_strings = 2 , alpaqa_register_arg_py_args = 3 }
 
enum  alpaqa_symmetry { alpaqa_unsymmetric = 0 , alpaqa_upper = 1 , alpaqa_lower = 2 }
 

Functions

static void alpaqa_problem_register_init (alpaqa_problem_register_t *self)
 
static void alpaqa_control_problem_register_init (alpaqa_control_problem_register_t *self)
 
template<class Signature >
 function_wrapper_t (std::function< Signature >) -> function_wrapper_t< Signature >
 
template<class Func >
void register_function (function_dict_t *&extra_functions, std::string name, Func &&func)
 Make the given function available to alpaqa.
 
template<class Func >
void register_function (problem_register_t &result, std::string name, Func &&func)
 
template<class Func >
void register_function (control_problem_register_t &result, std::string name, Func &&func)
 
template<class Result , class T , class Ret , class... Args>
void register_member_function (Result &result, std::string name, Ret(T::*member)(Args...))
 
template<auto Member, class Class , class Ret , class... Args>
static auto member_caller (Ret(Class::*)(Args...))
 Overload for non-const-qualified member functions.
 
template<auto Member, class Class , class Ret >
static auto member_caller (Ret Class::*)
 Overload for member variables.
 
template<auto Member>
static auto member_caller ()
 Wrap the given member function or variable into a (possibly generic) lambda function that accepts the instance as a type-erased void pointer.
 
void unregister_functions (function_dict_t *&extra_functions)
 Cleans up the extra functions registered by register_function.
 

Class Documentation

◆ alpaqa_register_arg_t

struct alpaqa_register_arg_t
+ Collaboration diagram for alpaqa_register_arg_t:
Class Members
void * data { nullptr } Pointer to the user-provided argument passed to the problem registration functions.

Use the type member to determine its type.

alpaqa_register_arg_type_t type { alpaqa_register_arg_unspecified } Specifies the type of the data pointed to by data.

◆ alpaqa_dense_t

struct alpaqa_dense_t
+ Collaboration diagram for alpaqa_dense_t:
Class Members
alpaqa_length_t rows { 0 }
alpaqa_length_t cols { 0 }
alpaqa_symmetry symmetry { alpaqa_unsymmetric }

◆ alpaqa_function_dict_s

struct alpaqa_function_dict_s
+ Collaboration diagram for alpaqa_function_dict_s:
Class Members
map< string, any > dict {}

◆ alpaqa_exception_ptr_s

struct alpaqa_exception_ptr_s
+ Collaboration diagram for alpaqa_exception_ptr_s:
Class Members
exception_ptr exc {}

◆ alpaqa::detail::function_wrapper_t

struct alpaqa::detail::function_wrapper_t
+ Collaboration diagram for function_wrapper_t< Signature >:
Class Members
function< Signature > function

◆ alpaqa_sparsity_t.__unnamed7__

union alpaqa_sparsity_t.__unnamed7__
+ Collaboration diagram for alpaqa_sparsity_t.__unnamed7__:
Class Members
alpaqa_dense_t dense
alpaqa_sparse_csc_t sparse_csc
alpaqa_sparse_csc_l_t sparse_csc_l
alpaqa_sparse_csc_ll_t sparse_csc_ll
alpaqa_sparse_coo_t sparse_coo
alpaqa_sparse_coo_l_t sparse_coo_l
alpaqa_sparse_coo_ll_t sparse_coo_ll

Macro Definition Documentation

◆ ALPAQA_DL_ABI_VERSION

#define ALPAQA_DL_ABI_VERSION   0xA1A000000005

◆ ALPAQA_DL_PROBLEM_EXPORT

#define ALPAQA_DL_PROBLEM_EXPORT

Definition at line 16 of file dl-problem.h.

◆ ALPAQA_BEGIN_STRUCT

#define ALPAQA_BEGIN_STRUCT (   name)    struct name

Definition at line 21 of file dl-problem.h.

◆ ALPAQA_END_STRUCT

#define ALPAQA_END_STRUCT (   name)

Definition at line 22 of file dl-problem.h.

◆ ALPAQA_DEFAULT

#define ALPAQA_DEFAULT (   ...)     { __VA_ARGS__ }

Definition at line 23 of file dl-problem.h.

◆ ALPAQA_PROBLEM_REGISTER_INIT

#define ALPAQA_PROBLEM_REGISTER_INIT (   self)
Value:
_Generic((self), \
self)
static void alpaqa_control_problem_register_init(alpaqa_control_problem_register_t *self)
Definition dl-problem.h:652
static void alpaqa_problem_register_init(alpaqa_problem_register_t *self)
Definition dl-problem.h:646

Initialize an instance of alpaqa_problem_register_t or alpaqa_control_problem_register_t.

It initializes all members to zero, except for the ABI version, which is initialized to the current ABI version. Available in C only (unnecessary in C++).

Parameters
selfA pointer to the instance to initialize.
Examples
C++/DLProblem/main.cpp.

Definition at line 663 of file dl-problem.h.

Typedef Documentation

◆ alpaqa_real_t

typedef double alpaqa_real_t

Definition at line 31 of file dl-problem.h.

◆ alpaqa_length_t

typedef ptrdiff_t alpaqa_length_t

Definition at line 32 of file dl-problem.h.

◆ alpaqa_index_t

Definition at line 33 of file dl-problem.h.

◆ alpaqa_dl_abi_version_t

typedef uint64_t alpaqa_dl_abi_version_t

Definition at line 34 of file dl-problem.h.

◆ alpaqa_function_dict_t

Opaque type for a C++-only map of extra functions.

Definition at line 439 of file dl-problem.h.

◆ alpaqa_exception_ptr_t

Opaque type for a C++-only exception pointer.

Definition at line 441 of file dl-problem.h.

Enumeration Type Documentation

◆ alpaqa_register_arg_type_t

Enumerator
alpaqa_register_arg_unspecified 

No type was specified (discouraged).

alpaqa_register_arg_std_any 

The alpaqa_register_arg_t::data pointer points to a C++ std::any object.

Use reinterpret_cast<std::any *>(data) to convert back. Then use std::any_cast to get the actual value out.

Warning
std::any relies on RTTI that is included in both the dynamically loaded problem module and in the code that actually loads that module. Types that need to be passed between the loading and loaded code need to be exported as public classes to ensure that only a single symbol ends up in the final application. If the RTTI symbols are private, each library will end up with its own local copy, and the type information won't compare equal when using libc++, causing std::any_cast to fail.
alpaqa_register_arg_strings 

The alpaqa_register_arg_t::data pointer points to a dynamic C++ std::span of std::string_view.

Use reinterpret_cast<std::span<std::string_view> *>(data) to convert back.

alpaqa_register_arg_py_args 

The alpaqa_register_arg_t::data pointer points to a C++ tuple of pybind11::args and pybind11::kwargs.

Use reinterpret_cast<std::tuple<pybind11::args, pybind11::kwargs> *>(data) to convert back.

Definition at line 36 of file dl-problem.h.

◆ alpaqa_symmetry

See also
alpaqa::sparsity::Symmetry
Enumerator
alpaqa_unsymmetric 
alpaqa_upper 
alpaqa_lower 

Definition at line 76 of file dl-problem.h.

Function Documentation

◆ alpaqa_problem_register_init()

static void alpaqa_problem_register_init ( alpaqa_problem_register_t self)
inlinestatic

Definition at line 646 of file dl-problem.h.

◆ alpaqa_control_problem_register_init()

static void alpaqa_control_problem_register_init ( alpaqa_control_problem_register_t self)
inlinestatic

Definition at line 652 of file dl-problem.h.