Disabling scaling in Gurobi

361 views
Skip to first unread message

Virajith Jalaparti

unread,
Oct 15, 2016, 6:53:46 AM10/15/16
to Gurobi Optimization

Hi,

I am trying to solve a linear program with all coefficients equal to 1, and the constants in the constraints in the range of 10^7 to 10^13. I end up getting "Warning: unscaled primal violation" message, and the resulting solution is far from optimal.

I tried fixing this by scaling the constraints myself so that the constants are in the range of 10^11 to 10^13 (I read somewhere on these forums that two orders of magnitude difference may not cause this error). The quality of the solution definitely improves but I still get the same message.

I tried setting the GRB.IntParam.ScaleFlag to 0 in the Gurobi environment hoping that this would turn off the autoscaling Gurobi performs. However, I still get the same error.

Why do I see this error even after setting GRB.IntParam.ScaleFlag  to 0? Are there other ways to fix this problem?

Thanks!

Sonja Mars

unread,
Oct 17, 2016, 1:15:40 AM10/17/16
to gur...@googlegroups.com
Hi,

Can you post a Gurobi log file? This would be helpful to get some more details about your model.

Best regards,
Sonja


----
Dr. Sonja Mars
Gurobi Optimization - Technical Support

Virajith Jalaparti

unread,
Oct 17, 2016, 1:05:54 PM10/17/16
to Gurobi Optimization
Hi, Here is the log from one of the runs with the scaled constraints.

----

Optimize a model with 42570 rows, 74869 columns and 6671459 nonzeros
Coefficient statistics:
  Matrix range    [1e-02, 5e+02]
  Objective range [1e+00, 1e+00]
  Bounds range    [0e+00, 0e+00]
  RHS range       [8e+06, 1e+09]

Concurrent LP optimizer: primal simplex, dual simplex, and barrier
Showing barrier log only...

Presolve removed 4621 rows and 3296 columns
Presolve time: 3.13s
Presolved: 37949 rows, 71573 columns, 6629715 nonzeros

Ordering time: 0.06s

Barrier statistics:
 AA' NZ     : 6.773e+06
 Factor NZ  : 8.394e+06 (roughly 110 MBytes of memory)
 Factor Ops : 1.911e+09 (less than 1 second per iteration)
 Threads    : 18

                  Objective                Residual
Iter       Primal          Dual         Primal    Dual     Compl     Time
   0   6.45336095e+07 -1.26932678e+09  1.99e+10 0.00e+00  4.98e+06     7s
   1   6.80990959e+08 -1.45066586e+09  1.16e+10 1.02e-02  3.03e+06     7s
   2   1.27510133e+10 -1.64395238e+09  1.21e+09 8.76e-02  2.44e+06     8s
   3   1.22865329e+10 -2.18520175e+09  1.61e+07 7.17e-03  2.98e+05     9s
   4   7.23355603e+09 -3.72324413e+08  1.25e+04 7.41e-03  7.07e+04     9s
   5   1.85256264e+09 -5.11058848e+07  4.76e+04 6.99e-03  1.73e+04    10s
   6   1.52830711e+09  7.46628530e+08  1.10e+05 2.76e-03  7.12e+03    11s
   7   1.51048963e+09  1.46807028e+09  1.47e+01 6.50e-05  3.85e+02    11s
   8   1.47824505e+09  1.47468342e+09  6.13e-01 3.44e-05  3.18e+01    12s
   9   1.47739782e+09  1.47722117e+09  1.94e+01 1.72e-06  1.57e+00    12s
  10   1.47736450e+09  1.47736409e+09  1.19e-02 4.11e-09  3.62e-03    13s
  11   1.47736449e+09  1.47736447e+09  3.61e-07 6.23e-10  1.43e-04    14s
  12   1.47736449e+09  1.47736449e+09  6.74e-06 5.12e-13  1.49e-07    14s
  13   1.47736449e+09  1.47736449e+09  6.20e-06 5.22e-15  1.49e-10    15s

Barrier solved model in 13 iterations and 14.94 seconds
Optimal objective 1.47736449e+09

Crossover log...

     529 DPushes remaining with DInf 0.0000000e+00                15s
       0 DPushes remaining with DInf 0.0000000e+00                15s
Warning: Markowitz tolerance tightened to 0.5

   70295 PPushes remaining with PInf 0.0000000e+00                15s
   24357 PPushes remaining with PInf 0.0000000e+00                20s

Solved with dual simplex
Solved in 17234 iterations and 22.20 seconds
Optimal objective  1.477364486e+09
Warning: unscaled primal violation = 2.38419e-06 and residual = 2.38419e-06

Sonja Mars

unread,
Oct 19, 2016, 7:38:21 AM10/19/16
to gur...@googlegroups.com
Hi,

This model has numerical issues. You can for example see this because of this warning:
> Warning: Markowitz tolerance tightened to 0.5

Your RHS values are pretty large:
> RHS range [8e+06, 1e+09]
This can lead to numerical issues. Is there a way for you to reformulate the model to avoid these large values?

The violation warnings you are seeing can be a result of numerical issue in your model. You can see them, even if you set ScaleFlag=0, because Gurobi still works on the presolved model. These violations occur when transforming the presolved model back to the original model and they are not necessarily a result of scaling. So they will not automatically disappear, when scaling is turned off.

Virajith Jalaparti

unread,
Oct 21, 2016, 12:42:11 PM10/21/16
to Gurobi Optimization
Hi, I was able to change the units of the variables and bring down the RHS range to [0,1e+04]. I am able to run the LP without any numerical issues now. Thanks a lot for the suggestions!
Reply all
Reply to author
Forward
0 new messages