[SciPy-dev] Trouble with optimize.fmin_ncg

dmitrey openopt at ukr.net
Wed Jul 25 05:55:59 EDT 2007


Nils Wagner wrote:
> Matthieu Brucher wrote:
>   
>> Hi,
>>
>> Here is a link to the diff :
>> http://projects.scipy.org/scipy/scipy/changeset?old_path=trunk%2FLib%2Foptimize&old=3116&new_path=trunk%2FLib%2Foptimize&new=3189
>> <http://projects.scipy.org/scipy/scipy/changeset?old_path=trunk%2FLib%2Foptimize&old=3116&new_path=trunk%2FLib%2Foptimize&new=3189>
>>
>> Matthieu
>>
>>     
> Since the other optimizers are not affected, we may  cut it down to
> optimize.py.
>
> Is it possible that
>
> http://projects.scipy.org/scipy/scipy/changeset/3176
> http://projects.scipy.org/scipy/scipy/changeset/3177
>   
I have missed one bracket
fun(*(x,) +args) instead of fun(*((x,) +args))
(and now I fixed it, lines 1481, 1482,1027)
however, seems like it work without additional brackets as well:
 >>> f = lambda x,y,z,t: x+y+z+t
 >>> f(*((4,)+(5,)+(6,)+(7,)))
22
 >>> f(*(4,)+(5,)+(6,)+(7,))
22

But since your funcs take no additional arguments (only x is present), 
it's not the matter.
I checked - the problem remains.
I took a look at other changes and still can't find what's the problem.
the changes

    [A,B] = numpy.dot([[dc**2, -db**2],[-dc**3, 
db**3]],[fb-fa-C*db,fc-fa-C*dc]) 
  	309 	    d1 = empty((2,2)) 
  	310 	    d1[0,0] = dc**2 
  	311 	    d1[0,1] = -db**2 
  	312 	    d1[1,0] = -dc**3 
  	313 	    d1[1,1] = db**3 
  	314 	    [A,B] = 
numpy.dot(d1,asarray([fb-fa-C*db,fc-fa-C*dc]).flatten()) 

are not related to the problem, because my debugger don't reach a 
breakpoint placed here.


the changes
710 	  	        try: 
711 	  	            rhok = 1 / (numpy.dot(yk,sk)) 
712 	  	        except ZeroDivisionError: 
713 	  	            rhok = 1000. 
  	715 	        try: # this was handled in numeric, let it remaines for 
more safety 
  	716 	            rhok = 1.0 / (numpy.dot(yk,sk)) 
  	717 	        except ZeroDivisionError:  
  	718 	            rhok = 1000.0 
  	719 	            print "Divide-by-zero encountered: rhok assumed large" 
  	720 	        if isinf(rhok): # this is patch for numpy 
  	721 	            rhok = 1000.0 


are related to fmin_bfgs code.
> are responsible for the trouble with ncg ?
>
> Nils
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
>
>
>   




More information about the SciPy-Dev mailing list