chiark / gitweb /
fix xtol test in sbplx
authorstevenj <stevenj@alum.mit.edu>
Tue, 11 Nov 2008 05:57:23 +0000 (00:57 -0500)
committerstevenj <stevenj@alum.mit.edu>
Tue, 11 Nov 2008 05:57:23 +0000 (00:57 -0500)
darcs-hash:20081111055723-c8de0-ccf13dd14cb29b1278db5fdec22ae833c6798530.gz

neldermead/sbplx.c

index cc399410ded9afad60b03313fc6bf40afb4cec73..1d2048008721aa4dddcf11cdbffa4c6c35f20710 100644 (file)
@@ -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 */