From: stevenj Date: Sat, 10 Jul 2010 21:59:37 +0000 (-0400) Subject: prepare to handle forced-stop in ORIG_DIRECT (not done yet) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3f1aa34164b4cce1d96ce039badf999d8679fe93;p=nlopt.git prepare to handle forced-stop in ORIG_DIRECT (not done yet) darcs-hash:20100710215937-c8de0-b67e75ac8c2281b62aff33d86556069b4dc33c95.gz --- diff --git a/api/optimize.c b/api/optimize.c index 52f4433..b82cdf4 100644 --- a/api/optimize.c +++ b/api/optimize.c @@ -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;