Hello,
It seems I found a bug in the COBYLA algorithm implementation. When an
initial-guess vector contains positive and negative values, in my
objective function I get "-inf" instead of actual values.
I found that the bug is due to scaling x inside of COBYLA (cobyla.c,
cobyla_minimize function). When dx vector contains negative values. s.lb
and s.ub rescaled, but with negative scale[j] they should be swapped too.
Please see attached patch.
Best regards,
Alexander
--- nlopt-2.3.original/cobyla/cobyla.c 2012-07-30 11:49:21.994645167 +0400
+++ nlopt-2.3/cobyla/cobyla.c 2012-07-30 14:27:28.482885214 +0400
@@ -187,6 +187,7 @@
func_wrap_state s;
nlopt_result ret;
double rhobeg, rhoend;
+ double t;
s.f = f; s.f_data = f_data;
s.m_orig = m;
@@ -204,6 +205,11 @@
s.ub = nlopt_new_rescaled(n, s.scale, ub);
if (!s.ub) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
+ for (j = 0; j < n; ++j)
+ if (s.ub[j] < s.lb[j]) {
+ t = s.lb[j]; s.lb[j] = s.ub[j]; s.ub[j] = t;
+ }
+
s.xtmp = (double *) malloc(sizeof(double) * n);
if (!s.xtmp) { ret = NLOPT_OUT_OF_MEMORY; goto done; }
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss