chiark / gitweb /
Use trusty
[nlopt.git] / neldermead / nldrmd.c
index ee86e92d1c8ddaebe7f4be2f3a214f376adbb3c8..a8e7ee479b079560dc04587c1be3c4b0d2d634dc 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2010 Massachusetts Institute of Technology
+/* Copyright (c) 2007-2014 Massachusetts Institute of Technology
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files (the
@@ -153,7 +153,12 @@ nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
                                           ub[i] : lb[i]) + x[i]);
               }
          }
-         if (close(pt[1+i], x[i])) { ret=NLOPT_FAILURE; goto done; }
+         if (close(pt[1+i], x[i])) { 
+              nlopt_stop_msg(stop, "starting step size led to simplex that was too small in dimension %d: %g is too close to x[%d]=%g",
+                             i, pt[1+i], i, x[i]);
+              ret=NLOPT_FAILURE;
+              goto done; 
+          }
          pt[0] = f(n, pt+1, NULL, f_data);
          CHECK_EVAL(pt+1, pt[0]);
      }
@@ -175,7 +180,7 @@ nlopt_result nldrmd_minimize_(int n, nlopt_func f, void *f_data,
          *fdiff = fh - fl;
 
          if (init_diam == 0) /* initialize diam. for psi convergence test */
-              for (i = 0; i < n; ++i) init_diam = fabs(xl[i] - xh[i]);
+              for (i = 0; i < n; ++i) init_diam += fabs(xl[i] - xh[i]);
 
          if (psi <= 0 && nlopt_stop_ftol(stop, fl, fh)) {
               ret = NLOPT_FTOL_REACHED;