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

Rob Falck robfalck@gmail....
Sat Oct 31 08:02:25 CDT 2009


I have a fix for this which changes the default bounds from +/- 1E12 to
numpy.finfo(float).max and numpy.finfo(float).min.  It also now detects None
and inf and replaces them with max or min, depending on whether they are
used in the upper or lower bound.  I'll try to get it into the system this
weekend.

On Tue, Oct 20, 2009 at 10:13 AM, <josef.pktd@gmail.com> wrote:

> 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
> > bug please help me sort it out.
> >
>
> 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
> >
> >
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



-- 
- Rob Falck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20091031/4f4fdcb1/attachment.html 


More information about the SciPy-User mailing list