1

I would like to optimize function with SLSQP solver. The function contains 5 parameters, and I would like to add a constraint that x[0] > x[3]. The following code makes x[0]=x[3]. Can you help me to modify it to "x[0] > x[3]"

cons = {'type':'eq', 'fun': lambda x: x[0] - x[3]} 

res = minimize(model_calib, xo, bounds=[(100,8000),(0,650),(0,1),(5,550),(0,3)], method='SLSQP',constraints = cons)

Best regards,

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
Mohamed
  • 11
  • 2
  • 1
    You should use `'type': 'ineq'` for inequality type of constraints – Cory Kramer Jan 19 '21 at 19:00
  • 1
    Essentially a duplicate of: https://stackoverflow.com/questions/42303470/scipy-optimize-inequality-constraint-which-side-of-the-inequality-is-considere – Igor Rivin Jan 19 '21 at 19:01

1 Answers1

0

As you mentioned in comment by @Cory Kramer

cons = {'type':'ineq', 'fun': lambda x: x[0] - x[3]} 
balezz
  • 788
  • 5
  • 15