Skip to main content

Get the current solution before best objective found

Answered

Comments

3 comments

  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Jiayin,

    You should be able to issue a keyboard interrupt, which will tell Gurobi to stop the solve.  On my Mac for example the keyboard interrupt is control-C.  The solver will be in a state as if it had reached a time limit so you can query the best solution as normal.  If you're using a Jupyter Notebook the keyboard interrupt may not work but you can interrupt the kernel via the interface in the notebook and the result should be the same.

    I suggest you run a test with our model "glass4.mps" which we distribute with Gurobi.  On my mac for example this is located here

    /Library/gurobi1002/macos_universal2/examples/data/glass4.mps

    You can read it in and solve like this

    import gurobipy as gp
    m = gp.read("/Library/gurobi1002/macos_universal2/examples/data/glass4.mps")
    m.optimize()

    Try the keyboard interrupt within the first 10 seconds or so, and if it is successful then you can be confident it will work with your model.

    - Riley

    0
  • Jiayin Fu
    Gurobi-versary
    First Comment
    First Question

    Hi Riley,

    thanks a lot for your help. Can you tell me how to query the current solutions now? I've interrupted the procedure. I'm not sure if it's possible as the model didn't start to write any file yet. My prints are as follows:

    ......   ......  

    H41859 20357                      26.1210683   25.64906  1.81%  1155 438054s
     41996 20471   26.01770 2379 3794   26.12107   25.64906  1.81%  1156 439928s
    H41999 20373                      26.1201197   25.64906  1.80%  1156 439935s
    H42105 19797                      26.1150468   25.64906  1.78%  1154 439970s

    Cutting planes:
      Gomory: 308
      Cover: 184
      Implied bound: 69
      Clique: 32
      MIR: 3386
      Flow cover: 10568
      RLT: 8521
      Relax-and-lift: 1043

    Explored 42110 nodes (48885439 simplex iterations) in 440000.40 seconds
    Thread count was 4 (of 4 available processors)

    Solution count 10: 26.115 26.1201 26.1211 ... 26.1243

    Solve interrupted
    Warning: max constraint violation (9.9999e-05) exceeds tolerance
    Best objective 2.611504684425e+01, best bound 2.564906168949e+01, gap 1.7844%

    Process finished with exit code -1

    Is there any commands that can be used in terminal in pycharm?

    Best,
    Jiayin

    0
  • Riley Clement
    Gurobi Staff Gurobi Staff

    Hi Jiayin,

    How were you running Python?  From a script, or interactively?

    - Riley

    0

Please sign in to leave a comment.