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