# Modeling the product of two variables

Suppose we have two continuous nonnegative variables $$X_{1}$$ and $$X_{2}$$ both bounded by the number $$M$$ from above.

I would like to model the following:

If $$X_{1} > 0$$ then $$X_{2} = 0$$

If $$X_{2} > 0$$ then $$X_{1} = 0$$

I can do this by imposing $$X_{1} X_{2} = 0$$ but this is a nonconvex nonlinear term.

I can instead model as follows:

$$X_{1} \le M \\ X_{2} \le M \\ X_{1} \le B_{1} M \\ X_{2} \le B_{2} M \\ B_{1} + B_{2} \le 1$$

where $$B_{1}$$ and $$B_{2}$$ are binary variables. The result is a MILP.

Can you see an alternative way for modeling this relation?

• You can omit the first two constraints, which are implied by the next two. Nov 25 '20 at 18:43
• Yes, aber I don't win that much do I? Nov 25 '20 at 18:45
• No, just a little simpler, like omitting $B_1 \le 1$ and $B_2 \le 1$. Nov 25 '20 at 20:08

You can declare $$\lbrace X_1, X_2 \rbrace$$ to be a type 1 special ordered set (SOS1). Assuming that your solver understands SOS1 constraints, it will enforce what you want internally, possibly by a "big M" approach and possibly through branching. This again results in a MILP.
• There may also be workarounds involving callbacks. For instance, one of the answers to the question you linked says that CPLEX automatically converts SOS1 constraints to binaries (which may be correct). You can, however, add a branch callback. In the branch callback, you might test whether both $X$ variables are positive. If so, you can branch with one of them set to zero in each child. If not, you can just let CPLEX branch as it normally would. So in addition to support for SOS1 branching, you might look for support for user-controlled branching. Nov 28 '20 at 18:23