How to enable gurobi checkpoint in a MILP problem?
AnsweredHello Help Center:
Could you please advise how to enable/set checkpoints in Gurobi for a MILP problem?
-
Hi Peng Xu,
Can you explain a bit more about what you mean by checkpoints?
- Riley
0 -
In the context of Gurobi (or any optimization solver), a checkpoint is a snapshot of the solver's current state, including data, variables, and progress, allowing you to resume the optimization process later if needed, such as after an interruption or a technical issue.
In my case, due to the limited wall time on HPC, I wanna resume the optimization process from when the HPC wall time gets due, instead of asking Gurobi to solve from scratch.
0 -
Ah I understand. If you are using an API and terminate the solve, you may resume it later in the same code, e.g. in Python
import gurobipy as gp
m = gp.read(...)
m.params.TimeLimit=3
m.optimize()
m.params.TimeLimit=2
m.optimize() # <- resumes optimizationBut this doesn't sound like it would help for your HPC. There is no snapshotting functionality though beyond this.
The next best thing is saving solutions to file such as MST or SOL formats, and then using these to warm start the solver. But in this case you are starting from scratch - just with some solutions at hand.
- Riley
0 -
Dear Riley
I bet that's the way to go!
Could you please show me an example to enable/activate an MST/SOL, save the file (to some directory), then read it to warm start the solver.
Thanks for guidance and support.
0 -
Hi Peng Xu,
There's a few ways to do this.
In your case it might be easiest to use the SolFiles parameter. Give this parameter a value which points to a directory and Gurobi will write all solutions to that directory. The files written later will be better solutions.
Or you can use the ResultFile parameter. Set this to a file path - you will want it to end in either ".mps", ".mps.bz2" or ".sol".
You can use either of these from the command line.
The other option is to use the "write" method from whatever API you are using.
- Riley
0
Please sign in to leave a comment.
Comments
5 comments