Why does MIPGap not give me the actual optimality gap?
AnsweredHello,
for my optimization problem I set the time limit as follows:
model.Params.timeLimit = 2 * 60
Afterwards, I want to retrieve the optimality gap. Therefore, I am using the parameter MIPGap.
But whenever I am running the code, the resulting MIP gap has the default value 0.0001 and not the actual optimality gap that is automatically displayed in the Gurobi output.
Why are these values not the same? How can I retrieve the actual optimality gap?
Set parameter TimeLimit to value 120
Gurobi Optimizer version 10.0.1 build v10.0.1rc0 (win64)
CPU model: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz, instruction set [SSE2|AVX|AVX2]
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1640 rows, 8400 columns and 41200 nonzeros
Model fingerprint: 0x9f986b80
Variable types: 0 continuous, 8400 integer (0 binary)
Coefficient statistics:
Matrix range [1e-04, 1e+00]
Objective range [1e-02, 2e+03]
Bounds range [0e+00, 0e+00]
RHS range [1e+00, 1e+09]
Found heuristic solution: objective 1971914.6060
Presolve removed 20 rows and 0 columns
Presolve time: 0.06s
Presolved: 1620 rows, 8400 columns, 33200 nonzeros
Variable types: 0 continuous, 8400 integer (0 binary)
Found heuristic solution: objective 1971893.7260
Root relaxation: objective 3.761114e+05, 2916 iterations, 0.05 seconds (0.02 work units)
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 376111.405 0 39 1971893.73 376111.405 80.9% - 0s
H 0 0 407944.12200 376111.405 7.80% - 0s
H 0 0 407928.97400 376111.405 7.80% - 0s
H 0 0 407925.63400 376111.405 7.80% - 0s
H 0 0 406496.55600 376111.405 7.47% - 0s
0 0 380188.927 0 82 406496.556 380188.927 6.47% - 0s
H 0 0 406493.24600 380188.927 6.47% - 0s
H 0 0 406332.58600 380188.927 6.43% - 0s
H 0 0 394717.19800 380188.927 3.68% - 0s
H 0 0 388537.16400 380188.927 2.15% - 0s
H 0 0 388008.46000 380188.927 2.02% - 0s
0 0 380463.725 0 83 388008.460 380463.725 1.94% - 0s
0 0 380483.299 0 86 388008.460 380483.299 1.94% - 1s
0 0 380483.442 0 89 388008.460 380483.442 1.94% - 1s
0 0 380483.442 0 89 388008.460 380483.442 1.94% - 1s
0 2 380483.442 0 89 388008.460 380483.442 1.94% - 1s
H 31 37 387972.16600 380536.860 1.92% 6.6 1s
H 32 37 387588.82200 380536.860 1.82% 6.4 1s
H 33 37 387570.91800 380536.860 1.81% 6.5 1s
H 156 161 385955.26000 380536.860 1.40% 5.5 2s
H 1027 856 385955.04000 380706.943 1.36% 3.8 4s
1031 859 383881.443 28 81 385955.040 380706.943 1.36% 3.7 5s
H 1031 816 385884.30200 380706.943 1.34% 3.7 5s
H 1031 775 385405.95000 380706.943 1.22% 3.7 5s
H 1040 741 385384.06200 380706.943 1.21% 3.7 6s
H 1260 857 385366.35000 380706.943 1.21% 6.8 8s
H 1332 848 384861.07600 380706.943 1.08% 6.7 8s
H 1333 811 384840.12200 380706.943 1.07% 6.7 8s
2278 1264 383438.715 44 84 384840.122 381258.696 0.93% 5.5 10s
H 3368 1740 384671.03200 381494.239 0.83% 5.0 11s
H 3381 1545 384391.37000 381494.239 0.75% 4.9 11s
H 3392 1492 384303.79200 381494.239 0.73% 5.0 11s
H 4734 2317 384237.96200 381619.375 0.68% 4.6 13s
H 5980 3214 384237.95200 381738.415 0.65% 4.4 15s
H 6017 3213 384237.63200 381740.733 0.65% 4.4 15s
10058 5492 383058.047 33 93 384237.632 381991.880 0.58% 4.4 20s
H13061 6870 384237.63085 382121.235 0.55% 4.5 23s
14540 7777 383644.420 41 81 384237.631 382164.446 0.54% 4.5 25s
18887 9674 384032.665 42 81 384237.631 382297.534 0.50% 4.6 30s
21135 10343 383777.676 26 89 384237.631 382357.761 0.49% 4.6 40s
21153 10355 384112.549 33 154 384237.631 382357.761 0.49% 4.6 45s
22836 10670 383898.068 64 94 384237.631 382771.674 0.38% 4.7 50s
26730 11398 384218.958 50 110 384237.631 383063.755 0.31% 4.6 55s
31166 12005 383766.649 54 112 384237.631 383133.589 0.29% 4.4 60s
35276 11988 383856.816 53 110 384237.631 383171.700 0.28% 4.4 65s
40213 12200 383234.465 52 110 384237.631 383209.629 0.27% 4.3 70s
43327 12297 383737.622 56 108 384237.631 383226.670 0.26% 4.2 76s
46185 12390 383881.890 62 106 384237.631 383242.053 0.26% 4.2 80s
48978 12365 384176.669 73 88 384237.631 383253.873 0.26% 4.1 85s
51464 12520 383736.966 67 107 384237.631 383263.074 0.25% 4.1 90s
53469 13062 384207.375 57 103 384237.631 383269.300 0.25% 4.1 95s
56065 13797 383825.050 52 109 384237.631 383278.626 0.25% 4.0 100s
58937 14664 383741.570 57 111 384237.631 383288.881 0.25% 4.0 105s
61896 15571 383859.686 59 105 384237.631 383298.496 0.24% 4.0 111s
63441 16081 383924.227 59 107 384237.631 383304.444 0.24% 4.0 115s
66216 16873 383911.039 58 104 384237.631 383311.290 0.24% 4.0 120s
Cutting planes:
Gomory: 108
MIR: 15
Inf proof: 6
Explored 66288 nodes (266033 simplex iterations) in 120.05 seconds (43.94 work units)
Thread count was 8 (of 8 available processors)
Solution count 10: 384238 384238 384238 ... 385366
Time limit reached
Best objective 3.842376320000e+05, best bound 3.833121038592e+05, gap 0.2409%
model.Params.MIPGap: 0.0001
Thank you very much!
-
This is a good question. The MIPGap parameter defines the relative optimality gap at which Gurobi will terminate the solve. The default value of this parameter is 0.0001 (0.01%). Parameters control the solver's behavior and are not changed during the optimization process.
You are looking for the MIPGap attribute, which stores the relative optimality gap for the current solution:
model.MIPGap
0
Please sign in to leave a comment.
Comments
1 comment