I'm working on a large scale MIP. So I have to set the time limit to a reasonable value. But the problem is that after the timelimit is met, I don't know how to evaluate the solution, in another words, the gap between lower and upper bounds. Yes, the gap will be shown on screen. But if there is a way to get its value with Python API? So I can output it or do some following statistcs. I have to solve more than 10 MIP at once, it's hard to find the gaps one by one on screen. Thx for your help!
Your tags indicate that you are using Gurobi with the Python API to solve your models.
To retrieve the relative MIP gap, you can query the MIPGap attribute (see http://www.gurobi.com/documentation/6.5/refman/mipgap.html)
Python example:
from gurobipy import *
model = read("model.mps")
model.params.TimeLimit = 100
model.optimize()
print("Final MIP gap value: %f" % model.MIPGap)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With