[SciPy-user] scipy.optimize.anneal doesn't work properly?
dmitrey
dmitrey.kroshko at scipy.org
Sun Oct 7 09:20:50 EDT 2007
Hi all,
I try to connect scipy.optimize anneal to openopt,
and here are suspicious examples I constantly get, that seems to show
anneal() don't work properly:
>>> from numpy import asfarray
>>> x_opt = anneal(lambda x: (x**2).sum(), asfarray([1,-1]))
Warning: Cooled to 31.093245 at [-5.56463126 0.35794414] but this is
not the smallest point found.
>>> x_opt
(array([ 1.88050049, -1.49370399]), 5)
(this is typical output, because anneal uses random numbers generator)
So, as you see, f(x_opt) is even greater than f(x0),
because 1.88050049**2 +1.49370399**2 > 1**2+(-1)**2
Same problem we can observe with even nVars = 1:
>>> x_opt = anneal(lambda x: (x**2).sum(), asfarray([0.1]))
Warning: Cooled to 0.234018 at 0.483754056848 but this is not the
smallest point found.
>>> x_opt
(array([ -8.99753917e-09]), 1)
(typical output is x=+/-0.01...+/-0.8)
Of course, maybe scipy.optimize.anneal default lb-ub bounds that are set
to +/-100 affect the solution obtained (as for me I dislike these
defaults), but anyway - isn't it a bug, especially 1st example, where
f(x_opt) is greater than f(x0)?
for nVars = 3 the situation (as I expected) is even more bad:
>>> x_opt = anneal(lambda x: (x**2).sum(), asfarray([1,2,3]))
Warning: Cooled to 1205.692393 at [ 9.59094938 31.96016313
-9.60489749] but this is not the smallest point found.
>>> x_opt
(array([-28.66744536, 3.62546302, 15.94018009]), 5)
Best regards, Dmitrey
More information about the SciPy-User
mailing list