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

Infeasible solution in a callback

回答済み

コメント

5件のコメント

  • 正式なコメント
    Simranjit Kaur
    • 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

    From the documentation for Model.cbGetNodeRel():

    Note that this method can only be invoked when the \( \texttt{where} \) value on the callback function is equal to \( \texttt{GRB.Callback.MIPNODE} \) and \( \texttt{GRB.Callback.MIPNODE_STATUS} \) is equal to \( \texttt{GRB.OPTIMAL} \)

    Before calling Model.cbGetNodeRel(), can you try using Model.cbGet() to verify that the MIPNODE_STATUS is optimal? E.g.:

    elif where == GRB.Callback.MIPNODE and model.cbGet(GRB.Callback.MIPNODE_STATUS) == GRB.OPTIMAL:
    ...
    0
  • Jiří Fink
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you for your help. I misunderstood this sentence. Therefore, I followed an example on the documentation for https://www.gurobi.com/documentation/9.1/refman/py_model_cbgetnoderel.html

    def mycallback(model, where):
        if where == GRB.Callback.MIPNODE:
          print(model.cbGetNodeRel(model._vars))

    I think it would be better to update this example to check the value of as required by the documentation. Furthermore, it would be helpful to generate some kind of error when cbGetNodeRel is improperly used; e.g. if is used when where != GRB.Callback., then the following message is printed.

    0
  • Maliheh Aramon
    • Gurobi Staff

    Hi Jiří,

    Gurobi 9.5 was recently released. Included in this release is a fix to the strange behaviour of the Model.cbGetNodeRel() method you saw when MIPNODE_STATUS is not equal to GRB.OPTIMAL. With the new fix, an exception is raised if asking for a solution when MIPNODE_STATUS != GRB.OPTIMAL and the solution vector is initialized to GRB.UNDEFINED (1e+101) values.

    The code snippet in the documentation of Model.cbGetNodeRel() is also fixed to check the model status before asking for a solution. 

    We hope this new fix works well for you. Please let us know if you find any issues using this.

    Best regards,

    Maliheh

    0
  • Jiří Fink
    • Gurobi-versary
    • First Comment
    • First Question

    Great. Thank you.

    0

投稿コメントは受け付けていません。