[SciPy-Dev] Halting optimize.minimize

Andrew Nelson andyfaff at gmail.com
Thu Jan 8 06:59:47 EST 2015


I submitted https://github.com/scipy/scipy/pull/4384, to achieve this.  If
a callback function returns True the minimization halts. However, it won't
work for TNC minimizer as the callback is called from somewhere in the
Fortran and I know no Fortran (thank goodness).

On 8 January 2015 at 13:33, Robert McGibbon <rmcgibbo at gmail.com> wrote:

> +1 for something like this. In some of my applications, I want to remove
> variables from the optimization when they get sufficiently close to zero,
> so some control flow is needed to halt the optimization and then restart it
> with a different (reduced) set of independent variables.
>
> -Robert
>
> On Wed, Jan 7, 2015 at 5:57 PM, Andrew Nelson <andyfaff at gmail.com> wrote:
>
>> Dear devs,
>> often one might want to halt a minimization, especially if the
>> minimization is taking a long time.
>> This could be done by raising an Exception in the objective function or
>> callback function. e.g.
>>
>> def callback(xk):
>>     if something_is_not_to_our_liking(xk):
>>         raise HaltError('we wanted to stop')
>>
>> However, on halting one would not get the best solution found so far.
>> Could the optimize.minimize functions be adapted to stop a minimizer?  This
>> could be done in a couple of ways:
>> 1) the minimizer could catch something like a HaltError, raised either in
>> the objective function or in the callback function.  When it's caught the
>> minimizer should return the best solution so far.. I'm not sure how this
>> would work with the internals of each minimizer.
>> 2) the callback could return False if the minimizer has to stop, or True
>> to keep going.  Again, I'm not sure how this would work with the internals
>> of each minimizer.
>>
>> I'd also like to be able to halt a 'leastsq' optimization, in a similar
>> fashion.  What would be the best way of going about this?
>>
>> cheers,
>> Andrew.
>>
>>
>>
>> --
>> _____________________________________
>> Dr. Andrew Nelson
>>
>>
>> _____________________________________
>>
>> _______________________________________________
>> SciPy-Dev mailing list
>> SciPy-Dev at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-dev
>>
>>
>
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-dev
>
>


-- 
_____________________________________
Dr. Andrew Nelson


_____________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20150108/7963e77d/attachment.html>


More information about the SciPy-Dev mailing list