Precision of variables

793 views
Skip to first unread message

Florian S.

unread,
Sep 19, 2014, 6:40:25 AM9/19/14
to gur...@googlegroups.com
I have some issued regarding precision of variable values and I wonder if that's normal or it happens due to any inprober model formulation.

What i observed (only 2 times till now for something like 1000 instances) that a continuous variable takes a small value (0.002) even though it is forced to be zero through another binary variable.
The constraint that ensures this behavior are as follows:
            model.addConstr(jumpAmount <= jump * 100000)
where jumpAmount is the continuous variable and jump is the binary variable.

Here are the exact Gurobi outputs for the 2 instances where I found the precision problem:
<gurobi.Var jump[22] (value 0.0)>
<gurobi.Var jumpAmount[22] (value 0.00544075059845)>

<gurobi.Var jump[10] (value 0.0)>
<gurobi.Var jumpAmount[10] (value 0.00203405207466)>

There are of course many inprecisions, but in a much less dimension like e.g.:
<gurobi.Var jump[9] (value 0.0)>
<gurobi.Var jumpAmount[9] (value -9.94759830064e-14)>

This is, of course, acceptable.

So my question is: Is that level of precision normal?

Thanks for your help.

Sonja Mars

unread,
Sep 19, 2014, 7:17:07 AM9/19/14
to gur...@googlegroups.com
Hi Florian,

Can you post the log of the run where these violations appear? Maybe Gurobi tells you something like

“max constraint violation (5.4408e-03) exceeds tolerance”

This normally indicates numerical issues in your model. For example, if you have a large range of matrix coefficients like [1e-5, 1e5] the solver will have a hard time solving your model.

If you can additionally to the log file post a MPS file with the model for which these violations appear, we can take a look.

Best regards,
Sonja

-----------------------------------------------------------------
Dr. Sonja Mars
Gurobi Optimization




Florian S.

unread,
Sep 19, 2014, 7:51:50 AM9/19/14
to gur...@googlegroups.com
Thanks for that hint. Haven't noticed it and that would explain a lot...
Here are the logs:
Optimize a model with 191533 rows, 175372 columns and 1391598 nonzeros
Model has 192 quadratic objective terms
Model has 2160 quadratic constraints
Presolve removed 188203 rows and 169797 columns
Presolve time: 2.20s
Presolved: 7858 rows, 7896 columns, 47682 nonzeros
Presolved model has 152 quadratic objective terms
Variable types: 3321 continuous, 4575 integer (4575 binary)
Found heuristic solution: objective -5760.000000

Root relaxation: objective 7.236824e+03, 6676 iterations, 0.23 seconds

   
Nodes    |    Current Node    |     Objective Bounds      |     Work
 
Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

     
0     0 7236.82352    0  564 -5760.0000 7236.82352   226%     -    2s

 
...
* 4571   202              52    5110.7464234 5876.69236  15.0%  2319 1265s
 
6518    20 5464.03243   28  304 5110.74642 5791.17112  13.3%  1665 1277s
 
7339     0 5217.93721   37  352 5110.74642 5265.05656  3.02%  1494 1280s

Cutting planes:
 
Learned: 3
 
Gomory: 5
 
Cover: 32
 
Implied bound: 157
 
Clique: 34
  MIR
: 20
 
Flow cover: 114
  GUB cover
: 1
 
Zero half: 12

Explored 7909 nodes (11270873 simplex iterations) in 1284.14 seconds
Thread count was 12 (of 12 available processors)

Optimal solution found (tolerance 1.00e-02)
Warning: max constraint violation (2.0341e-03) exceeds tolerance
Warning: max bound violation (2.0341e-03) exceeds tolerance
         
(model may be infeasible or unbounded - try turning presolve off)
Best objective 5.110746423396e+03, best bound 5.110746423396e+03, gap 0.0%

and in the other case its:

Optimize a model with 670324 rows, 613447 columns and 4880609 nonzeros
Model has 672 quadratic objective terms
Model has 7368 quadratic constraints
Presolve removed 659260 rows and 594631 columns (presolve time = 5s) ...
Presolve removed 659260 rows and 594631 columns
Presolve time: 8.55s
Presolved: 26237 rows, 26574 columns, 159491 nonzeros
Presolved model has 491 quadratic objective terms
Variable types: 11263 continuous, 15311 integer (15311 binary)
Found heuristic solution: objective -20160.00000

Root relaxation: objective 2.445149e+04, 18448 iterations, 1.19 seconds

   
Nodes    |    Current Node    |     Objective Bounds      |     Work
 
Expl Unexpl |  Obj  Depth IntInf | Incumbent    BestBd   Gap | It/Node Time

     
0     0 24451.4904    0 1362 -20160.000 24451.4904   221%     -    9s

...
 
38673   360 12543.5161   44 2493 12262.3158 12543.5161  2.29%   865 20981s
 
39283   124 12450.3851   40  422 12262.3158 12479.2640  1.77%   853 20987s

Cutting planes:
 
Learned: 19
 
Gomory: 4
 
Cover: 140
 
Implied bound: 655
 
Clique: 129
  MIR
: 70
 
Flow cover: 690
  GUB cover
: 1
 
Zero half: 23

Explored 39935 nodes (34383832 simplex iterations) in 20991.75 seconds
Thread count was 12 (of 12 available processors)

Optimal solution found (tolerance 1.00e-02)
Warning: max constraint violation (5.4408e-03) exceeds tolerance
Warning: max bound violation (5.4408e-03) exceeds tolerance
         
(possibly due to large matrix coefficient range)
Best objective 1.226231580280e+04, best bound 1.226242337439e+04, gap 0.0009%Enter code here...

The inprecision is not problem at this point, I just want to ensure that there is no logical issue in my model formulation.

Sonja Mars

unread,
Sep 19, 2014, 8:02:51 AM9/19/14
to gur...@googlegroups.com
Hi,

> Warning: max constraint violation (2.0341e-03) exceeds tolerance
> Warning: max bound violation (2.0341e-03) exceeds tolerance
> (model may be infeasible or unbounded - try turning presolve off)
>
> Warning: max constraint violation (5.4408e-03) exceeds tolerance
> Warning: max bound violation (5.4408e-03) exceeds tolerance
> (possibly due to large matrix coefficient range)
>
This definitely looks like you have numerical issues in your model.

> The inprecision is not problem at this point, I just want to ensure that there is no logical issue in my model formulation.
I don’t think there is a logical issue in your model. However, you might want to reformulate or rescale your model. You should take a look at your model statistics. For example, you can use model.printStats() from the Python API (http://www.gurobi.com/documentation/5.6/reference-manual/py_model_printstats) to get detailed information about all your coefficients. If the matrix coefficient range is larger than 6 orders of magnitude or the largest value in the bounds, rhs coefficients and objective sections is huge (like 1e9), you should rescale your model.

Additionally, you can try to increase the NumericFocus parameter and/or try to turn Presolve and/or Aggregate off.

Best regards,
Sonja
Reply all
Reply to author
Forward
0 new messages