# [SciPy-User] fmin_slsqp constraint problem

Neal Becker ndbecker2@gmail....
Fri Oct 26 09:53:06 CDT 2012

```I have a ineq constraint:

## constrain poles to be inside unit circle
def c(coef, len_z, len_p, dz, dp):
p = compose ((coef/opt.scale)[len_z:-1], dp)
return np.abs(p) - 1

So this will return a 1D array where each value should satisfy the constraint.
fmin_slsqp will not accept this directly:

e = fmin_slsqp (obj_fnc, coef*opt.scale, ieqcons=[lambda coef, len_z, len_p,
dz, dp: -c(coef, len_z, len_p, dz, dp)], args=(len(lz), len(lp), dz, dp),
eqcons=[lambda coef, len_z, len_p, dz, dp: h(coef, len_z, len_p, dz, dp)],
full_output=True)

Traceback (most recent call last):
File "./optimize_pll5.3.2.py", line 519, in <module>
run_line (sys.argv)
File "./optimize_pll5.3.2.py", line 498, in run_line
e = fmin_slsqp (obj_fnc, coef*opt.scale, ieqcons=[lambda coef, len_z, len_p,
dz, dp: -c(coef, len_z, len_p, dz, dp)], args=(len(lz), len(lp), dz, dp),
eqcons=[lambda coef, len_z, len_p, dz, dp: h(coef, len_z, len_p, dz, dp)],
full_output=True)
File "/usr/lib64/python2.7/site-packages/scipy/optimize/slsqp.py", line 334,
in fmin_slsqp
a_ieq[i] = ieqcons_prime[i](x)
File "/usr/lib64/python2.7/site-packages/scipy/optimize/optimize.py", line
176, in function_wrapper
return function(x, *args)
File "/usr/lib64/python2.7/site-packages/scipy/optimize/optimize.py", line
398, in approx_fprime