From: stevenj Date: Tue, 11 Nov 2008 05:57:23 +0000 (-0500) Subject: fix xtol test in sbplx X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=416b0fd0d5ca29e2acd696cec26778f6f4527cf0;p=nlopt.git fix xtol test in sbplx darcs-hash:20081111055723-c8de0-ccf13dd14cb29b1278db5fdec22ae833c6798530.gz --- diff --git a/neldermead/sbplx.c b/neldermead/sbplx.c index cc39941..1d20480 100644 --- a/neldermead/sbplx.c +++ b/neldermead/sbplx.c @@ -187,8 +187,19 @@ nlopt_result sbplx_minimize(int n, nlopt_func f, void *f_data, goto done; } if (nlopt_stop_x(stop, x, xprev)) { - ret = NLOPT_XTOL_REACHED; - goto done; + int j; + /* as explained in Rowan's thesis, it is important + to check |xstep| as well as |x-xprev|, since if + the step size is too large (in early iterations), + the inner Nelder-Mead may not make much progress */ + for (j = 0; j < n; ++j) + if (fabs(xstep[j]) * psi > stop->xtol_abs[j] + && fabs(xstep[j]) * psi > stop->xtol_rel * fabs(x[j])) + break; + if (j == n) { + ret = NLOPT_XTOL_REACHED; + goto done; + } } /* compute change in optimal point */