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:

<span>$</span>\begin{array}{rcl}
10^{-7}x + 10y &\leq& 10\
x+10^4z&\leq&10^3\
x,y,z&\geq&0,
\end{array}<span>$</span>
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:
<span>$</span>\begin{array}{rcl}
10^{-2}x' + 10y &\leq& 10\
10^2x'+10z&\leq&1\
x',y,z&\geq&0,
\end{array}<span>$</span>
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>.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search