Understanding Gurobi Running time and why it is different than the log file time
AnsweredI am currently solving a robust optimisation problem using Gurobi. I need to get the computational time, but I am confused regarding this feature.
1) I get 20.9394s TIME output from Gurobi (see Running Time below)
SOLVING Being solved by Gurobi... Solution status: 2 Running time: 20.9394s Optimization duration: 50.45294785499573 seconds Conic program object: ============================================= Number of variables: 1922 Continuous/binaries/integers: 1442/480/0 --------------------------------------------- Number of linear constraints: 22326 Inequalities/equalities: 20166/2160 Number of coefficients: 144202 --------------------------------------------- Number of SOC constraints: 0 --------------------------------------------- Number of ExpCone constraints: 0
2) I tried to calculate the time manually using the python function Time() as below and I get a different time (Optimization duration: 50.45294785499573 seconds)
start_time = time.time()
model.solve(solver=grb, display=True)
# End the timer
end_time = time.time()
# Calculate the duration
duration = end_time - start_time
# Print the duration
print("Optimization duration:", duration, "seconds")
3) I also checked the log file and it gives a different time for those two above.
Which one is the right one ? and why am I getting different values ?
Optimize a model with 22326 rows, 1922 columns and 144202 nonzeros
Model fingerprint: 0x7dd3a1bf
Variable types: 1442 continuous, 480 integer (480 binary)
Coefficient statistics:
Matrix range [4e-02, 1e+04]
Objective range [1e+00, 1e+00]
Bounds range [1e+00, 1e+00]
RHS range [2e-01, 7e+02]
Presolve removed 20838 rows and 746 columns
Presolve time: 0.18s
Presolved: 1488 rows, 1176 columns, 19527 nonzeros
Variable types: 936 continuous, 240 integer (240 binary)
Found heuristic solution: objective 1443.0992994
Root relaxation: objective -1.078467e+04, 999 iterations, 0.11 seconds (0.04 work units)
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 -10784.673 0 9 1443.09930 -10784.673 847% - 0s
H 0 0 1330.8833689 -10784.673 910% - 0s
0 0 -4885.6045 0 126 1330.88337 -4885.6045 467% - 0s
0 0 -4884.1210 0 124 1330.88337 -4884.1210 467% - 0s
0 0 -1253.0951 0 54 1330.88337 -1253.0951 194% - 1s
0 0 -83.97289 0 57 1330.88337 -83.97289 106% - 2s
0 0 -83.58408 0 51 1330.88337 -83.58408 106% - 2s
0 0 218.59669 0 59 1330.88337 218.59669 83.6% - 2s
0 0 662.60634 0 66 1330.88337 662.60634 50.2% - 3s
0 0 737.45950 0 81 1330.88337 737.45950 44.6% - 4s
0 0 754.02777 0 84 1330.88337 754.02777 43.3% - 4s
0 0 754.63582 0 82 1330.88337 754.63582 43.3% - 4s
0 0 860.28340 0 59 1330.88337 860.28340 35.4% - 5s
0 0 865.30128 0 52 1330.88337 865.30128 35.0% - 6s
0 0 867.86441 0 57 1330.88337 867.86441 34.8% - 6s
H 0 0 1309.3317032 875.66263 33.1% - 6s
0 0 875.66263 0 72 1309.33170 875.66263 33.1% - 6s
0 0 880.98295 0 81 1309.33170 880.98295 32.7% - 7s
0 0 883.70284 0 80 1309.33170 883.70284 32.5% - 7s
0 0 905.36499 0 84 1309.33170 905.36499 30.9% - 8s
0 0 905.36499 0 62 1309.33170 905.36499 30.9% - 8s
0 2 905.36499 0 62 1309.33170 905.36499 30.9% - 11s
7 8 1118.46740 3 31 1309.33170 1102.75825 15.8% 630 16s
H 63 24 1305.4775990 1305.47760 0.00% 237 20s
Cutting planes:
Gomory: 8
MIR: 246
Flow cover: 24
Relax-and-lift: 18
Explored 79 nodes (24477 simplex iterations) in 20.84 seconds (3.02 work units)
Thread count was 24 (of 24 available processors)
Solution count 4: 1305.48 1309.33 1330.88 1443.1
Optimal solution found (tolerance 1.00e-04)
Best objective 1.305477598982e+03, best bound 1.305477598982e+03, gap 0.0000%
-
It looks like you may be using a third-party modeling framework here. I would guess then that
model.solve(solver=grb, display=True)
has some other processing happening to convert the model you created into one that can be sent to Gurobi. The 20.84 is the time Gurobi spends in the optimization process.
0 -
I see, that\s correct, I am using the library RSOME to construct my model and then solve it using Gurobi. However, shouldn't\t Gurobi solving time and the log file be similar ?
0 -
Hi Amal,
Since the RSOME API allows you to specify the solver at the point of calling ”solve” it means that nothing has been built in Gurobi up until that point. The 29s time difference is the time RSOME is taking to build the model in Gurobi. In this respect there is double handling, the model is built twice, once in RSOME, and again in Gurobi.
- Riley
0
Please sign in to leave a comment.
Comments
3 comments