Changing the NoRelHeurTime parameter for the NoRel Heuristic using Callbacks
OngoingHi,
I'm using the No Relaxation heuristic to quickly find feasible solutions for my optimization problem, which works very well. I was wondering whether it is possible to change the NoRelHeurTime parameter using a Callback, based on the phase of the NoRel heuristic.
For example, I want Gurobi to spend 250 seconds in phase 2 of the NoRel heuristic, after it has found a feasible solution in phase 1. When I set the NoRelHeurTime parameter, it affects both phase 1 and 2, and it is unknown how long phase 1 will take. So in the callback, I want to check if Gurobi is in phase 2 of the NoRel heuristic, and if so, I want to change the NoRelHeurTime parameter, such that it will spend exactly 250 seconds in phase 2.
I have been looking for the "where" condition in the list of callback options in the documentation, but I couldn't find what I was looking for. Or maybe it is named differently from what I expected.
Furthermore I was wondering whether there are any sources available that explain the working principle of the NoRel heuristic. I'm using Gurobi for my thesis project, so it would be nice to include some details in the methodology part of my report.
Thanks in advance!
Best regards,
Koen Timmermans
-
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 -
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.
Comments
2 comments