Custom heuristic implementation for MIQCP
AnsweredI am trying to solve an MIQCP, for which a fractional solution at a MIP node can be converted to an integer feasible solution rather easily using a heuristic. Does Gurobi support custom heuristics for QCP/MIQCP? And, in such a case, what should be the "where" and "what" in the callback code ( Link: https://www.gurobi.com/documentation/9.0/refman/cb_codes.html ). Any tips will be much appreciated.
-
Official comment
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?. -
Yes, Gurobi supports callbacks for (MI)QCPs. The callback \(\texttt{where}\) you are looking for is \(\texttt{MIPSOL}\) which triggers when a new feasible solution has been found. In this callback, you can access the feasible solution via the cbGetSolution method. After improving the solution point via your heuristic, you can save this point and provide the improved solution point in the \(\texttt{MIPNODE}\) callback via the cbSetSolution method.
Best regards,
Jaromił0 -
Hi Jaromił,
Thank you very much for your response. To clarify, for the heuristic, I need a fractional solution only that satisfies the linear constraints (I do not need a feasible solution of the MIQP), and I can generate a good feasible solution to the MIQP from that fractional solution because of a special structure present in the problem. In that situation, is my `where` still `MIPSOL`?
0 -
Hi,
In the MIPSOL callback you can access a feasible solution which satisfies all constraints of the given model, i.e., the solution will satisfy all linear and all quadratic constraints.
I think what you are looking for is the \(\texttt{MIPNODE_REL}\) (\(\texttt{what}\)) of the \(\texttt{MIPNODE}\) callback, which returns the solution of the LP relaxation of a given node via the cbGetNodeRel method. This relaxation solution does not have to fulfill the quadratic constraints. However, it also does not have to fulfill the integer linear constraints, because it is a relaxation solution.
If you are looking for a feasible point which fulfills all integer and continuous linear constraints, then you would have to create a new model without the quadratic parts and solve it separately.
Best regards,
Jaromił0 -
Hi Jaromił,
Thanks very much for the update, the second paragraph is exactly what I need to access: a fraction solution to the LP relaxation (it does not need to satisfy the quadratic and/or integer constraints), the heuristic can generate an integer feasible solution to the MIQCP from the fractional solution based on the special structure of the problem.
Best Regards,
Shuvo
0
Post is closed for comments.
Comments
5 comments