Skip to main content

Cannot access MIPGap attribute

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Eli Towle
    • 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.

    0

Post is closed for comments.