I am trying to use cvxpy but i don't know how to use or operator.
I have
x = cp.Variable(N, integer=True)
I try
x[i]==0 or x>=m[i]
.
I got this error
> Cannot evaluate the truth value of a constraint or chain constraints, e.g., 1 >= x >= 0.
Then i try:
for i in range(N):
constraints += [
x[i]*(x[i]-m[i])>=0,
]
And i got
> Problem does not follow DCP rules.
Can someone help me? Thank you
The constraint
x=0 or x≥L
is known as x
being a semicontinuous variable. Some solvers and tools have specialized facilities for this. Otherwise, add a binary variable y
and use:
y*L ≤ x ≤ y*U
x ∈ [0,U] (U is an upperbound on x)
y ∈ {0,1}