From: stevenj Date: Thu, 19 Nov 2009 00:23:12 +0000 (-0500) Subject: isres should ignore change in f and x on first evaluation X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=38be1b2c09256d269034055565a68e00025b314a;p=nlopt.git isres should ignore change in f and x on first evaluation darcs-hash:20091119002312-c8de0-40fd94fd0d8d0dd456c2a51e5a20608b70e9ca07.gz --- diff --git a/isres/isres.c b/isres/isres.c index 9cd3dec..c41a8ee 100644 --- a/isres/isres.c +++ b/isres/isres.c @@ -83,6 +83,8 @@ nlopt_result isres_minimize(int n, nlopt_func f, void *f_data, double minf_penalty = HUGE_VAL, minf_gpenalty = HUGE_VAL; double taup, tau; + *minf = HUGE_VAL; + if (!population) population = 20 * (n + 1); if (population < 1) return NLOPT_INVALID_ARGS; survivors = ceil(population * SURVIVOR); @@ -149,11 +151,13 @@ nlopt_result isres_minimize(int n, nlopt_func f, void *f_data, && (penalty[k] != minf_penalty || fval[k] != *minf)) { if (fval[k] < stop->minf_max && penalty[k] == 0) ret = NLOPT_MINF_MAX_REACHED; - else if (nlopt_stop_f(stop, fval[k], *minf) + else if (!nlopt_isinf(*minf)) { + if (nlopt_stop_f(stop, fval[k], *minf) && nlopt_stop_f(stop, penalty[k], minf_penalty)) - ret = NLOPT_FTOL_REACHED; - else if (nlopt_stop_x(stop, xs+k*n, x)) - ret = NLOPT_XTOL_REACHED; + ret = NLOPT_FTOL_REACHED; + else if (nlopt_stop_x(stop, xs+k*n, x)) + ret = NLOPT_XTOL_REACHED; + } memcpy(x, xs+k*n, sizeof(double)*n); *minf = fval[k]; minf_penalty = penalty[k];