Skip to main content

Obtain root relaxation time

Answered

Comments

7 comments

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Théo,

    The information you want to access is not available after the optimization has finished. Thus, you can use callbacks to access the information you seek. The MIPNODE_NODCNT value can be used to check whether you are in the root node. If it is \(=0\), then you are in the root node. Then, you can access the MIPNODE_OBJBND value to get the relaxation objective value and RUNTIME to get the runtime so far.

    As already mentioned, alternatively, you can use the MESSAGE callback to access the log strings.

    Another option would be to set the parameter NodeLimit=0 and access the attributes ObjBound and Runtime.

    Best regards,
    Jaromił

    1
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Théo,

    You can access the information you are looking for via callbacks. In particular, you should check out the MIPNODE callback with its MIPNODE_NODCNT and MIPNODE_OBJBND values.

    An alternative would be to use the MESSAGE callback and parse the log string MSG_STRING value.

    Best regards,
    Jaromił

    0
  • Théo BORDILLON
    Gurobi-versary
    First Comment
    First Question

    Hi Jaromil,

    I forgot to mention that I use JuMP and Julia for my work.

    I don't really undersant why I should use the MIPNODE callback because for exemple my terminal is like : 

    Presolve removed 360 rows and 40 columns
    Presolve time: 0.07s
    Presolved: 1400 rows, 1680 columns, 8679 nonzeros
    Variable types: 0 continuous, 1680 integer (1600 binary)

    Root relaxation: objective 0.000000e+00, 430 iterations, 0.02 seconds

    Nodes | Current Node | Objective Bounds | Work
    Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time

    And I want to get this information : 

    Root relaxation: objective 0.000000e+00, 430 iterations, 0.02 seconds

    For exemple if I want the number of Node, I just have to use this function :

    MOI.get(model, MOI.NodeCount())

     

    If I understood correctly MIPNODE_NODCNT give me the number of node and MIPNODE_OBJBND give me the objective bound, but it's not what I want

    0
  • Théo BORDILLON
    Gurobi-versary
    First Comment
    First Question

    Oh! Ok I understand.

    Thank you very much Jaromil

     

    Cordialy,

    Théo

    0
  • Théo BORDILLON
    Gurobi-versary
    First Comment
    First Question

    Hello,

    I took back what you said last time. I tried to use de MESSAGE callback for exemple but on every call I get a 0 and I don't know why. I tested with other Callback Codes and I still get 0.

    My callback function (in Julia) is like :

    function my_callback_function(cb_data, cb_where::Cint)
    if cb_where == GRB_CB_MESSAGE
    resultP = Ref{Cstring}()
    println(GRBcbget(cb_data, cb_where, GRB_CB_MSG_STRING,resultP))
    end
    return
    end

     

    0
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi,

    According to the Julia documentation, they don't support the MESSAGE callback. However, they seem to support the MIPNODE callback. Did you think about switching to Gurobi's native Python API? It is intuitive and the switch should be easy for you, given the fact that you already have Julia code.

    Best regards,
    Jaromił

     

    0
  • Théo BORDILLON
    Gurobi-versary
    First Comment
    First Question

    Hi,

    Sorry I forgot to answer you. The problem is solved and therefore I use the MIPNODE callback.

    Théo

    0

Please sign in to leave a comment.