Skip to main content

Save optimizer state and resume.

Answered

Comments

4 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than two 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.
  • Simranjit Kaur
    • Gurobi Staff

    Hi Milin,

    Calling the optimize() method again on a model will continue the optimisation process from the last state where the optimizer had stopped. Please see a sample code below.

    import gurobipy as gp

    #construct your model
    ...

    # your custom terminating criteria
    model.params.MipGap=0.05
    ...

    # optimize
    model.optimize()

    # do something with the solution/s
    ...

    #redefine termination criteria
    model.params.MipGap=0.02
    ...

    #resume optimisation
    model.optimize()
    Best regards,
    Simran
    0
  • Milin Kodnongbua
    • Gurobi-versary
    • First Question
    • First Comment

    Thanks for the response.

    However, I mean load the state to a new instance of solver in a new process. The same solver is not in memory anymore. Is there a way to save/load from disk?

    0
  • Simranjit Kaur
    • Gurobi Staff

    Hi Milin, 

    It is not possible to save a snapshot of the optimizer state to a disk. One cannot store the branch-and-bound tree or the presolve transformations. However, you can store the solution at the end of a solve by writing the SOL file and use it to warm-start the next solve.  

    Best regards,
    Simran

    0

Post is closed for comments.