[SciPy-user] number of function evaluation for leastsq

dmitrey dmitrey.kroshko at scipy.org
Tue Apr 15 14:47:59 EDT 2008


You could try using leastsq from scikits.openopt, it has mechanism for 
preventing double-call objective function with same x value as before.

Regards, D.

Achim Gaedke wrote:
> Hello!
>
> I use scipy.optimize.leastsq to adopt paramters of a model to measured
> data. Each evaluation of that model costs 1.5 h of computation time.
> Unfortunately I can not specify a gradient function.
>
> While observing the approximation process I found that the first 3 runs
> were always with the same parameters. First I thought, the parameter
> variation for gradient approximation is too tiny for a simple print
> command. Later I found out, that these three runs were independent of
> the number of fit parameters.
>
> A closer look to the code reveals the reason (svn dir trunk/scipy/optimize):
>
> 1st call is to check with python code wether the function is valid
>
> line 265 of minpack.py
> m = check_func(func,x0,args,n)[0]
>
> 2nd call is to get the right amount of memory for paramters.
>
> line 449 of __minpack.h
> ap_fvec = (PyArrayObject *)call_python_function(fcn, n, x, extra_args,
> 1, minpack_error);
>
> 3rd call is from inside the fortran algorithm (the essential one!)
>
> Unfortunately that behaviour is not described and I would eagerly demand
> to avoid the superficial calls to the function.
>
> Yours, Achim
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
>
>
>   




More information about the SciPy-User mailing list