# Mixed Integer Programming with product of a binary variable and multiple continuous variables

Suppose we have a binary variable $$x$$ and two non-negative continuous variables $$y_1\ge 0$$ and $$y_2 \ge 0$$. How can we linearize $$xy_1 y_2$$ ?

FYI, this is a follow up question to this: How to linearize the product of a binary and a non-negative continuous variable?

• You cannot. Just consider the case when you don't have $x$, there is no magic way to linear a bilinear product of two continuous variables. Commented Aug 11, 2022 at 10:48

## 2 Answers

As Johan Löfberg said, it cannot be done directly. You can get an approximate solution in two steps.

1. First, approximate the product of $$y_1$$ and $$y_2$$ using a new variable $$z.$$ See, for instance, this question, and specifically the answers involving McCormick envelopes.
2. Now linearize the product of $$x$$ and $$z$$ using the link in your question.

I would start with a non-convex solver like Gurobi. Gurobi can only do quadratic terms, but that is not a real limitation:

 z1 = x*y1
z2 = z1*y2