# [Scipy-tickets] [SciPy] #1126: scipy.optimize.anneal does not respect lower/upper bounds

SciPy Trac scipy-tickets@scipy....
Mon Feb 21 07:58:52 CST 2011

```#1126: scipy.optimize.anneal does not respect lower/upper bounds
--------------------------------+-------------------------------------------
Reporter:  lboussouf           |       Owner:  somebody
Type:  defect              |      Status:  new
Priority:  normal              |   Milestone:  Unscheduled
Component:  scipy.optimize      |     Version:
Keywords:  bounds upper lower  |
--------------------------------+-------------------------------------------

Comment(by Titus):

I also struggled with the annealing-routine, but now it seems fine. The
reason is indeed the input-parameters "lower" and "upper" that are not
very logic. They do not refer to global bounds of the parameters space but
to 'maximum' displacements in the MC scheme AND in addition they determine
the initial point!! This last point wasnot mentioned before, I think.

The initial value that you provide for the parameter vector seems to have
no influence.

This is how I call anneal with my desired functionality

p=[a,b,c] #my initial values

lb=array([a0,b0,c0]) #my lower bounds

ub=array([a1,b1,c1]) #my upper bounds

N=100 #determines the size of displacements

dx=(ub-lb)/N #displacements

lower=array(p)-dx/2 #the "lower bound" of the anneal routine

upper=array(p)+dx/2 #the "upper bound" of the anneal routine

f=lambda var: costfunction(p,lb,ub) #my cost function that is made very
high if not lb < p < ub

pbest=scipy.optimize.anneal(f,p,lower=lower,upper=upper)

This ensures a MC search that starts of close to my initial value and
makes steps of dx in its search.

~

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1126#comment:7>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```