# [SciPy-dev] SLSQP Constrained Optimizer Status

Rob Falck robfalck@gmail....
Fri Dec 21 08:04:05 CST 2007

```Thanks for the catch in the docstring.  I've fixed that on the version of
slsqp.py attached to the ticket.

I'm not positive this is the correct minimum, but it definitely is trending
towards this result when that error in encountered.

This appears to be a case where SLSQP just can't quite zero in on the
minimum.  I know its a kludge, but lowering the requested accuracy to
1.0E-5yields a converged solution, within 3 or 4 decimal places of
what appears to
be the true minimum.

Does this appear to be yielding proper results?

from numpy import *
from scipy.optimize.slsqp import fmin_slsqp
N = 10
M = 5
ff = lambda x: (abs(x-M) ** 1.5).sum()
x0 = cos(arange(N))

print "Initial guess", x0

c = lambda x: asfarray([2* x[0] **4-32, x[1]**2+x[2]**2 - 8])

h1 = lambda x: 1e1*(x[-1]-1)**4
h2 = lambda x: (x[-2]-1.5)**4

#TODO: pass bounds to fmin_slsqp when all other will work ok
bounds = [(-6,6)]*10
bounds[3] = (5.5, 6)
#bounds[4] = (6, 4.5)

diffInt = 1e-8

# Unconstrained
print "Unconstrainted"
x = fmin_slsqp( ff, x0, epsilon = diffInt, bounds=bounds, iprint=1, acc=
1.0E-12)
print x
print "\n"

# Inequality constraints
print "Inequality constraints"
x = fmin_slsqp( ff, x0, epsilon = diffInt, iprint=1, acc=1.0E-12,
f_ieqcons = c, bounds=bounds      )
print x
print "\n"

h1 = lambda x: 1e1*(x[-1]-1)**4
h2 = lambda x: (x[-2]-1.5)**4

# Inequality and Equality constraints
print "Inequality and Equality constraints"
x = fmin_slsqp( ff, x0, epsilon = diffInt, iprint=1, acc=1.0E-12,
f_eqcons=lambda x: asfarray([h1(x), h2(x)]), f_ieqcons = c,
bounds=bounds )

print "Solution vector", x
print "Equality constraint values:",h1(x), h2(x)
print "Inequality constraint values:", c(x)
print "\n"

# Inequality and Equality constraints - lower requested accuracy
print "Inequality and Equality constraints - lower requested accuracy"
x = fmin_slsqp( ff, x0, epsilon = diffInt, iprint=1, acc=1.0E-5,
f_eqcons=lambda x: asfarray([h1(x), h2(x)]), f_ieqcons = c,
bounds=bounds )

print "Solution vector", x
print "Equality constraint values:",h1(x), h2(x)
print "Inequality constraint values:", c(x)

--
- Rob Falck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-dev/attachments/20071221/ffc8a809/attachment.html
```