メインコンテンツへスキップ

Usercut callback and lazycut callback via C

回答済み

コメント

3件のコメント

  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    It is right, you need only one callback function. The "where" argument in the callback function indicates at which step of the algorithm the code is called, see Callback Codes.
    The relevant function to add lazy constraints is GRBcblazy. As the documentation says, it can only be called if the where is \(\texttt{GRB_CB_MIPSOL}\) or \(\texttt{GRB_CB_MIPNODE}\). So, you could add your lazy constraints whenever a new solution is found (\(\texttt{GRB_CB_MIPSOL}\)) as it is done in the example tsp_c.c or additionally in each MIP node (\(\texttt{GRB_CB_MIPNODE}\)).
    The relevant function to add user cuts is GRBcbcut which can only be called if the where is  \(\texttt{GRB_CB_MIPNODE}\).

    1
  • OneCable OneCable
    First Comment
    First Question

    Thank you Marika. I have two follow up questions

    (1) Is there an example for adding usercuts via GRBcbcut as there is for lazycuts [tsp_c.c]? I did search on https://docs.gurobi.com/projects/examples/en/current/examples/callback.html but no cut seems to be added in that example -- only status display in the lazy cut section [where == GRB_CB_MIPSOL] and no cut was added in the user cut section [where == GRB_CB_MIPNODE]

    (2) Is there a way to add user cuts locally, i.e., only valid within the subtree rooted at the current MIP node where the cut is found? In CPLEX, this is done via CPXcutcallbackaddlocal() as opposed to CPXcutcallbackadd() which adds the cuts globally. I'd presume that GRBcbcut is equivalent to the latter. Could you please confirm?

    Thank you.

    0
  • Marika Karbstein
    Gurobi Staff Gurobi Staff

    The documentation of GRBcbcut provides a small example. The usage is similar to adding lazy constraints. So, for the general guidelines, you can use the tsp example.

    It is not possible to add only locally valid user cuts,see Can I add locally valid constraints in Gurobi MIP?

    1

サインインしてコメントを残してください。