[SciPy-user] convergence detection in optimize/nonlin.py

Andrew Hawryluk HAWRYLA@novachem....
Wed Nov 12 17:29:24 CST 2008


I am experimenting with optimize.broyden3() for solving a multivariable,
nonlinear problem. The signature is
  def broyden3(F, xin, iter=10, alpha=0.4, verbose = False)
and it is written to iterate exactly 'iter' times.

However, after it converges (to within machine tolerances) it runs into
division by zero errors and fails while trying to take the square root
of a NaN. I have modified my copy as follows.

Original (revision 5067), beginning on line 151:

        #Gm=Gm+(deltaxm-Gm*deltaFxm)*deltaFxm.T/norm(deltaFxm)**2
        updateG(deltaxm-Gmul(deltaFxm),deltaFxm/norm(deltaFxm)**2)

Modified version, beginning on line 151

        normDelta = norm(deltaFxm)
        if normDelta == 0.0:
            break
        #Gm=Gm+(deltaxm-Gm*deltaFxm)*deltaFxm.T/norm(deltaFxm)**2
        updateG(deltaxm-Gmul(deltaFxm),deltaFxm/normDelta**2)

All of the routines in optimize/nonlin.py have the same behaviour. Could
we add some convergence checking to each of them? Should 'iter' be
called 'maxiter' to reflect this?

Andrew Hawryluk


More information about the SciPy-user mailing list