Skip to main content

Why is Gurobi taking too much time after finding the optimal solution?

Answered

Comments

6 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 why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi,

    There are 2 calls to Model.optimize() which can be seen at the 2 lines stating the Gurobi version

    Gurobi Optimizer version 9.0.1 build v9.0.1rc0 (mac64)

    Are you using a third party software to call Gurobi?

    Could you provide a minimal working example?

    Best regards,
    Jaromił

    0
  • Khadija HADJ SALEM
    • Gurobi-versary
    • First Comment
    • First Question

    Hi again, 

    I have a function (below) to compute the root relaxation of my model. So, for this reason, I have 2 calls to Model.Optimize(). 

    Best regards, 

    Khadija

    def compute_root_relax(model):
    r = model.relax()
    r.Params.Presolve=0
    r.optimize()
    if (r.Status != GRB.OPTIMAL):
    print ("Root relaxation optimization status: ", r.Status)
    return r
    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Khadija,

    Ok, so this explains the two optimizations.

    Just for my understanding. You are first optimizing your integer problem and get the solution 3.1274e+04. Next, you construct a relaxation of your integer problem using the relax() function, which solves your original model but the integer variables are relaxed to be continuous. Is there a particular reason for turning off the Presolve? Note that for your original integer problem which has been solved quickly, you did not turn off presolving. Presolve is in most cases essential for good performance.

    Best regards,
    Jaromił

    0
  • Khadija HADJ SALEM
    • Gurobi-versary
    • First Comment
    • First Question

    No, I have no specific reason to turn off the Presolve parameter. I just tried to compute the root relaxation of my model with Gurobi's default parameters.
    I tried to solve my model again by activating Presolve (= 1) when I call my function relax() and Gurobi takes over 120 seconds to solve my model with relaxed variables.

    So, is there another way to improve this?

    Thank again.

    Best regards!

    Khadija

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Khadija,

    It seems like the Presolve algorithms for integer variables are essential for simplifying and quickly solving the root relaxation. You could try and add one binary variable to the objective which is redundant, e.g., \( + b\) in the case of minimization. This might help.

    What exactly are you using the relaxed model for? Are you interested in the optimal solution of the relaxed model? You can access various information on the root relaxation during the first optimization run already by the use of callbacks. Thus, you maybe don't have to re-solve the relaxed model. In particular, you would use the MIPNODE callback.

    You could also try the Gurobi parameter tuning tool to find settings improving the solution performance of the relaxed model.

    Best regards,
    Jaromił

    0

Post is closed for comments.