[SciPy-dev] Trouble with fmin_cg
Nils Wagner
nwagner at iam.uni-stuttgart.de
Fri Jan 4 06:31:41 EST 2008
On Fri, 04 Jan 2008 13:23:00 +0200
dmitrey <dmitrey.kroshko at scipy.org> wrote:
> I guess monitor(x0) is real number, not function.
> Hence it yields error.
> Maybe you need
>
> fmin_cg(func,x0,callback=monitor) ?
>
> BTW there is a way of connecting user-defined output
>func in openopt, I
> can explain you if you are interested (I haven't
>provided an example to
> OO documentation yet).
>
> Regards, D.
>
> Nils Wagner wrote:
>> Hi all,
>>
>> If I run the following script
>>
>> from scipy import *
>>
>> def func(x):
>> return 0.5*dot(x,dot(A,x))-dot(x,b)
>>
>> def monitor(x):
>> res = linalg.norm(dot(A,x)-b)
>> return res
>>
>> n = 10
>> x0 = zeros(n,float)
>> A = random.rand(n,n)+diag(4*ones(n))
>> A = 0.5*(A+A.T)
>> b = random.rand(n)
>>
>> x = optimize.fmin_cg(func,x0,callback=monitor(x0))
>>
>> I get
>>
>> Traceback (most recent call last):
>> File "test_fmin_cg.py", line 16, in <module>
>> x = optimize.fmin_cg(func,x0,callback=monitor(x0))
>> File
>> "/usr/local/lib64/python2.5/site-packages/scipy/optimize/optimize.py",
>> line 911, in fmin_cg
>> callback(xk)
>> TypeError: 'numpy.float64' object is not callable
>>
>> Is that a bug ?
>>
>> Nils
>> _______________________________________________
>> Scipy-dev mailing list
>> Scipy-dev at scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-dev
>>
>>
>>
>>
>
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
Hi Dmitrey,
Thank you for your prompt reply.
It would be very kind of you if you could supply an OO
example.
Cheers
Nils
More information about the SciPy-Dev
mailing list