Time_limit parameter as Cut
OngoingHi Folks,
I have two questions about Gurobi parameters.. I am using Gurobi C++ to solve a MIP_problem that I need to add CNTR from a previous optimization, each optimization has its own difficulties, but the first one is simple to get initial variable values, then put them into C++ variables do some calculations, and redecide Gurobi variables, for this reason, I set time_limit for the first optimization. I just need this time limit at the first, the subsequent optimizations should not have time_limit. But once it is set, it remains, even if I change the Objective function or call another optimization process.
Is there a possibility the next opt process "turn off" the setting of time_limit?
Another question is about MIP_GAP, when I do not set this parameter, it is taking about 21417s to achieve the default GAP 0.01, once I set 0.01 as Gurobi Parameter MIP_GAP that takes 44s! How works this MIP_Gap set by the user or by Gurobi, because I read already
https://www.gurobi.com/documentation/9.1/refman/mipgap2.html#parameter:MIPGap and https://www.gurobi.com/documentation/9.1/examples/params_cpp_cpp.html
Why that difference happens ?! I am seeing that as a Cut to my optimization process to search for a solution, is that correct?
Thanks in advance!
Best Regards,
Alessandra Vieira.

Hi Alessandra,
Is there a possibility the next opt process "turn off" the setting of time_limit?
You can do
// Set a 2 second time limit
m>set(GRB_DoubleParam_TimeLimit, 2);
m>optimize();
// Do your calculations and update the model
// Reset time limit to the default value and reoptimize
m>set(GRB_DoubleParam_TimeLimit, GRB_INFINITY);
m>optimize();If you have a new \(\texttt{GRBModel}\) then this shouldn't be necessary. However, if you are reusing the model, the parameters you've set will persists unless you change them back.
Another question is about MIP_GAP, when I do not set this parameter, it is taking about 21417s to achieve the default GAP 0.01, once I set 0.01 as Gurobi Parameter MIP_GAP that takes 44s!
I am not sure what you mean here without looking at the logs. One interpretation: it may be possible that the 0.01 MIP Gap is reached after 44s but closing that final gap to optimality (to the default MIP gap of 1e4) takes a very long time.
Cheers,
David0 
Hi David,
Thanks for your answer , time_limit was reset with :
GRB_DoubleParam_TimeLimit, GRB_INFINITY
About the MIP_GAP, please see below part of .log file for the same problem, the first one without the MIP_GAP parameter set as 0.001 . and the second with:
"Usercallback calls 7883, time in usercallback 0.02 sec
Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (win64)
Thread count: 2 physical cores, 4 logical processors, using up to 2 threads
Optimize a model with 1640 rows, 3360 columns and 4660 nonzeros
Model fingerprint: 0xa6c2c3f8
Model has 664 quadratic objective terms
Model has 5284 quadratic constraints
Variable types: 240 continuous, 3120 integer (1680 binary)
Coefficient statistics:
Matrix range [1e+00, 8e+00]
QMatrix range [9e01, 1e+00]
QLMatrix range [2e02, 5e+02]
Objective range [7e+02, 2e+03]
QObjective range [6e04, 4e+03]
Bounds range [1e+00, 5e+02]
RHS range [1e+00, 1e+00]
QRHS range [1e+00, 1e+03]Warning: Completing partial solution with 2880 unfixed noncontinuous variables out of 3120
User MIP start did not produce a new incumbent solution
MIP start from previous solve did not produce a new incumbent solution
MIP start from previous solve violates constraint R950 by 1.000000000Presolve added 1860 rows and 690 columns
Presolve time: 0.37s
Presolved: 10313 rows, 6155 columns, 57151 nonzeros
Presolved model has 240 quadratic constraint(s)
Variable types: 1411 continuous, 4744 integer (1864 binary)Root relaxation: objective 9.191439e+04, 4575 iterations, 0.35 seconds
I stopped the optimization process at :
4894967 4318238 98759.3500 1387 59 98763.4267 98746.5432 0.02% 3.2 28443s
Gurobi Optimizer version 9.1.1 build v9.1.1rc0 (win64)
Thread count: 2 physical cores, 4 logical processors, using up to 4 threads
Optimize a model with 950 rows, 3360 columns and 1900 nonzeros
Model fingerprint: 0x36f67b05
Model has 664 quadratic objective terms
Model has 5284 quadratic constraints
Variable types: 240 continuous, 3120 integer (1680 binary)
Coefficient statistics:
Matrix range [1e+00, 8e+00]
QMatrix range [9e01, 1e+00]
QLMatrix range [2e02, 5e+02]
Objective range [7e+02, 2e+03]
QObjective range [6e04, 4e+03]
Bounds range [1e+00, 5e+02]
RHS range [1e+00, 1e+00]
QRHS range [1e+00, 1e+03]
Presolve added 2580 rows and 690 columns
Presolve time: 0.50s
Presolved: 10343 rows, 6155 columns, 55831 nonzeros
Presolved model has 240 quadratic constraint(s)
Variable types: 1411 continuous, 4744 integer (1864 binary)Root relaxation: objective 9.191439e+04, 4637 iterations, 0.53 seconds
Last optimization line :
H14675 8327 98870.530457 98728.0962 0.14% 6.9 44s
Cutting planes:
MIR: 8
StrongCG: 3
Flow cover: 1
RLT: 23Explored 14735 nodes (117664 simplex iterations) in 44.71 seconds
Thread count was 4 (of 4 available processors)Solution count 10: 98870.5 102238 102238 ... 103071
In my question I meant to understand better about MIP_GAP, e.g,time_limit is inherited from the previous optimization, but MIP_GAP is not.
0 
Hi Alessandra,
Sorry for the delay, both of these settings are carried along.
Setting the MIP gap to 0.001 means that the optimization will stop when 0.1% optimality is reached.
In the logs you are showing, the optimality gap has not reached that point.
Please try reducing the MIP gap.
Cheers,
David0 
Hi David,
Really thanks for your answer!
"In the logs, you are showing, the optimality gap has not reached that point", so why the optimization has stopped if no time limit was set?
BR,
Alessandra.
0
Please sign in to leave a comment.
Comments
4 comments