I met a problem when I try to use cvxpy to solve the LQ problem. Let me give a simple example. My objective function is x^2
and the constraints is x<1 or x>5
So I use the penalty function method to add the two constraints.
the new objective function : x**2 + np.sign(np.min([np.max([0,x-1]),np.max([]5-x,0)]))
That means if x<1 or x>5, the later term np.sign(np.min([np.max([0,x-1]),np.max([]5-x,0)])) is equall to 0.
However, when I run it, I get a error:
Exception: Cannot evaluate the truth value of a constraint or chain constraints, e.g., 1 >= x >= 0.
Could any friend help me solve this problem? thanks very much previously.