[Scipy-tickets] [SciPy] #1778: fmin_ncg fails at Rosenbrock

SciPy Trac scipy-tickets@scipy....
Sat Nov 24 07:59:30 CST 2012


#1778: fmin_ncg fails at Rosenbrock
------------------------------+---------------------------------------------
 Reporter:  unknown (google)  |       Owner:  somebody    
     Type:  defect            |      Status:  needs_review
 Priority:  normal            |   Milestone:  Unscheduled 
Component:  scipy.optimize    |     Version:  devel       
 Keywords:  fmin_ncg          |  
------------------------------+---------------------------------------------
Changes (by josefpktd):

  * status:  new => needs_review


Comment:

 I was curious why fmin_ncg uses linesearch_bfgs while fmin_bfgs using wolf


 copying the linesearch code from fmin_bfgs to fmin_ncg

 {{{
         #alphak, fc, gc, old_fval = line_search_BFGS(f,xk,pk,gfk,old_fval)
         #################
         alpha_k, fc, gc, old_fval2, old_old_fval2, gfkp1 = \
            line_search_wolfe1(f,fprime,xk,pk,gfk,
                               old_fval,old_old_fval)
         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,fprime,xk,pk,gfk,
                                         old_fval,old_old_fval)
             if alpha_k is None:
                 # This line search also failed to find a better solution.
                 warnflag = 2
                 break
         alphak = alpha_k
         ###############################
 }}}

 I get

 {{{
 >>> res = optimize.fmin_ncg(optimize.rosen, np.array([-1.25, 1.0]),
 fprime=optimize.rosen_der, fhess=optimize.rosen_hess, avextol=1e-6,
 full_output=1, maxiter=1000)
 Optimization terminated successfully.
          Current function value: 0.000000
          Iterations: 60
          Function evaluations: 78
          Gradient evaluations: 137
          Hessian evaluations: 60
 }}}


 (Note, I changed the source in my installed scipy 0.9.0, since I cannot
 compile scipy, and that's what I have in my working python.)

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


More information about the Scipy-tickets mailing list