alpaqa 1.0.0a10
Nonconvex constrained optimization
Loading...
Searching...
No Matches
cutest-functions.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "cutest-types.hpp"
4
6#include <dlfcn.h>
7
8/*
9CUTEST_cfn : function and constraints values
10CUTEST_cofg : function value and possibly gradient
11CUTEST_cofsg : function value and possibly gradient in sparse format
12CUTEST_ccfg : constraint functions values and possibly gradients
13CUTEST_clfg : Lagrangian function value and possibly gradient
14CUTEST_cgr : constraints gradients and gradient of objective/Lagrangian function
15CUTEST_csgr : constraints gradients and gradient of objective/Lagrangian function
16CUTEST_ccfsg : constraint functions values and possibly their gradients in sparse format
17CUTEST_ccifg : single constraint function value and possibly its gradient
18CUTEST_ccifsg : single constraint function value and possibly gradient in sparse format
19CUTEST_cgrdh : constraints gradients, Hessian of Lagrangian function and gradient of objective/Lagrangian function
20CUTEST_cdh : Hessian of the Lagrangian
21CUTEST_cdhc : Hessian of the constraint part of the Lagrangian
22CUTEST_cshp : sparsity pattern of the Hessian of the Lagrangian function
23CUTEST_csh : Hessian of the Lagrangian, in sparse format
24CUTEST_cshc : Hessian of the constraint part of the Lagrangian, in sparse format
25CUTEST_ceh : sparse Lagrangian Hessian matrix in finite element format
26CUTEST_cifn : problem function value
27CUTEST_cigr : gradient of a problem function
28CUTEST_cisgr : gradient of a problem function in sparse format
29CUTEST_cidh : Hessian of a problem function
30CUTEST_cish : Hessian of an individual problem function, in sparse format
31CUTEST_csgrsh : constraints gradients, sparse Lagrangian Hessian and the gradient of either the objective/Lagrangian in sparse format
32CUTEST_csgreh : constraint gradients, the Lagrangian Hessian in finite element format and the gradient of either the objective/Lagrangian in sparse format
33CUTEST_chprod : matrix-vector product of a vector with the Hessian matrix of the Lagrangian
34CUTEST_cshprod : matrix-vector product of a sparse vector with the Hessian matrix of the Lagrangian
35CUTEST_chcprod : matrix-vector product of a vector with the Hessian matrix of the constraint part of the Lagrangian
36CUTEST_cshcprod : matrix-vector product of a spaarse vector with the Hessian matrix of the constraint part of the Lagrangian
37CUTEST_cjprod : matrix-vector product of a vector with the Jacobian of the constraints, or its transpose
38CUTEST_csjprod : matrix-vector product of a sparse vector with the Jacobian of the constraints, or its transpose
39CUTEST_cchprods : matrix-vector products of a vector with each of the Hessian matrices of the constraint functions
40*/
41
42namespace alpaqa::cutest {
43
44// clang-format off
45using csetup = Function<"cutest_cint_csetup_", void(integer *status, const integer *funit, const integer *iout, const integer *io_buffer, integer *n, integer *m, doublereal *x, doublereal *bl, doublereal *bu, doublereal *v, doublereal *cl, doublereal *cu, logical *equatn, logical *linear, const integer *e_order, const integer *l_order, const integer *v_order)>;
46using cterminate = Function<"cutest_cterminate_", void(integer *status)>;
47
48using cdimen = Function<"cutest_cdimen_", void(integer *status, const integer *funit, integer *n, integer *m)>;
49using cdimsj = Function<"cutest_cdimsj_", void(integer *status, integer *nnzj)>;
50using cdimsh = Function<"cutest_cdimsh_", void(integer *status, integer *nnzh)>;
51
52using probname = Function<"cutest_probname_", void(integer *status, char *pname)>;
53using creport = Function<"cutest_creport_", void(integer *status, doublereal *calls, doublereal *time)>;
54using creport = Function<"cutest_creport_", void(integer *status, doublereal *calls, doublereal *time)>;
55using ureport = Function<"cutest_ureport_", void(integer *status, doublereal *calls, doublereal *time)>;
56
57using cfn = Function<"cutest_cfn_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *f, doublereal *c)>;
58using cofg = Function<"cutest_cint_cofg_", void(integer *status, const integer *n, const doublereal *x, doublereal *f, doublereal *g, const logical *grad)>;
59using ccfg = Function<"cutest_cint_ccfg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *c, const logical *jtrans, const integer *lcjac1, const integer *lcjac2, doublereal *cjac, const logical *grad)>;
60using clfg = Function<"cutest_cint_clfg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, doublereal *f, doublereal *g, const logical *grad)>;
61using ccfsg = Function<"cutest_cint_ccfsg_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *c, integer *nnzj, const integer *lcjac, doublereal *cjac, integer *indvar, integer *indfun, const logical *grad)>;
62using ccifg = Function<"cutest_cint_ccifg_", void(integer *status, const integer *n, const integer *icon, const doublereal *x, doublereal *ci, doublereal *gci, const logical *grad)>;
63using cdh = Function<"cutest_cdh_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, const integer *lh1, doublereal *h)>;
64using cshp = Function<"cutest_cshp_", void(integer *status, const integer *n, integer *nnzh, const integer *lh, integer *irnh, integer *icnh)>;
65using csh = Function<"cutest_csh_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, integer *nnzh, const integer *lh, doublereal *h, integer *irnh, integer *icnh)>;
66using cigr = Function<"cutest_cigr_", void(integer *status, const integer *n, const integer *iprob, const doublereal *x, doublereal *g)>;
67using chprod = Function<"cutest_chprod_", void(integer *status, const integer *n, const integer *m, const logical *goth, const doublereal *x, const doublereal *y, doublereal *p, doublereal *q)>;
68using cjprod = Function<"cutest_cjprod_", void(integer *status, const integer *n, const integer *m, const logical *gotj, const logical *jtrans,const doublereal *x, const doublereal *p, const integer *lp, doublereal *r, const integer *lr)>;
69using csjp = Function<"cutest_csjp_", void(integer *status, integer *nnzj, const integer *lj, integer *J_var, integer *J_con)>;
70
71using fortran_open = Function<"fortran_open_", void(const integer *funit, const char *fname, integer *ierr)>;
72using fortran_close = Function<"fortran_close_", void(const integer *funit, integer *ierr)>;
73// clang-format on
74
75template <Name Nm, class Sgn>
76auto Function<Nm, Sgn>::load(void *handle) -> signature_t * {
77 (void)::dlerror();
78 static_assert(name.value.back() == '\0');
79 const char *name_cstr = name.value.data();
80 auto func = reinterpret_cast<signature_t *>(::dlsym(handle, name_cstr));
81 if (const char *error = ::dlerror())
82 throw function_load_error(error);
83 return func;
84}
85
86} // namespace alpaqa::cutest
Reference to CUTEst function.
static signature_t * load(void *handle)