chiark / gitweb /
put source code into src subdirectory
[nlopt.git] / src / algs / stogo / stogo.h
1 /* A C-callable front-end to the StoGO global-optimization library.
2    -- Steven G. Johnson   */
3
4 #ifndef STOGO_H
5 #define STOGO_H
6
7 #include "nlopt-util.h"
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 typedef double (*objective_func)(unsigned n, const double *x, double *grad,
14                                  void *data);
15
16 /* search for the global minimum of the function fgrad(n, x, grad, data)
17    inside a simple n-dimensional hyperrectangle.
18
19    Input:
20
21        n: dimension of search space (number of decision variables)
22
23        fgrad: the objective function of the form fgrad(n, x, grad, data),
24               returning the objective function at x, where
25                  n: dimension of search space
26                  x: pointer to array of length n, point to evaluate
27                  grad: if non-NULL, an array of length n which
28                        should on return be the gradient d(fgrad)/dx
29                        [ if NULL, grad should be ignored ]
30                  data: arbitrary data pointer, whose value is the
31                        data argument of stogo_minimize
32
33        data: arbitrary pointer to any auxiliary data needed by fgrad
34
35        l, u: arrays of length n giving the lower and upper bounds of the
36              search space
37
38        maxeval: if nonzero, a maximum number of fgrad evaluations
39        maxtime: if nonzero, a maximum time (in seconds)
40         -- REPLACED in NLopt by nlopt_stopping *stop
41
42        nrandom: number of randomized search points to use per box,
43                 in addition to 2*n+1 deterministic search points
44                 (0 for a deterministic algorithm).
45
46    Output:
47
48       minf: the minimum value of the objective function found
49
50       x: pointer to array of length n, giving the location of the minimum
51
52    Return value: 0 if no minimum found, 1 otherwise.
53
54  */
55
56 int stogo_minimize(int n,
57                    objective_func fgrad, void *data,
58                    double *x, double *minf,
59                    const double *l, const double *u,
60 #ifdef NLOPT_UTIL_H
61                    nlopt_stopping *stop,
62 #else
63                    long int maxeval, double maxtime,
64 #endif
65                    int nrandom);
66
67 extern int stogo_verbose; /* set to nonzero for verbose output */
68
69 #ifdef __cplusplus
70 }
71 #endif
72
73 #endif