optimize.least_squares memory allocation every function call

Brian Hare <[email protected]> Tue, 14 Apr 2020 08:39:47 +0000
Newsgroups gmane.comp.python.scientific.user
Message-ID <SC1PR80MB407925E44CF3C956AB0C6F2EB7DA0@SC1PR80MB4079.lamprd80.prod.outlook.com>
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

_______________________________________________
SciPy-User mailing list
[email protected]
https://mail.python.org/mailman/listinfo/scipy-user