chiark / gitweb /
f8a8c30da98fc491428985c1de83c10689c7cc09
[nlopt.git] / api / nlopt.h
1 #ifndef NLOPT_H
2 #define NLOPT_H
3
4 #ifdef __cplusplus
5 extern "C"
6 {
7 #endif /* __cplusplus */
8
9 typedef double (*nlopt_func)(int n, const double *x,
10                              double *gradient, /* NULL if not needed */
11                              void *func_data);
12
13 typedef enum {
14      /* non-gradient methods */
15      NLOPT_GLOBAL_DIRECT,
16      NLOPT_LOCAL_SUBPLEX,
17
18      /* gradient-based methods */
19      NLOPT_GLOBAL_STOGO,
20      NLOPT_LOCAL_LBFGS
21 } nlopt_method;
22
23 typedef enum {
24      NLOPT_FAILURE = -1, /* generic failure code */
25      NLOPT_INVALID_ARGS = -2,
26      NLOPT_OUT_OF_MEMORY = -3,
27
28      NLOPT_SUCCESS = 1, /* generic success code */
29      NLOPT_FMIN_MAX_REACHED = 2,
30      NLOPT_FTOL_REACHED = 3,
31      NLOPT_XTOL_REACHED = 4,
32      NLOPT_MAXEVAL_REACHED = 5,
33      NLOPT_MAXTIME_REACHED = 6
34 } nlopt_result;
35
36 extern nlopt_result nlopt_minimize(
37      nlopt_method method,
38      int n, nlopt_func f, void *f_data,
39      const double *lb, const double *ub, /* bounds */
40      double *x, /* in: initial guess, out: minimizer */
41      double *fmin, /* out: minimum */
42      double fmin_max, double ftol_rel, double ftol_abs,
43      double xtol_rel, const double *xtol_abs,
44      int maxeval, double maxtime);
45
46 #ifdef __cplusplus
47 }  /* extern "C" */
48 #endif /* __cplusplus */
49
50 #endif