# [SciPy-User] using scipy.optimize.fmin_slsqp and setting bounds=(None, None)

josef.pktd@gmai... josef.pktd@gmai...
Tue Oct 20 09:13:58 CDT 2009

```On Mon, Oct 19, 2009 at 5:46 PM, Peter Halverson
<halverson.peter@yahoo.com> wrote:
> I'm not sure if this is user error or an actual bug. When I attempt to set
> my bounds in fmin_slsqp the option bounds =[(-10,10),(0,None)] is not
> recognized Scipy crashes with
>
> IndexError                                Traceback (most recent call last)
>
> C:\Documents and Settings\All Users\Documents\Python\<ipython console> in
> <module>()
>
> C:\Python25\lib\site-packages\scipy\optimize\slsqp.pyc in fmin_slsqp(func,
> x0, eqcons, f_eqcons, ieqcons, f_ieqcons, bounds, fprime, fprime_eqcons,
> fprime_ieqcons, args, iter, acc, iprint, full_output, epsilon)
>     244             if bounds[i][0] > bounds[i][1]:
>     245                 raise ValueError, \
> --> 246                 'SLSQP Error: lb > ub in bounds[' + str(i) +']  ' +
> str(bounds[4])
>     247
>     248     xl = array( [ b[0] for b in bounds ] )
>
> IndexError: list index out of range
>
> My code:
>
> import numpy as np
> import scipy as sp
> from scipy.optimize import fmin_slsqp as fmincon
>
> #The purpose of this script is
> # minimize x0+x1^2
> # where a and b are constants
> # and 0<x0
> # and x1-x2>0
>
> def fitfun(x):
>     t=x[0]+x[1]**2
>     return t
>
> def confun(x):
>     return (x[0]-x[1])
>
> bnds =[(-10,10),(0,None)]
> guess=[0.5,0.5]
>
> fmincon(fitfun,guess,ieqcons=[confun],bounds=bnds)
>
> If this is a bug I will report it to the appropriate places. If its not a
>

I think bounds are just assumed to be finite (``inf`` doesn't work either)

If you set the bounds to a number that is unlikely to be binding,
then it works.

For example, with

bnds =[(-10,10),(0,1000)]

your example and several variations of it with different constraints binding,
that I tried, work without problems.

Josef
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
```