Hey Adam, On Tue, Dec 7, 2010 at 7:17 PM, Adam Openshaw <[email protected]> wrote: > Hey there, > > I'm not sure why you would have wanted to set xtol_abs to a NULL pointer. > From > what I've read on the wiki, I assumed you neglect to set it (default) or if > you > wanted to set it to a constant value for all your parameters you use > nlopt_set_xtol_abs1(nl_opt opt, double tol).
Well, quoting from the deprecated C API wiki page: """ xtol_rel, xtol_abs — relative and absolute tolerances in the optimization parameter values. xtol_abs should either be NULL, in which case it is ignored (equivalent to zero tolerance), or otherwise it should point to an array of length n containing absolute tolerances in each parameter x[i]. Set any tolerance to zero for it to be ignored. """ [ http://ab-initio.mit.edu/wiki/index.php/NLopt_Deprecated_API_Reference ] So it seems xtol_abs = NULL is valid from the docs. I checked the NLopt 1.2 source and a NULL check on xtol_abs is there. > If you want to set specific tolerances for each variable, then you would use > nlopt_set_xtol_abs(nl_opt opt, const double *tol), where tol is an array of > doubles of size n (# of x's) that you initialize with tolerances for each > corresponding variable prior to calling nlopt_set_xtol_abs(...). > > I don't think passing a "real" pointer to xtol_abs is doing what you want. If > you simply passed a pointer pointing to n doubles of uninitialized data, then > I > bet the algorithm is using garbage data for your tolerances i.e. totally > broken. Yeah, what I meant to say is that I now pass it a non-NULL valid pointer (specifically from the first element of a std::vector of the proper size). > Maybe Steven has something else to add? I realize I'm using a deprecated API (and I'm planning to switch to the new C++ API ASAP), but if this analysis is correct NLopt 2.x ends up breaking code that seems to be legit from the docs, so I thought this should be reported. Cheers, Francesco. _______________________________________________ NLopt-discuss mailing list [email protected] http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss
