Gurobi: Save model after presolve for reuse

I'm looking for a way to save a presolved model in gurobi, so that I can save the time necessary for presolving the next time I'm running the model.

I have tried to write the model to a .mps/.lp file using a callback function after presolve, but when I load the file it starts to presolve again.

I'd also be thankful for negative answers, if what I'm looking for isn't possible.

PS.: I'm using Gurobi 7.5.2 with python 3.6

Upvotes: 3

Views: 1659

Answers (1)

Greg Glockner
Greg Glockner

Reputation: 5653

It is very uncommon to save the presolved model. The key exceptions are:

  1. When you want to understand the presolve transformations
  2. For benchmarking when you don't want to repeat presolve

Gurobi lets you access the presolved model, but only from the Python API. Here is some sample code:

from gurobipy import *
m = read("mymodel.mps")
mp = m.presolve()
mp.write("mypresolved.lp")

Upvotes: 5

Related Questions