[SciPy-user] fmin_bfgs doesn't terminate

Bernhard Voigt bernhard.voigt at gmail.com
Wed May 23 08:17:52 EDT 2007


Dear all!

I'm using scipy.optimize.fmin_bfgs to perform a log likelihood fit.
Unfortunately it doesn't terminate in many cases. I guess the reason is an
endless loop in linesearch.py:

    while 1:
        stp,fval,derphi,task = minpack2.dcsrch(alpha1, phi0, derphi0, c1,
c2,
                                               xtol, task, amin,
amax,isave,dsave)

        if task[:2] == 'FG':
            alpha1 = stp
            fval = f(xk+stp*pk,*args)
            fc += 1
            gval = fprime(xk+stp*pk,*newargs)
            if gradient: gc += 1
            else: fc += len(xk) + 1
            phi0 = fval
            derphi0 = numpy.dot(gval,pk)
        else:
            break

This only terminates, when the task is set to something different than 'FG'.
However, it happens that this takes forever, this could be related to some
problems determining the gradient of my llh function and/or the initial
seed. Anyway, wouldn't it be usefull to insert a hard limit for that loop
and raise an Exception?

Thanks! Bernhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20070523/e9d31a53/attachment.html>


More information about the SciPy-User mailing list