[SciPy-user] optimize.fmin_l_bfgs_b problem

Nils Wagner nwagner@iam.uni-stuttgart...
Wed Jun 11 15:19:12 CDT 2008


On Wed, 11 Jun 2008 22:00:05 +0200
  Marek Wojciechowski <mwojc@p.lodz.pl> wrote:
> Nils Wagner wrote:
> 
>> On Mon, 9 Jun 2008 15:50:53 +0200
>>   Marek Wojciechowski <mwojc@p.lodz.pl> wrote:
>>> Hi!
>>> The following command:
>>>    optimize.fmin_l_bfgs_b(lambda x: x[0]**2, [-1.],
>>>iprint=1)
>>> causes an error and breaks the python session with the
>>>following output:
>>> 
>>> RUNNING THE L-BFGS-B CODE
>>> 
>>>           * * *
>>> 
>>> At line 2647 of file scipy/optimize/lbfgsb/routines.f
>>> Internal Error: printf is broken
>>> Machine precision =
>>> 
>>> This occurs on scipy-0.6.0 and python 2.4 under Gentoo
>>>Linux. Is this the
>>> known bug?
>>> 
>>> Greetings,
>>> --
>>> Marek Wojciechowski
>> 
>> I get
>> 
>>>>> optimize.fmin_l_bfgs_b(lambda x: x[0]**2, [-1.], 
>>>>>iprint=1)
>> RUNNING THE L-BFGS-B CODE
>> 
>>             * * *
>> 
>> Machine precision = 2.220E-16
>>   N =  1    M =  10
>>   This problem is unconstrained.
>> 
>> At X0         0 variables are exactly at the bounds
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>>    File
>> "/data/home/nwagner/local/lib/python2.5/site-packages/scipy/optimize/lbfgsb.py",
>> line 205, in fmin_l_bfgs_b
>>      f, g = func_and_grad(x)
>>    File
>> "/data/home/nwagner/local/lib/python2.5/site-packages/scipy/optimize/lbfgsb.py",
>> line 156, in func_and_grad
>>      f, g = func(x, *args)
>> TypeError: 'numpy.float64' object is not iterable
>> 
>>>>> scipy.__version__
>> '0.7.0.dev4420'
> 
> It seems that my bug is corrected in development 
>versions of scipy.
> Exception you obtained results probably from new layout 
>of lbfgsb
> optimizer. I think the following should work:
> 
> optimize.fmin_l_bfgs_b(lambda x: (x[0]**2, 2*x[0]), 
>[-1.], iprint=1)
> 
> Greetings,
> -- 
> Marek Wojciechowski
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

Try

python -i test_l_bfgs_b.py
RUNNING THE L-BFGS-B CODE

            * * *

Machine precision = 2.220E-16
  N =  1    M =  10
  This problem is unconstrained.

At X0         0 variables are exactly at the bounds

At iterate    0    f=  1.00000E+00    |proj g|= 
 2.00000E+00

At iterate    1    f=  0.00000E+00    |proj g|= 
 0.00000E+00

            * * *

Tit   = total number of iterations
Tnf   = total number of function evaluations
Tnint = total number of segments explored during Cauchy 
searches
Skip  = number of BFGS updates skipped
Nact  = number of active bounds at final generalized 
Cauchy point
Projg = norm of the final projected gradient
F     = final function value

            * * *

    N   Tit  Tnf  Tnint  Skip  Nact     Projg        F
     1    1    2      1     0     0   0.000E+00 
  0.000E+00
   F =  0.

CONVERGENCE: NORM OF PROJECTED GRADIENT <= PGTOL

  Cauchy                time 0.000E+00 seconds.
  Subspace minimization time 0.000E+00 seconds.
  Line search           time 0.000E+00 seconds.

  Total User time 4.000E-03 seconds.

Position of the minimum [ 0.]
Value of func(x) [ 0.]
Dictionary {'warnflag': 0, 'task': 'CONVERGENCE: NORM OF 
PROJECTED GRADIENT <= PGTOL', 'grad': array([ 0.]), 
'funcalls': 2}
  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_l_bfgs_b.py
Type: text/x-python
Size: 263 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080611/2f03fccf/attachment.py 


More information about the SciPy-user mailing list