def get_cons(self, ub, lb):
cons = []
for i in range(len(ub)):
cons.append({'type':'ineq','fun':lambda x0:ub[i]-x0[i]})
cons.append({'type':'ineq','fun':lambda x0:x0[i]-lb[i]})
return cons
ub = [1,3,1,1]
lb = [0,0,0,0]
cons = self.get_cons(self.ub, self.lb)
res = minimize(fun, x0[:,i], method='SLSQP', constraints=cons)
Here fun is custom loss function initial parameter is [0.08024884 0.14003958 0.0786131 0.00157402]. I expect all parameter>0,but after optimize parmeter is [-0.45684621 0.02531972 -0.10755587 0.2108312].
Whether this constraint fails?