[SciPy-User] optimize.least_squares memory allocation every function call

Brian Hare bhare8972 at hotmail.com
Tue Apr 14 04:39:47 EDT 2020


I have a question about the scipy.optimize.least_squares function.  I have found that the function to optimize needs to reallocate the return array every time the function is called. I've tried having the calling function return the same array every time (just re-filled with the correct return values), but least_squares doesn't seem to converge when I do this.

I do not like having to allocate memory in the calling function, this seems slow and unnecessary. Is there a way around this? If not, could scipy.optimize.least_squares be adjusted so this is possible?

The Gnu Scientific Library (which I sometimes fall back on when scipy.optimize.least_squares is too slow, I think this allocation issue is one major contributor),  passes an array to the calling function to fill.

Thank you,
Brian Hare
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-user/attachments/20200414/a78de71e/attachment.html>


More information about the SciPy-User mailing list