pythonconstraintslinear-programmingcvxpyconvex-optimization

Constraints with condition in CVXPY


I want to add constraints like this:

constraint = cp.sum(cp.multiply(x, a)) > 10 if x*a != 0

where x is decision variable and a is constant. I know if condition and chain constraints are not allowed. But how can I implement this condition?

I also report a issue for csxpy in github.


Solution

  • That can be implemented linearly by considering y=a*x to be semi-continuous.

     y = a*x
     10*δ ≤ y ≤ 9999*δ
     δ ∈ {0,1}