chiark / gitweb /
prepare to handle forced-stop in ORIG_DIRECT (not done yet)
authorstevenj <stevenj@alum.mit.edu>
Sat, 10 Jul 2010 21:59:37 +0000 (17:59 -0400)
committerstevenj <stevenj@alum.mit.edu>
Sat, 10 Jul 2010 21:59:37 +0000 (17:59 -0400)
darcs-hash:20100710215937-c8de0-b67e75ac8c2281b62aff33d86556069b4dc33c95.gz

api/optimize.c

index 52f443345f11ade43ec7ef9b257ca1225b0e0b76..b82cdf47b0c328c3b9aea9da03d127113f33acba 100644 (file)
@@ -92,8 +92,10 @@ static double f_direct(int n, const double *x, int *undefined, void *data_)
      unsigned i, j;
      f = data->f((unsigned) n, x, NULL, data->f_data);
      *undefined = isnan(f) || nlopt_isinf(f);
+     if (nlopt_get_force_stop(data)) return f;
      for (i = 0; i < data->m && !*undefined; ++i) {
          nlopt_eval_constraint(data->work, NULL, data->fc+i, (unsigned) n, x);
+         if (nlopt_get_force_stop(data)) return f;
          for (j = 0; j < data->fc[i].m; ++j)
               if (data->work[j] > 0)
                    *undefined = 1;