alpaqa pi-pico
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 <alpaqa/util/dl.hpp>
7#include <cassert>
8
9/*
10CUTEST_cfn : function and constraints values
11CUTEST_cofg : function value and possibly gradient
12CUTEST_cofsg : function value and possibly gradient in sparse format
13CUTEST_ccfg : constraint functions values and possibly gradients
14CUTEST_clfg : Lagrangian function value and possibly gradient
15CUTEST_cgr : constraints gradients and gradient of objective/Lagrangian function
16CUTEST_csgr : constraints gradients and gradient of objective/Lagrangian function
17CUTEST_ccfsg : constraint functions values and possibly their gradients in sparse format
18CUTEST_ccifg : single constraint function value and possibly its gradient
19CUTEST_ccifsg : single constraint function value and possibly gradient in sparse format
20CUTEST_cgrdh : constraints gradients, Hessian of Lagrangian function and gradient of objective/Lagrangian function
21CUTEST_cdh : Hessian of the Lagrangian
22CUTEST_cdhc : Hessian of the constraint part of the Lagrangian
23CUTEST_cshp : sparsity pattern of the Hessian of the Lagrangian function
24CUTEST_csh : Hessian of the Lagrangian, in sparse format
25CUTEST_cshc : Hessian of the constraint part of the Lagrangian, in sparse format
26CUTEST_ceh : sparse Lagrangian Hessian matrix in finite element format
27CUTEST_cifn : problem function value
28CUTEST_cigr : gradient of a problem function
29CUTEST_cisgr : gradient of a problem function in sparse format
30CUTEST_cidh : Hessian of a problem function
31CUTEST_cish : Hessian of an individual problem function, in sparse format
32CUTEST_csgrsh : constraints gradients, sparse Lagrangian Hessian and the gradient of either the objective/Lagrangian in sparse format
33CUTEST_csgreh : constraint gradients, the Lagrangian Hessian in finite element format and the gradient of either the objective/Lagrangian in sparse format
34CUTEST_chprod : matrix-vector product of a vector with the Hessian matrix of the Lagrangian
35CUTEST_cshprod : matrix-vector product of a sparse vector with the Hessian matrix of the Lagrangian
36CUTEST_chcprod : matrix-vector product of a vector with the Hessian matrix of the constraint part of the Lagrangian
37CUTEST_cshcprod : matrix-vector product of a spaarse vector with the Hessian matrix of the constraint part of the Lagrangian
38CUTEST_cjprod : matrix-vector product of a vector with the Jacobian of the constraints, or its transpose
39CUTEST_csjprod : matrix-vector product of a sparse vector with the Jacobian of the constraints, or its transpose
40CUTEST_cchprods : matrix-vector products of a vector with each of the Hessian matrices of the constraint functions
41*/
42
43namespace alpaqa::cutest {
44
45// clang-format off
46using 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)>;
47using cterminate = Function<"cutest_cterminate_", void(integer *status)>;
48
49using cdimen = Function<"cutest_cdimen_", void(integer *status, const integer *funit, integer *n, integer *m)>;
50using cdimsj = Function<"cutest_cdimsj_", void(integer *status, integer *nnzj)>;
51using cdimsh = Function<"cutest_cdimsh_", void(integer *status, integer *nnzh)>;
52
53using probname = Function<"cutest_probname_", void(integer *status, char *pname)>;
54using creport = Function<"cutest_creport_", void(integer *status, doublereal *calls, doublereal *time)>;
55using creport = Function<"cutest_creport_", void(integer *status, doublereal *calls, doublereal *time)>;
56using ureport = Function<"cutest_ureport_", void(integer *status, doublereal *calls, doublereal *time)>;
57
58using cfn = Function<"cutest_cfn_", void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *f, doublereal *c)>;
59using cofg = Function<"cutest_cint_cofg_", void(integer *status, const integer *n, const doublereal *x, doublereal *f, doublereal *g, const logical *grad)>;
60using 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)>;
61using 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)>;
62using 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)>;
63using ccifg = Function<"cutest_cint_ccifg_", void(integer *status, const integer *n, const integer *icon, const doublereal *x, doublereal *ci, doublereal *gci, const logical *grad)>;
64using cdh = Function<"cutest_cdh_", void(integer *status, const integer *n, const integer *m, const doublereal *x, const doublereal *y, const integer *lh1, doublereal *h)>;
65using cshp = Function<"cutest_cshp_", void(integer *status, const integer *n, integer *nnzh, const integer *lh, integer *irnh, integer *icnh)>;
66using 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)>;
67using cigr = Function<"cutest_cigr_", void(integer *status, const integer *n, const integer *iprob, const doublereal *x, doublereal *g)>;
68using 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)>;
69using 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)>;
70using csjp = Function<"cutest_csjp_", void(integer *status, integer *nnzj, const integer *lj, integer *J_var, integer *J_con)>;
71
72using fortran_open = Function<"fortran_open_", void(const integer *funit, const char *fname, integer *ierr)>;
73using fortran_close = Function<"fortran_close_", void(const integer *funit, integer *ierr)>;
74// clang-format on
75
76template <Name Nm, class Sgn>
77auto Function<Nm, Sgn>::load(void *handle) -> signature_t * {
78 static_assert(name.value.back() == '\0');
79 auto func = util::load_func(handle, name.value.data());
80 assert(func);
81 return reinterpret_cast<signature_t *>(func);
82}
83
84} // namespace alpaqa::cutest
constexpr doublereal inf
void * load_func(void *lib_handle, const std::string &name)
Get a pointer to a function inside of a loaded DLL or SO file.
Definition dl.cpp:66
Reference to CUTEst function.
static signature_t * load(void *handle)