Issue with callback best objective and heuristic solution (versions 9.1.2 and 9.0.0)
Awaiting user inputHello,
I am applying Benders decomposition via callback to my problem. I noticed that I can generate heuristic solution from integer solution which is possibly better than the best objective found by Gurobi. However, when I query MIPSOL_OBJBST via callback, the value is higher than the value shown from the MILP Gurobi log. Here is my code that obtain best objective bound and heuristic solution (I insset the heuristic solution at the MIPNODE due to the limitation of my Gurobi version):
if (where == GRB.Callback.MIPSOL) :
z_sol = model.cbGetSolution(model._z)
a_sol = model.cbGetSolution(model._a)
r_sol = model.cbGetSolution(model._r)
e_sol = model.cbGetSolution(model._e)
eta_sol = model.cbGetSolution(model._eta)
best_obj = model.cbGet(GRB.Callback.MIPSOL_OBJBST)
true_z_value,r_sol, a_sol,e_sol = BendersMPnew.a_r_true_value_mip_z(z_sol, r_sol, a_sol,e_sol)
BendersMPnew.set_SP_rhs_and_solve(z_sol,r_sol,a_sol) # obtain true value of the subproblem
sp_obj = BendersMPnew.SP_optimal_obj
true_obj = true_z_value - sp_obj # obtain true value of objective function for current solution
eta_sol =sp_obj
if((true_obj>best_obj) and ( true_obj > model._betterobj ) ):
print("best obj",best_obj)
print("new true value", true_obj)
model._betterobj = true_obj
model._betterobj_eta = eta_sol
model._betterobj_r = r_sol
model._betterobj_a = a_sol
model._betterobj_z = z_sol
model._betterobj_e = e_sol
model._betterobj_flag = 1
if(model._betterobj_flag ==1 and where == GRB.Callback.MIPNODE ):
model.cbSetSolution(model._r, model._betterobj_r)
model.cbSetSolution(model._a, model._betterobj_a)
model.cbSetSolution(model._eta, model._betterobj_eta)
model.cbSetSolution(model._e, model._betterobj_e)
model.cbSetSolution(model._z, model._betterobj_z)
model.cbUseSolution()
But in the MILP log, you can see the best objective bound is higher than the one shown in the log (Incumbent) and the heuristic solution is also not incorporated:
Changed value of parameter LazyConstraints to 1
Prev: 0 Min: 0 Max: 1 Default: 0
Changed value of parameter Cuts to 0
Prev: -1 Min: -1 Max: 3 Default: -1
Changed value of parameter PreCrush to 1
Prev: 0 Min: 0 Max: 1 Default: 0
Changed value of parameter Threads to 1
Prev: 0 Min: 0 Max: 1024 Default: 0
Changed value of parameter TimeLimit to 14400.0
Prev: inf Min: 0.0 Max: inf Default: inf
Changed value of parameter Threads to 1
Prev: 0 Min: 0 Max: 1024 Default: 0
Parameter LazyConstraints unchanged
Value: 1 Min: 0 Max: 1 Default: 0
Parameter PreCrush unchanged
Value: 1 Min: 0 Max: 1 Default: 0
Parameter OutputFlag unchanged
Value: 1 Min: 0 Max: 1 Default: 1
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (mac64)
Thread count: 4 physical cores, 8 logical processors, using up to 1 threads
Optimize a model with 7832 rows, 7831 columns and 36261 nonzeros
Model fingerprint: 0x986f14aa
Variable types: 175 continuous, 7656 integer (7656 binary)
Coefficient statistics:
Matrix range [1e-02, 2e+01]
Objective range [1e+00, 9e+01]
Bounds range [4e-01, 2e+00]
RHS range [1e+00, 1e+04]
Presolve removed 1 rows and 0 columns
Presolve time: 0.04s
Presolved: 7831 rows, 7831 columns, 36174 nonzeros
Variable types: 1 continuous, 7830 integer (7656 binary)
Found heuristic solution: objective -11904.80000
Found heuristic solution: objective -5000.900000Root relaxation: objective 1.323948e+03, 2014 iterations, 0.02 seconds
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time0 0 1323.36701 0 93 -5000.9000 1323.36701 126% - 2s
best obj 959.1003024652846
new true value 959.1003024652857
H 0 0 959.1003025 1323.36701 38.0% - 3s
0 0 1323.01674 0 349 959.10030 1323.01674 37.9% - 3s
0 2 1320.75216 0 261 959.10030 1320.75216 37.7% - 8s
5 7 1317.88206 4 242 959.10030 1319.82349 37.6% 70.2 10s
27 29 1256.36028 20 33 959.10030 1319.82349 37.6% 42.4 15s
105 107 1163.57470 82 41 959.10030 1319.82349 37.6% 22.7 20s
269 271 1153.82935 232 75 959.10030 1319.82349 37.6% 13.0 25s
best obj 1028.9437666391068
new true value 1046.9773049115258
388 390 1099.08559 343 14 959.10030 1319.82349 37.6% 10.5 30s
* 416 401 368 962.1459479 1319.82349 37.2% 10.3 31s
425 410 1297.60517 9 78 962.14595 1319.05778 37.1% 11.9 35s
437 422 1274.53888 18 87 962.14595 1319.05778 37.1% 13.0 40s
451 436 1223.80204 28 100 962.14595 1319.05778 37.1% 13.7 46s
459 444 1210.32124 33 29 962.14595 1319.05778 37.1% 13.9 50s
485 470 1232.14514 56 150 962.14595 1319.05778 37.1% 13.5 55s
513 496 1191.31886 92 351 962.14595 1319.05778 37.1% 13.2 60s
514 497 1133.02900 217 261 962.14595 1319.05778 37.1% 13.2 66s
516 498 1188.53743 106 371 962.14595 1319.05778 37.1% 13.1 70s
518 500 1316.72038 5 371 962.14595 1319.05778 37.1% 13.1 77s
519 502 1319.05778 14 376 962.14595 1319.05778 37.1% 29.3 82s
528 508 1290.80276 18 28 962.14595 1319.05778 37.1% 30.5 85s
540 516 1261.07762 24 50 962.14595 1319.05778 37.1% 31.2 91s
546 520 1248.39942 27 50 962.14595 1319.05778 37.1% 31.3 95s
564 532 1204.12531 36 29 962.14595 1319.05778 37.1% 30.8 100s
576 540 1180.07751 42 21 962.14595 1319.05778 37.1% 30.8 106s
588 548 1186.74079 48 38 962.14595 1319.05778 37.1% 30.4 111s
H 596 526 962.7274479 1319.05778 37.0% 30.2 115s
622 545 1213.47184 65 200 962.72745 1319.05778 37.0% 29.7 120s
664 573 1160.13732 86 32 962.72745 1319.05778 37.0% 28.8 125s
H 700 572 966.2164479 1319.05778 36.5% 28.3 128s
726 591 1167.75969 117 33 966.21645 1319.05778 36.5% 27.5 130s
778 626 1192.73648 143 30 966.21645 1319.05778 36.5% 26.8 135s
828 659 1129.35955 168 29 966.21645 1319.05778 36.5% 25.8 140s
best obj 1107.4475000000011
new true value 1118.879898831533
H 856 653 979.0094479 1319.05778 34.7% 25.3 142s
H 882 648 1013.8994479 1319.05778 30.1% 24.8 144s
892 657 1159.05916 200 60 1013.89945 1319.05778 30.1% 24.6 145s
928 667 cutoff 214 1013.89945 1319.05778 30.1% 23.9 150s
936 668 1306.38452 18 29 1013.89945 1319.05778 30.1% 24.5 155s
947 676 1275.93971 23 41 1013.89945 1319.05778 30.1% 24.4 160s
961 685 1272.69480 30 41 1013.89945 1319.05778 30.1% 24.3 165s
983 700 1262.98588 41 41 1013.89945 1319.05778 30.1% 24.1 170s
1005 714 1248.63478 52 34 1013.89945 1319.05778 30.1% 24.0 175s
1016 722 1242.73775 58 66 1013.89945 1319.05778 30.1% 24.1 180s
1031 732 1192.46979 65 29 1013.89945 1319.05778 30.1% 23.9 185s
1039 737 1204.70664 69 29 1013.89945 1319.05778 30.1% 23.8 190s
1053 746 1187.03236 76 29 1013.89945 1319.05778 30.1% 23.8 195s
I faced this issue in both 9.1.2 and 9.0.0 Gurobi versions. I am aware that Gurobi 9.5 accept the heuristic solution in MIPSOL as well, but I cannot move to other version due to limitation in installing the new version in our computer server.
Please let me know if you spot any issue in my code or have any suggestion.
Thank you very much.
Regards,
Kianoush
-
Hi Kianoush,
This indeed seems suspicious. Could you generate a minimal working example to reproduce the issue? You could write your master model and the Bender's submodels you solve to LP/MPS files using the write method. You can then generate a short program where you solve the master model and the submodels in your callback. You can read the model via the read method.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment