Skip to content

Commit

Permalink
BUG: optimize: don't clobber line search old_fval if the first one fa…
Browse files Browse the repository at this point in the history
…ils, although this probably does not matter much (fixes #1158)
  • Loading branch information
pv committed Sep 5, 2010
1 parent 9566405 commit bd6b450
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scipy/optimize/optimize.py
Expand Up @@ -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)
Expand Down

0 comments on commit bd6b450

Please sign in to comment.