Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

inequality constrains definition and violation in slsqp

17 views
Skip to first unread message

pear

unread,
Dec 11, 2009, 9:38:41 AM12/11/09
to
Subject: inequality constrains definition and violation in slsqp my
objective function is a simple least square function, i have 8
parameters, 3 inequality constraints, i used fmin_slsqp optimization
algorithm for my problem, but often my constraints are violated during
execution. My code looks like,

Init = [8.0, 14.0, 16.0, 7.0, 13.0, 50.0, 9.0, 4.0] #
[a,b,c,d,e,f,g,h]
# constraints (c > d, g > h & e>=a)

bounds = [(3.0, 4000.0), (1.0, 6000.0), (2.0, 10000.0), (1.0,
4000.0), (4.0, 6000.0), (1.0, 5000.0), (2.0, 10000.0), (1.0, 4000.0)]
# constraints
con1 = lambda x: x[2]-x[3]
con2 = lambda x: x[6]-x[7]
con3 = lambda x: x[4]-x[0]
cons = [con1, con2, con3]
###
# gradient function for my problem
def grad(s,*args):
f = func
step = 1.e-3
fini = f(*((s,)+args))
grad = numpy.zeros((len(s),), float)
st = numpy.zeros((len(s),), float)
for i in range(len(s)):
st[i] = step*s[i]
grad[i] = (f(*((s+st,)+args)) - fini)/st[i]
st[i] = 0.0
return grad

opt = fmin_slsqp(func, Init, ieqcons=cons, bounds= bounds, fprime =
grad, iter=50000,iprint=2, acc=0.01)

### end of the code #########

Here the major problem i face is the constraints (c > d, g > h & e>=a)
are violated frequently during the execution, is there any error with
my constrain definition method or any better way to avoid constrain
violations?

For my problem, constraints should not be violated during execution of
the optimization routine.

Please help me.

Hans-Bernhard Bröker

unread,
Dec 11, 2009, 2:58:41 PM12/11/09
to pear
pear wrote:
> Subject: inequality constrains definition and violation in slsqp my
> objective function is a simple least square function, i have 8
> parameters, 3 inequality constraints, i used fmin_slsqp optimization
[...]

Wherever that was supposed to go, this newsgroup is not it.

0 new messages