Skip to main content

Help with incumbent

Answered

Comments

3 comments

  • Official comment
    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

Post is closed for comments.