[SciPy-user] Getting started with optimize.fmin_l_bfgs_b
Nils Wagner
nwagner at mecha.uni-stuttgart.de
Wed Jun 29 07:27:40 EDT 2005
Christian Kristukat wrote:
> Nils Wagner wrote:
>
>> Traceback (most recent call last):
>> File "bfgs_b.py", line 8, in ?
>> best, val, d = optimize.fmin_l_bfgs_b(func, guess, bounds=bounds)
>> File
>> "/usr/local/lib/python2.4/site-packages/scipy/optimize/lbfgsb.py",
>> line 183, in fmin_l_bfgs_b
>> f[0], g = func_and_grad(x)
>> File
>> "/usr/local/lib/python2.4/site-packages/scipy/optimize/lbfgsb.py",
>> line 135, in func_and_grad
>> f, g = func(x, *args)
>> TypeError: unpack non-sequence
>>
>> How can I resolve the problem ?
>
>
> Look at the docstring of l_bfgs_b - func is expected to return the
> function and its gradient!
>
> Regards, Christian
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
Hi Christian,
This my modified program
from scipy import *
def func(x):
return x[0]-x[1]
def fprime(x):
return array(([1,-1]))
guess = 1.2, 1.3
bounds = [(-2.0,2.0), (-2.0,2.0) ]
best, val, d = optimize.fmin_l_bfgs_b(func, guess, fprime,
approx_grad=True, bounds=bounds, iprint=2)
print 'Position of the minimum',best, 'and its value',val
Is it somehow possible to visualize (e.g. by matplotlib) the history of
the optimization process ?
Nils
More information about the SciPy-User
mailing list