# Constraint: x is zero *or* x falls within a range

I want variable x to be in range “x = 0 or Pmin <= x <= Pmax”. (Pmin and Pmax is constant) But in CVX, I cannot use or operation. Additionally I tried to use binary variable to satisfy that range, but multiplication of two different variables are not permitted.

Is there any solution to determine range of variable x like that?

Presuming you have a mixed integer solver available (Gurobi or Mosek) in cvx, declare y to be a binary variable, and then use the constraint y * Pmin <= x <= y * Pmax . There is no multiplication of variables in this formulation, since Pmin and Pmax are not cvx variables.

Alternatively, if you don’t have a mixed integer solver available, and you have just a single scalar variable subject to this type of constraint, you could explicitly solve two separate optimization problems, one with x set to 0, and the other with constraint Pmin <= x <= Pmax.

Yes, this is exactly right. This is not convex, but a mixed-integer solver can handle it. This kind of constraint is very useful in portfolio design where there is a minimum buy-in for a particular investment.