Terminating optimization when leaving root node posts a different bestbound than the one in log.
Awaiting user inputPython 3 + Gurobi 9.5
I'm currently doing lower bound analysis in the root node. Since I'm only interested in the root I terminate the optimization using callbacks:
if where == GRB.Callback.MIP and m.cbGet(GRB.Callback.MIP_NODCNT) != 0:
m.terminate()
bst = m.cbGet(GRB.Callback.MIP_OBJBST)
bnd = m.cbGet(GRB.Callback.MIP_OBJBND)
gap = (bst - bnd) / bst * 100
print(
f"\nLeft Root node\n\Best objective {bst:.12e}, best bound {bnd:.12e}, gap {gap:.4f} %\n"
)
But then, the log shows that there's a better lower bound which, in turn, would mean a lower gap than the one obtained when terminating the optimization (if this new lowerbound corresponds to one obtained in the root).
Root relaxation: objective 5.307926e+04, 1202 iterations, 0.02 seconds (0.05 work units)
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 53079.2556 0 92 - 53079.2556 - - 0s
0 0 66534.4216 0 94 - 66534.4216 - - 0s
0 0 67567.6001 0 68 - 67567.6001 - - 0s
H 0 0 77129.600000 67567.6001 12.4% - 0s
H 0 0 75067.200000 68443.9437 8.82% - 0s
0 0 68443.9437 0 81 75067.2000 68443.9437 8.82% - 0s
H 0 0 74847.200000 68443.9437 8.56% - 0s
0 0 68448.5698 0 82 74847.2000 68448.5698 8.55% - 0s
0 0 68587.7181 0 78 74847.2000 68587.7181 8.36% - 0s
0 0 68774.2004 0 87 74847.2000 68774.2004 8.11% - 0s
0 0 68777.0450 0 90 74847.2000 68777.0450 8.11% - 0s
0 0 68778.1575 0 91 74847.2000 68778.1575 8.11% - 0s
0 0 68999.7748 0 89 74847.2000 68999.7748 7.81% - 0s
0 0 69003.6911 0 88 74847.2000 69003.6911 7.81% - 0s
0 0 69004.7754 0 93 74847.2000 69004.7754 7.81% - 1s
0 0 69156.0564 0 93 74847.2000 69156.0564 7.60% - 1s
0 0 69175.7393 0 94 74847.2000 69175.7393 7.58% - 1s
0 0 69176.0974 0 109 74847.2000 69176.0974 7.58% - 1s
0 0 69187.0660 0 94 74847.2000 69187.0660 7.56% - 1s
0 0 69187.5403 0 94 74847.2000 69187.5403 7.56% - 1s
0 0 69201.6884 0 104 74847.2000 69201.6884 7.54% - 1s
0 0 69201.6884 0 104 74847.2000 69201.6884 7.54% - 1s
0 2 69201.6884 0 104 74847.2000 69201.6884 7.54% - 1s
Left Root node
Best objective 7.484720000000e+04, best bound 6.920268589866e+04, gap 7.5414 %
Cutting planes:
Implied bound: 12
MIR: 29
Flow cover: 35
Zero half: 6
RLT: 11
Relax-and-lift: 1
Lazy constraints: 110
Explored 3 nodes (5385 simplex iterations) in 1.74 seconds (1.42 work units)
Thread count was 16 (of 16 available processors)
Solution count 3: 74847.2 75067.2 77129.6
Solve interrupted
Best objective 7.484720000000e+04, best bound 6.970075276348e+04, gap 6.8759%
Where does this new best bound come from? If I'm telling the solver to terminate when the MIP_NODCNT != 0 then it shouldn't solve any other node but the root, right?
Should I be using MIPSOL or MIPNODE instead of MIP? or another callback code? Since I realize that the amount of explored nodes is 3 instead of 1.
Thanks in advance!
Nicolas
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
I solved it by just setting the parameter NodeLimit to 1
But I still have the question as to why gurobi explores +2 nodes even when I tell it to stop when the NODCNT != 0
0
Post is closed for comments.
Comments
3 comments