[SciPy-Dev] optimize: what should happen if objective functions return non-finite numbers?

Stephan Hoyer shoyer at gmail.com
Wed Jun 15 13:32:12 EDT 2016


On Tue, Jun 14, 2016 at 4:19 PM, Andrew Nelson <andyfaff at gmail.com> wrote:

> The behaviour one might expect in both examples could be to see a
> ValueError raised if there arenp.nan values returned from the objective
> function. I'm not totally sure of what to do if +/- np.inf is returned
> (-inf would be a very good global minimum).
>

It's not uncommon get pathological objective function values when you
optimize complex models (e.g., that integrate an ode).

I agree that the sane default behavior is to raise a ValueError when NaN is
encountered, but sometimes it's better to treat such data points as invalid.

The exact strategy would depend on the optimizer, but I think +np.inf is a
perfectly reasonable sentinel value to use to indicate that function value
is "bad" in a generic way. It would be nice if the scipy optimizers handled
this consistently.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20160615/6f6add28/attachment.html>


More information about the SciPy-Dev mailing list