[SciPy-User] fmin_bfgs stuck in infinite loop

Johann Cohen-Tanugi johann.cohentanugi@gmail....
Mon Oct 24 14:36:34 CDT 2011



On 10/24/2011 07:56 PM, josef.pktd@gmail.com wrote:
> On Mon, Oct 24, 2011 at 1:50 PM, Johann Cohen-Tanugi
> <johann.cohentanugi@gmail.com>  wrote:
>> Hello,
>> the OP is a colleague of mine and I looked quickly at the code. The infinite
>> loop in the OP's illustrating script comes from the "while 1" loop in l.144
>> of linesearch.py : becuse phi0 is np.nan, phi1 is returned as np.nan as
>> well, and the break condition is never met. There is an easy fix :
>>      while 1:
>>          stp, phi1, derphi1, task = minpack2.dcsrch(alpha1, phi1, derphi1,
>>                                                     c1, c2, xtol, task,
>>                                                     amin, amax, isave, dsave)
>>          if task[:2] == asbytes('FG') and not np.isnan(phi1):
>>              alpha1 = stp
>>              phi1 = phi(stp)
>>              derphi1 = derphi(stp)
>>          else:
>>              break
>>
>> but it is not a nice kludge.... Is there a better way to secure this while 1
>> loop? I am sure I am not covering all possible pathological cases with
>> adding "not np.isnan(phi1)" in the code above.
> Is this still a problem with 0.10 ?
> I thought this fixed it, https://github.com/scipy/scipy/commit/a31acbf
actually, this would not fix the nan issue, which ends up sitting on an 
infinite loop on l.531 where line_search_wolfe1 is called.
So the 2 trac entries were maybe different : one meant for +/-inf which 
is fixed, and one for the nan case, which is still problematic.

best,
Johann
> Josef
>
>
>> thoughts?
>> Johann
>>
>> On 08/14/2011 01:38 AM, b9o2jnbm tsd71eam wrote:
>>
>> I have run into a frustrating problem where scipy.optimize.fmin_bfgs will
>> get stuck in an infinite loop.
>>
>> I have submitted a bug report:
>>
>> http://projects.scipy.org/scipy/ticket/1494
>>
>> but would also like to see if anybody on this list has any suggestions or
>> feedback.
>>
>> Thanks,
>>
>> --
>> This message has been scanned for viruses and
>> dangerous content by MailScanner, and is
>> believed to be clean.
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User@scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>


More information about the SciPy-User mailing list