Skip to main content

Strange values for GRB_CB_MIP_OBJBST and GRB_CB_MIP_OBJBND at root node

Answered

Comments

5 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff 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?.
  • Eli Towle
    Gurobi Staff Gurobi Staff

    \( \texttt{GRB_CB_MIP_OBJBST} \) and \( \texttt{GRB_CB_MIP_OBJBND} \) are specifically meant to be used when \( \texttt{where == GRB_CB_MIP} \). Similarly, \( \texttt{GRB_CB_MIPSOL_NODCNT} \) is meant to be used when \( \texttt{where == GRB_CB_MIPSOL} \).

    When \( \texttt{where == GRB_CB_MIPNODE} \), use:

    • \( \texttt{GRB_CB_MIPNODE_OBJBST} \) for the best objective value
    • \( \texttt{GRB_CB_MIPNODE_OBJBND} \) for the best objective bound
    • \( \texttt{GRB_CB_MIPNODE_NODCNT} \) for the explored node count.

    See the Callback Codes section of the documentation for more details.

    You can wrap the code in the callback function with a conditional statement to avoid running the entire code every time the callback is triggered (not unlike what you already do). This should have a low overhead.

    1
  • Alberto Santini
    Gurobi-versary
    Curious
    Conversationalist

    Thanks Eli. It completely escaped me that I was using a where == GRB_CB_MIPNODE but then I was using the MIPSOL and MIP codes. Changing that fixed this problem.

    It's still not clear to me what happens with the number of nodes, though. My callback is called 100% of the time with GRB_CB_MIPNODE_NODCNT == 0, the primal and dual bound are equal at the end of the exploration of the root node, so I would assume Gurobi should only explore one node. However, the log still says 104 nodes were explored, and GRB_DoubleAttr_NodeCount also says it's 104. Am I missing something here?

    P.S. How do you format in-line code nicely with fixed-width font?

    0
  • Eli Towle
    Gurobi Staff Gurobi Staff

    Could you post your revised callback code, along with the log output (including values printed in the callback function)?

    To write \(\texttt{inline code}\), you can use:

    \(\texttt{inline code}\)

    For more information, see the Posting to the Community Forum article.

    0
  • Alberto Santini
    Gurobi-versary
    Curious
    Conversationalist

    Sorry Eli, it was my mistake. Indeed everything works as it's supposed to, including bounds and number of nodes explored. Thanks a lot for your help.

    0

Post is closed for comments.