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

Extracting Runtime for Root Node

回答済み

コメント

4件のコメント

  • 正式なコメント
    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 try Gurobot, our chatbot interface offering instant, expert-level support.
  • David Torres Sanchez
    • Gurobi Staff

    Hi Elina,

    The correct syntax to obtain the runtime in a callback is:

    runtime = model.cbGet(GRB.Callback.RUNTIME)

    As shown in the Callback Codes page, this attribute is available everywhere except when \(\texttt{where}=\texttt{GRB.Callback.POLLING}\).

    Cheers, 
    David

    0
  • Elina Joksch
    • Gurobi-versary
    • Conversationalist
    • Curious

    Hey David,

    thank you very much! This worked perfectly. Is it now possible to print those numbers also "in the end" to extract those numbers and compare it with different optimizations?

    Best,

    Elina

    0
  • David Torres Sanchez
    • Gurobi Staff

    Hi Elina,

    Glad it worked.
    Of course, from the Python Callbacks section:

    If you would like to pass data to your callback function, you can do so through the Model object. For example, if your program includes the statement model._value = 1 before the optimization begins, then your callback function can query the value of model._value. Note that the name of the user data field must begin with an underscore.

    So, in your case, you can set \(\texttt{model._runtime}=0\) at the beginning, update that attribute in the callback, then finally query it at the end of the optimisation.

    Cheers, 
    David

    0

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