Permalink
Browse files

BUG: optimize: don't clobber line search old_fval if the first one fa…

…ils, although this probably does not matter much (fixes #1158)
  • Loading branch information...
1 parent 9566405 commit bd6b450a6de9ac0be5eb125b5e3e838d5d6a9333 @pv pv committed Sep 5, 2010
Showing with 6 additions and 2 deletions.
  1. +6 −2 scipy/optimize/optimize.py
@@ -406,10 +406,14 @@ def fmin_bfgs(f, x0, fprime=None, args=(), gtol=1e-5, norm=Inf,
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)

0 comments on commit bd6b450

Please sign in to comment.