chiark / gitweb /
use nlopt_stopping in StoGO (currently only for maxevals and maxtime)
[nlopt.git] / util / nlopt-util.h
1 #ifndef NLOPT_UTIL_H
2 #define NLOPT_UTIL_H
3
4 #ifdef __cplusplus
5 extern "C"
6 {
7 #endif /* __cplusplus */
8
9 /* seconds timer */
10 extern double nlopt_seconds(void);
11 extern unsigned long nlopt_time_seed(void);
12
13 /* pseudorandom number generation by Mersenne twister algorithm */
14 extern void nlopt_init_genrand(unsigned long s);
15 extern double nlopt_urand(double a, double b);
16
17 /* stopping criteria */
18 typedef struct {
19      int n;
20      double fmin_max;
21      double ftol_rel;
22      double ftol_abs;
23      double xtol_rel;
24      const double *xtol_abs;
25      int nevals, maxeval;
26      double maxtime, start;
27 } nlopt_stopping;
28 extern int nlopt_stop_f(const nlopt_stopping *stop, double f, double oldf);
29 extern int nlopt_stop_ftol(const nlopt_stopping *stop, double f, double oldf);
30 extern int nlopt_stop_x(const nlopt_stopping *stop, 
31                         const double *x, const double *oldx);
32 extern int nlopt_stop_xs(const nlopt_stopping *stop, 
33                          const double *xs, const double *oldxs,
34                          const double *scale_min, const double *scale_max);
35 extern int nlopt_stop_evals(const nlopt_stopping *stop);
36 extern int nlopt_stop_time(const nlopt_stopping *stop);
37 extern int nlopt_stop_evalstime(const nlopt_stopping *stop);
38
39 #ifdef __cplusplus
40 }  /* extern "C" */
41 #endif /* __cplusplus */
42
43 #endif