chiark / gitweb /
support calling both original and new DIRECT code, make direct limits more dynamic...
[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 algorithms */
15
16      NLOPT_GLOBAL_DIRECT = 0,
17      NLOPT_GLOBAL_DIRECT_L,
18      NLOPT_GLOBAL_DIRECT_L_RANDOMIZED,
19      NLOPT_GLOBAL_ORIG_DIRECT,
20      NLOPT_GLOBAL_ORIG_DIRECT_L,
21
22      NLOPT_LOCAL_SUBPLEX,
23
24      /* gradient-based algorithms */
25
26      NLOPT_GLOBAL_STOGO,
27      NLOPT_GLOBAL_STOGO_RANDOMIZED,
28
29      NLOPT_LOCAL_LBFGS,
30
31      NLOPT_NUM_ALGORITHMS /* not an algorithm, just the number of them */
32 } nlopt_algorithm;
33
34 extern const char *nlopt_algorithm_name(nlopt_algorithm a);
35
36 typedef enum {
37      NLOPT_FAILURE = -1, /* generic failure code */
38      NLOPT_INVALID_ARGS = -2,
39      NLOPT_OUT_OF_MEMORY = -3,
40
41      NLOPT_SUCCESS = 1, /* generic success code */
42      NLOPT_FMIN_MAX_REACHED = 2,
43      NLOPT_FTOL_REACHED = 3,
44      NLOPT_XTOL_REACHED = 4,
45      NLOPT_MAXEVAL_REACHED = 5,
46      NLOPT_MAXTIME_REACHED = 6
47 } nlopt_result;
48
49 extern nlopt_result nlopt_minimize(
50      nlopt_algorithm algorithm,
51      int n, nlopt_func f, void *f_data,
52      const double *lb, const double *ub, /* bounds */
53      double *x, /* in: initial guess, out: minimizer */
54      double *fmin, /* out: minimum */
55      double fmin_max, double ftol_rel, double ftol_abs,
56      double xtol_rel, const double *xtol_abs,
57      int maxeval, double maxtime);
58
59 extern void nlopt_srand(unsigned long seed);
60 extern void nlopt_srand_time(void);
61
62 extern void nlopt_version(int *major, int *minor, int *bugfix);
63
64 #ifdef __cplusplus
65 }  /* extern "C" */
66 #endif /* __cplusplus */
67
68 #endif