1 /* Copyright (c) 2007-2008 Massachusetts Institute of Technology
3 * Permission is hereby granted, free of charge, to any person obtaining
4 * a copy of this software and associated documentation files (the
5 * "Software"), to deal in the Software without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Software, and to
8 * permit persons to whom the Software is furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 /* workaround for Solaris + gcc 3.4.x bug (see configure.ac) */
31 #if defined(__GNUC__) && defined(REPLACEMENT_HUGE_VAL)
33 # define HUGE_VAL REPLACEMENT_HUGE_VAL
39 #endif /* __cplusplus */
41 int nlopt_isinf(double x);
43 /* re-entrant qsort */
44 extern void nlopt_qsort_r(void *base_, size_t nmemb, size_t size, void *thunk,
45 int (*compar)(void *, const void *, const void *));
48 extern double nlopt_seconds(void);
49 extern unsigned long nlopt_time_seed(void);
51 /* pseudorandom number generation by Mersenne twister algorithm */
52 extern void nlopt_init_genrand(unsigned long s);
53 extern double nlopt_urand(double a, double b);
54 extern int nlopt_iurand(int n);
55 extern double nlopt_nrand(double mean, double stddev);
57 /* Sobol' low-discrepancy-sequence generation */
58 typedef struct nlopt_soboldata_s *nlopt_sobol;
59 extern nlopt_sobol nlopt_sobol_create(unsigned sdim);
60 extern void nlopt_sobol_destroy(nlopt_sobol s);
61 extern void nlopt_sobol_next01(nlopt_sobol s, double *x);
62 extern void nlopt_sobol_next(nlopt_sobol s, double *x,
63 const double *lb, const double *ub);
64 extern void nlopt_sobol_skip(nlopt_sobol s, unsigned n, double *x);
66 /* stopping criteria */
73 const double *xtol_abs;
74 double htol_rel, htol_abs;
76 double maxtime, start;
78 extern int nlopt_stop_f(const nlopt_stopping *stop, double f, double oldf);
79 extern int nlopt_stop_ftol(const nlopt_stopping *stop, double f, double oldf);
80 extern int nlopt_stop_x(const nlopt_stopping *stop,
81 const double *x, const double *oldx);
82 extern int nlopt_stop_dx(const nlopt_stopping *stop,
83 const double *x, const double *dx);
84 extern int nlopt_stop_xs(const nlopt_stopping *stop,
85 const double *xs, const double *oldxs,
86 const double *scale_min, const double *scale_max);
87 extern int nlopt_stop_evals(const nlopt_stopping *stop);
88 extern int nlopt_stop_time(const nlopt_stopping *stop);
89 extern int nlopt_stop_evalstime(const nlopt_stopping *stop);
93 #endif /* __cplusplus */