[Scipy-tickets] [SciPy] #1158: old_fval incorrectly overwritten when first line_search fails in optimize.fmin_bfgs

SciPy Trac scipy-tickets@scipy....
Tue Apr 20 13:58:03 CDT 2010


#1158: old_fval incorrectly overwritten when first line_search fails in
optimize.fmin_bfgs
----------------------------------+-----------------------------------------
 Reporter:  mrocklin              |       Owner:  somebody
     Type:  defect                |      Status:  new     
 Priority:  low                   |   Milestone:  0.8.0   
Component:  Other                 |     Version:  0.7.0   
 Keywords:  optimize line_search  |  
----------------------------------+-----------------------------------------
 As a disclaimer this is my first bug-report. I apologize if I'm not
 following style or haven't double-checked things enough. My understanding
 of this is minimal.

 In optimize.fmin_bfgs, lines 720:726

 {{{
         alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
            linesearch.line_search(f,myfprime,xk,pk,gfk,
                                   old_fval,old_old_fval)
         if alpha_k is None:  # line search failed try different one.
             alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
                      line_search(f,myfprime,xk,pk,gfk,
                                  old_fval,old_old_fval)

 }}}

 If the line_search function in the linesearch module fails we use a second
 line_search function in this module (optimize). Unfortunately, when we
 call the first line_search() we overwrite the old_fval and old_old_fval
 values with the bogus results from the failing function. When we call the
 second line_search function we reuse these result values rather than the
 original ones. A correction could look like:


 {{{
         old_fval_b, old_old_fval_b = old_fval, old_old_fval;
         alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
            linesearch.line_search(f,myfprime,xk,pk,gfk,
                                   old_fval,old_old_fval)
         if alpha_k is None:  # line search failed try different one.
             alpha_k, fc, gc, old_fval, old_old_fval, gfkp1 = \
                      line_search(f,myfprime,xk,pk,gfk,
                                  old_fval_b,old_old_fval_b)

 }}}

 Of course, one should never get to this stage if one's function is nice.
 Not all functions are nice.

 Thank you for your time,
 Matthew

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1158>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list