[SciPy-dev] Advice on Simulated Annealing (ticket #875)

josef.pktd@gmai... josef.pktd@gmai...
Mon Mar 2 13:04:11 CST 2009


On Mon, Mar 2, 2009 at 12:04 PM, william ratcliff
<william.ratcliff@gmail.com> wrote:
> Here is code that will demonstrate the failure.  Suppose you want to
> minimize the simple function f(x,y)=x^2+y^2, but you want to do it in a
> specified domain.  This will not respect the upper and lower bounds:
>
> cheers,
> William
>
>
> import numpy as N
> import scipy.optimize.anneal as anneal
>
> def fcn(p):
>     x,y=p
>     result=x**2+y**2
>     return result
>
>
> if __name__=="__main__":
>     p0=N.array([3,3],'d')
>     lowerm=[1,1]
>     upperm=[4,4]
>     myschedule='fast'
>     p0,jmin=anneal(fcn,p0,\
>                   schedule=myschedule,lower=lowerm,upper=upperm,\
>                   maxeval=None,
> maxaccept=None,dwell=10,maxiter=600,T0=10000)
>     print 'p0',p0,'jmin',jmin
>
>

After looking a bit more carefully:

`upper` and `lower` in` fast_ca` are the bounds on the updating
increment, xc, not on the parameters that are estimated x0, xnew  and
in the ticket. I didn't see any constraints on the parameters
themselves in anneal.

The current bounds restrict the updating to local perturbations, while
in your case perturbations would always be global.

Rewriting anneal to incorporate bounds might be a good enhancement
but, I think, you need to distinguish between bounds on the parameters
and bounds on the update increments. Then the update increments can
easily bound by  (xbounds - x0)  and you don't need iteration to find
the updated values.

Josef


More information about the Scipy-dev mailing list