1 comment

• Gurobi Staff

The example problem is a continuous linear problem, so it is not solved as a MIP and there is no MIPGap to report. The model status is $$\texttt{GRB.OPTIMAL}$$, meaning the problem was solved to optimality. You can check if a problem is solved as a MIP by querying the value of the IsMIP model attribute:

print("IsMIP:", prob.IsMIP)

If you were to change the model so Gurobi solves the problem as a MIP (e.g., by changing a variable to be integer or introducing a non-convex quadratic constraint like you mentioned), you should be able to query the MIP gap.

I used to be able to do this before but I don't know why I can't do this anymore.

Do you mean you used to be able to query the MIP gap of a continuous linear problem like this? It's expected that the MIP gap is not available for such problems.