[SciPy-user] scipy.optimize.anneal - problem with lower and upper

Sebastian Haase seb.haase@gmail....
Thu Jun 11 02:58:46 CDT 2009

On Thu, Jun 11, 2009 at 9:42 AM, Paul Rudin<paul@rudin.co.uk> wrote:
> I'm experimenting with scipy.optimize.anneal, but I'm confused about the
> 'lower' and 'upper' arguments. I was expecting that this would limit the
> range of values passed to the function being optimized. However this
> appears not the be the case, as running the snippet below
> illustrates. You'll soon see values being passed in that fall outside
> the range given by upper and lower. Have I misunderstood what these
> arguments are supposed to mean or is there a bug?
> (Incidentally - I'm also surprised that that first thing printed isn't
> the value for x0 that's passed in - but that's another question.)
> from scipy.optimize import anneal
> import numpy
> def test(*args):
>    print args
>    return numpy.random.random()
> anneal(test, numpy.ones(3)*0.5, lower=numpy.zeros(3), upper=numpy.ones(3))
Hi Paul,
As was recently mentioned on this list - the bounds refer the "end
result" being within the given range. But the function itself should
"somehow" be able to return values even outside -- you could try to
fake some values that "point back into the right region"

Sebastian Haase

More information about the SciPy-user mailing list