1 comment

•  Gurobi Staff

It sounds like you are relaxing your problem correctly. However, the root relaxation in Gurobi is more sophisticated than relaxing the integrality of a MIP. You can access this information by saving the presolved model or turn it off by turning off presolve.

For those just reading this article, you can follow along using the p0033.mps example model that comes packaged with Gurobi.

First, solve the original model:

model = gp.read('<installdir>/examples/data/p0033.mps')model.optimize()

The root relaxation for the original model is 2,839.

Next, you can solve the relaxed MIP using the model.relax() method:

model.reset()model = model.relax()model.optimize()

The optimal solution of the relaxed MIP is 2,521. You can see that the root relaxation provides a tighter solution than the relaxed MIP.

To explore this difference further, it's interesting to do the following two solves:

First, turn off the presolve routine and solve as follows:

model.reset()model.Params.PreSolve=0model.optimize()

Solving without presolve will give you a root relaxation of 2,521. You can see that this matches the relaxed MIP solution.

Next, you can solve the relaxed presolve model:

# Store the presolve modelmodel.reset()presolve_model = model.presolve()# Relax integrality, then solvepresolve_model = presolve_model.relax()presolve_model.optimize()

The final solve gives an optimal objective of 2,839. This matches our root relaxation from the original model.