[Scipy-svn] r6681 - trunk/scipy/optimize

scipy-svn@scip... scipy-svn@scip...
Sat Sep 4 19:04:24 CDT 2010


Author: ptvirtan
Date: 2010-09-04 19:04:24 -0500 (Sat, 04 Sep 2010)
New Revision: 6681

Modified:
   trunk/scipy/optimize/optimize.py
Log:
BUG: optimize: don't clobber line search old_fval if the first one fails, although this probably does not matter much (fixes #1158)

Modified: trunk/scipy/optimize/optimize.py
===================================================================
--- trunk/scipy/optimize/optimize.py	2010-09-04 23:56:49 UTC (rev 6680)
+++ trunk/scipy/optimize/optimize.py	2010-09-05 00:04:24 UTC (rev 6681)
@@ -406,10 +406,14 @@
     gnorm = vecnorm(gfk,ord=norm)
     while (gnorm > gtol) and (k < maxiter):
         pk = -numpy.dot(Hk,gfk)
-        alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
+        alpha_k, fc, gc, old_fval2, old_old_fval2, gfkp1 = \
            line_search_wolfe1(f,myfprime,xk,pk,gfk,
                               old_fval,old_old_fval)
-        if alpha_k is None:  # line search failed try different one.
+        if alpha_k is not None:
+            old_fval = old_fval2
+            old_old_fval = old_old_fval2
+        else:
+            # line search failed: try different one.
             alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
                      line_search_wolfe2(f,myfprime,xk,pk,gfk,
                                         old_fval,old_old_fval)



More information about the Scipy-svn mailing list