Documentation

Advanced user scaling

In the previous sections, we presented some simple strategies to limit the ranges of variable bounds, constraint right-hand sides, objective values, and constraint matrix coefficients. However, it could happen that by scaling constraints or variables, some constraint coefficients become too small. Note that Gurobi will treat any constraint coefficient with absolute value under <span>$</span>10^{-13}<span>$</span> as zero. Consider the following example:

\begin{displaymath}\begin{array}{rcl}
10^{-7}x + 10y &\leq& 10\\
x+10^4z&\leq&10^3\\
x,y,z&\geq&0,
\end{array}\end{displaymath}

In this example, the matrix coefficients range in <span>$</span>[10^{-7},10^4]<span>$</span>. If we multiply all <span>$</span>x<span>$</span> coefficients by <span>$</span>10^5<span>$</span>, and divide all coefficients in the second constraint by <span>$</span>10^3<span>$</span>, we obtain:

\begin{displaymath}\begin{array}{rcl}
10^{-2}x' + 10y &\leq& 10\\
10^2x'+10z&\leq&1\\
x',y,z&\geq&0,
\end{array}\end{displaymath}

where <span>$</span>x=10^5x'<span>$</span>. The resulting matrix coefficients have a range in <span>$</span>[10^{-2},10^2]<span>$</span>. Essentially the trick is to simultaneously scale a column and a row to achieve a smaller range in the coefficient matrix.

We recommend that you scale the matrix coefficients so that their range is contained in six orders of magnitude or less, and hopefully within <span>$</span>[10^{-3},10^{6}]<span>$</span>.