From 38be1b2c09256d269034055565a68e00025b314a Mon Sep 17 00:00:00 2001 From: stevenj Date: Wed, 18 Nov 2009 19:23:12 -0500 Subject: [PATCH] isres should ignore change in f and x on first evaluation darcs-hash:20091119002312-c8de0-40fd94fd0d8d0dd456c2a51e5a20608b70e9ca07.gz --- isres/isres.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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]; -- 2.30.2