Skip to main content

Changing the NoRelHeurTime parameter for the NoRel Heuristic using Callbacks

Ongoing

Comments

2 comments

  • Silke Horn
    • Gurobi Staff Gurobi Staff

    Hi Koen,

    I am happy to hear that the NoRel heuristic is working so well for you.

    Unfortunately, it is not possible to change parameter settings in a callback. See this article for more information. However, I don't think the approach described in the article works for what you want to do. (I.e., when I stop and restart, it does not continue with NoRel.)

    I would recommend the following: You can parse the log output in a callback via MSG_STRING and look for "Transition to phase 2". Then you record the RUNTIME call Model.cbProceed() 250 seconds after that (by continually checking the RUNTIME until 250 seconds have passed).

    As for the inner workings of the NoRel heuristic, some information is contained in this "What's new in Gurobi 9.1?" presentation. (The video is more than 2h, but NoRel is explained in the beginning; if you start at about 10 min, you'll find it.) You can also find the slides here. I am not sure whether we publicly shared more details than that.

    0
  • Koen Timmermans
    • Gurobi-versary
    • Conversationalist
    • Curious

    Hi Silke,

    Thank you for the quick reply! Unfortunately, the first link in your message is not working for me.

    And thank you for your recommended approach. If I understand you correctly, Model.cbProceed() lets Gurobi proceed from the NoRel heuristic to the next phase (after the NoRel heuristic)?

    I was looking at Model.cbProceed() and I noticed this block of code there:

    def mycallback(model, where):
        if where == GRB.Callback.MIPSOL:
          phase = model.cbGet(GRB.Callback.MIPSOL_PHASE)
          obj = model.cbGet(GRB.Callback.MIPSOL_OBJ)
          if phase == GRB.PHASE_MIP_NOREL and obj < target_obj:
            model.cbProceed()
    
      model.optimize(mycallback)

    What about the \(\texttt{if phase == GRB.PHASE_MIP_NOREL and obj < target_obj:}\) line? It seems that \(\texttt{GRB.PHASE_MIP_NOREL}\) is never mentioned in the documentation except for the same example as in the codeblock above. But what I'm thinking of now: isn't it possible to check in a callback if 1.) the current phase is the MIP_NOREL phase AND 2.) if there is an objective value? Because there is an objective value after the first phase of the NoRel heuristic, right? Or does Gurobi only return an objective value in the MIP (solving) phase? If this is possible, then I can call Model.cbProceed() at that moment, so that I don't have to look into the MSG_STRING?  I hope that my idea is clear.

    And lastly, thanks for providing some extra information on the NoRel heuristic itself. I will have a look at it!

    Best regards,

    Koen Timmermans

    0

Please sign in to leave a comment.