nlopt icon indicating copy to clipboard operation
nlopt copied to clipboard

which_args value passed to cdirect_unscaled() in nlopt_optimize_()

Open jcottrell-ellex opened this issue 6 years ago • 2 comments

I believe there's a bug in optimize.c, in the big switch statement that farms out the optimisation to the selected algorithm. The algorithm -> which_alg -> {which_diam, which_div, which_opt} mapping is a bit tricky to follow, but it appears that cdirect_unscaled() is always called with which_alg = 13 (as intended for NLOPT_GN_DIRECT_L_NOSCAL), because all the conditional operators test the algorithm variable against constants without the _NOSCAL suffix (guaranteed to be != here).

This might be clearer if cdirect.h had a struct of enums representing the {which_diam, which_div, which_opt} settings, which could be set by a few lines of code in optimize.c and passed in. Maybe the 'unscaled' variant could also be turned on or off in the same struct, but that's a bigger change.

Cheers, Joel

jcottrell-ellex avatar Jun 04 '19 07:06 jcottrell-ellex

Could you show us the offending lines ?

jschueller avatar Jun 04 '19 19:06 jschueller

Hi Julien, thank you for responding. The issue can be seen on reading lines 438-453 of /src/api/optimize.c, with the actual bug on 452-453.

jcottrell-ellex avatar Jun 05 '19 01:06 jcottrell-ellex