Strongly non-negative constraint scipy minimizes

I am trying to use the minify function from scipy to fit a curve.

I have a 4-parameter equation with constraint constraints for each one and I would like to add a constraint that param1 is different from param2 (and if possible param2> param1). From what I understood, I have to use scipy.optimize.minimize with constraints and constraints. But constraints can only be equality (up to 0) or inequality (non-negative,> = 0).

So, if I set a constraint function to this (params are the store in an array):

cons = {"type": "ineq", "fun": lambda x: x[1] - x[0]}

      

in the case when x [1] and x [0] are equal, the inequality constraint does not apply. In fact, I don't quite understand why there is no "strictly positive" constraint ...

A workaround might be to add a very small remainder to this "p [1] - p [0]", but there is no cleanest solution

Greetings

+3


source to share





All Articles