[SciPy-Dev] improvements of optimize package
Mon Sep 19 13:57:25 CDT 2011
On Mon, 19 Sep 2011 17:41:47 +0200,
Christoph Deil wrote:
> I think 'infodict' is fine, although if the dict also contains x, it contains
> everything and I would prefer 'result'.
> This is what Matt called it in his very nice lmfit package,
> although in his case it's actually the Minimizer class itself which stores the fit results:
I've updated the proposal and set it to 'info' for now. But I can
change this later if needed.
> I have no opinion if (x,result) or only (result) should be returned,
> the important point is that all solvers return a same-length tuple and
> are thus one can easily learn new ones and try different ones out for a given fit problem.
> Looking over your document again, there's only one more name that is not
> obvious to me and for which I had to look at the docstring: "ier".
> Can we rename it to "status" or if that is too general, maybe "optimizer_status" or something
> similar that is self-descriptive?
I agree. "status" looks fine.
> It would be amazing if I could do this with any optimizer:
> result = <optimizer call>
> if result.success:
> print 'Found minimum %s at position %s' % (result.fun, result.x)
> print 'Fit did not converge. The problem was:'
> print result.status, result.message
> Specifically I think it would be nice if "success" and "fun" (the function value on optimizer exit)
> were added to the results dict for all optimizers,
> since these are the most basic fit results besides "x" every user wants.
> The current problem with "fun" is that only some optimizers return it,
> so for those I have to add a line or two of code to do it myself after the fit.
> Since every optimizer has a "fun" value on exit I guess it doesn't hurt
> to put it in the results dict for all of them without any performance hit?
This should be doable. I will look at this when I'll start the actual
> The current problem with ier = status is that each optimizer has different numbers for success,
> e.g. for leastsq 1,2,3 or 4 is success, for anneal 0 and 1 is success, and looking at the fmin docu I can't
> figure out how to tell if the fit succeeded at all.
Yes, I noticed that and planned to select a convention (probably 0 for
converged and >0 otherwise).
> I guess the numbers returned are the ones from the underlying libraries and thus should not be changed,
> so maybe adding a bool success flag to every optimizer for new users would be nice.
Ok, why not. Basically `success = (status==0)`.
More information about the SciPy-Dev