[SciPy-User] computing f and fprime in one evaluation in scipy.optimize

Sturla Molden sturla@molden...
Mon Dec 10 11:04:15 CST 2012

Den 10. des. 2012 kl. 16:11 skrev Pauli Virtanen <pav@iki.fi>:

> Skipper Seabold <jsseabold <at> gmail.com> writes:
> [clip]
>> AFAIK, fmin_l_bfgs_b is the only optimize function written so that f
>> can also return fprime, but I agree that this could be a nice option
>> to the other ones.
> The good news is that minimize(f, .., jac=True) [1] also works like this,
> and works for all of the solvers (it caches the jacobian).

This is a problem I have run into with sp.optimize.leastsq as well. Caching did not solve the problem, as the Jacobian is rank ndata x nparam, and caching it made me run out of memory. Interestingly, MINPACK lmder.f obtains the residuals and the Jaobian in a single function call, thus the problem is not there in the original Fortran code. It is introduced by the SciPy wrapper. On the other hand, I also prefer to use LAPACK for least-squares solvers. I don't think the built-in QR in MINPACK is very efficient compared to e.g. MKL. (Which is why I seriously consider to write my own LM routine.)


More information about the SciPy-User mailing list