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

Help with incumbent

回答済み

コメント

3件のコメント

  • 正式なコメント
    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.
  • Jaromił Najman
    • Gurobi Staff

    Hi Alejandro,

    There is no built-in method or attribute to get this information, but it can be obtained with callbacks.

    One example code might looks something like

    import gurobipy as gp
    from gurobipy import GRB

    def mycallback(model,where):
    if where == GRB.Callback.MIP:
      solcnt = model.cbGet(GRB.Callback.MIP_SOLCNT)
      if solcnt == 1:
    runtime = model.cbGet(GRB.Callback.RUNTIME)
      print("Found first incumbent after %f seconds."%(runtime))

    m = gp.read("myLP.lp")
    m.optimize(mycallback)

    Best regards, 
    Jaromił

    0
  • Alejandro Arenas
    • Gurobi-versary
    • First Comment
    • First Question

    Thank you!

    0

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