Cino
Cino

Reputation: 93

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.

Upvotes: 0

Views: 251

Answers (1)

Erwin Kalvelagen
Erwin Kalvelagen

Reputation: 16797

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

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

Upvotes: 1

Related Questions