Skip to main content

Help with incumbent

Answered

Comments

2 comments

  • Jaromił Najman
    Gurobi Staff 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

Please sign in to leave a comment.