convergence detection in optimize/nonlin.py
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
Wed, 12 Nov 2008 16:29:24 -0700, Andrew Hawryluk wrote:
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. [clip]
Yes, I think these methods should terminate after reaching user-specified tolerances. IIRC, divisions by zero etc. are not uncommon in Broyden methods if they are run to very short step lengths. It's a bug, ticket here: http://scipy.org/scipy/scipy/ticket/791 -- Pauli Virtanen
participants (2)
-
Andrew Hawryluk
-
Pauli Virtanen