Documentation

Avoid hiding large coefficients

As we said before, a typical recommendation for improving numerics is to limit the range of constraint matrix coefficients. The rationale behind this guideline is that terms to be added in a linear expression should be of comparable magnitudes so that rounding errors are minimized. For example:

\begin{eqnarray*}
x - 10^{6} y &\geq& 0 \\
y&\in&[0,10]
\end{eqnarray*}


is usually considered a potential source of numerical instabilities due to the wide range of the coefficients in the constraint. However, it is easy to implement a simple (but useless) alternative:

\begin{eqnarray*}
x - 10 y_1 &\geq& 0\\
y_1 - 10 y_2 &=& 0\\
y_2 - 10 y_3 &=& ...
... &=& 0\\
y_4 - 10 y_5 &=& 0\\
y_5 - 10 y &=& 0\\
y&\in&[0,10]
\end{eqnarray*}


This form certainly has nicer values in the matrix. However, the solution $y=-10^{-6}, x=-1$ might still be considered feasible as the bounds on variables and constraints might be violated within the tolerances. A better alternative is to reformulate

\begin{eqnarray*}
x - 10^{6} y &\geq& 0 \\
y&\in&[0,10]
\end{eqnarray*}


as

\begin{eqnarray*}
x - 10^{3} y' &\geq& 0 \\
y'&\in&[0,10^4]\\
\end{eqnarray*}


where $10^{-3} y' = y$. In this setting, the most negative values for $x$ which might be considered feasible would be $-10^{-3}$, and for the original $y$ variable it would be $-10^{-9}$, which is a clear improvement over the original situation.