From: stevenj Date: Mon, 14 Jun 2010 18:21:29 +0000 (-0400) Subject: C++, STOGO, and nocedal fixes X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3769419a240b7c118f9ed90c895e4198bbbb650e;p=nlopt.git C++, STOGO, and nocedal fixes darcs-hash:20100614182129-c8de0-4877a5f93a8e37ad69984339f01830c9bb35a7d2.gz --- diff --git a/api/f77api.c b/api/f77api.c index da709ae..15cf50f 100644 --- a/api/f77api.c +++ b/api/f77api.c @@ -21,6 +21,7 @@ */ #include +#include #include "nlopt.h" diff --git a/api/general.c b/api/general.c index 5d300ea..9e43228 100644 --- a/api/general.c +++ b/api/general.c @@ -23,8 +23,7 @@ #include #include -#include "nlopt.h" -#include "nlopt-util.h" +#include "nlopt-internal.h" /*************************************************************************/ @@ -128,11 +127,11 @@ void nlopt_srand(unsigned long seed) { nlopt_init_genrand(seed); } -void nlopt_srand_time() { +void nlopt_srand_time(void) { nlopt_srand(nlopt_time_seed() + my_gettid() * 314159); } -void nlopt_srand_time_default() { +void nlopt_srand_time_default(void) { if (!nlopt_srand_called) nlopt_srand_time(); } diff --git a/api/nlopt-internal.h b/api/nlopt-internal.h index fc43db3..e8a80ff 100644 --- a/api/nlopt-internal.h +++ b/api/nlopt-internal.h @@ -72,7 +72,7 @@ struct nlopt_opt_s { }; /*********************************************************************/ -void nlopt_srand_time_default(void); /* init the rand. seed only if unset */ +extern void nlopt_srand_time_default(void); /* init the rand. seed only if unset */ /*********************************************************************/ /* global defaults set by deprecated API: */ diff --git a/api/optimize.c b/api/optimize.c index 0f35707..50e5fa7 100644 --- a/api/optimize.c +++ b/api/optimize.c @@ -303,7 +303,7 @@ static nlopt_result nlopt_optimize_(nlopt_opt opt, double *x, double *minf) nbd[i] = linf && uinf ? 0 : (uinf ? 1 : (linf ? 3 : 2)); } iret = lbfgsb_minimize(ni, f, f_data, x, nbd, lb, ub, - MIN(ni, 5), 0.0, stop.ftol_rel, + ni < 5 ? ni : 5, 0.0, stop.ftol_rel, stop.xtol_abs[0] > 0 ? stop.xtol_abs[0] : stop.xtol_rel, stop.maxeval); diff --git a/stogo/local.cc b/stogo/local.cc index ccf5802..89802b6 100644 --- a/stogo/local.cc +++ b/stogo/local.cc @@ -82,7 +82,7 @@ int local(Trial &T, TBox &box, TBox &domain, double eps_cl, double *mgr, return LS_Old ; } -#ifdef NLOPT_H +#if 0 if (axis != -1) { cout << "NLopt code only works with axis == -1, exiting...\n" ; diff --git a/stogo/stogo.cc b/stogo/stogo.cc index 69a4f8d..146a9bc 100644 --- a/stogo/stogo.cc +++ b/stogo/stogo.cc @@ -18,9 +18,9 @@ public: switch (which) { case GRADIENT_ONLY: case OBJECTIVE_AND_GRADIENT: - return my_func(xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data); + return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), grad.raw_data(), my_data); case OBJECTIVE_ONLY: - return my_func(xy.GetLength(), xy.raw_data_const(), NULL, my_data); + return my_func((unsigned) xy.GetLength(), xy.raw_data_const(), NULL, my_data); } return 0.0; } diff --git a/stogo/stogo.h b/stogo/stogo.h index 7ca57f3..211f3d8 100644 --- a/stogo/stogo.h +++ b/stogo/stogo.h @@ -10,7 +10,7 @@ extern "C" { #endif -typedef double (*objective_func)(int n, const double *x, double *grad, +typedef double (*objective_func)(unsigned n, const double *x, double *grad, void *data); /* search for the global minimum of the function fgrad(n, x, grad, data)