What is the most efficient implementation to approximately linearize a quadratic variable in CPLEX?

33 Views Asked by At

In the linear optimization problem that I am facing, I would like to approximately linearize a large amount of quadratic variables. The optimization problem can be heavily simplified to the following problem:

$$ \text{min } x^2 $$

where $ x \in \mathbb{R}_+ $ is a variable that is bounded by any generic linear constraint.

I have found two ways of linearizing the quadratic variable. The first formulation is as follows:

$$ \text{min } y_1 + 3y_2 + 5y_3 + 7y_4 + \cdots + (2n-1)y_n $$

where $x \leq \sum_{i=1}^n y_i $, $y_i \in [0,1]$ for $i=1,\ldots, n-1$ and $y_n \in \mathbb{R}$. Also, $n$ is a parameter that can be set depending on the required accuracy of the optimizer.

The second formulation is as follows:

\begin{align} \text{min } & xsquared \\ \\ \text{s.t. } & xsquared \geq x \\ & xsquared \geq 3x - 2 \\ & xsquared \geq 5x - 6 \\ \vdots \\ & xsquared \geq (2n-1)x - n (n-1)\\ \end{align}

where $xsquared \in \mathbb{R}$.

My gut feeling is that the second formulation is the most efficient implementation of this constraint, because it uses fewer variables. However, due to optimizer magic (I am using CPLEX), the first formulation could maybe be better, because it has fewer complex constraints.

I would like to implement this constraint in a generic way so that I can also reuse my code for future projects. Can anyone explain which formulation is better in general? Or is there an even better formulation for this problem?