Gurobi presolve algorithms are designed to make a model smaller and
easier to solve. However, in some cases, presolve can contribute to
numerical issues. The following Python code can help you determine if
this is happening. First, read the model file and print summary
statistics for the presolved model:
m = read('gurobi.rew') p = m.presolve() p.printStats()If the numerical range looks much worse than the original model, try the parameter Aggregate=0:
m.reset() m.Params.Aggregate = 0 p = m.presolve() p.printStats()If the resulting model is still numerically problematic, you may need to disable presolve completely using the parameter Presolve=0; try the steps above using
m.reset() m.Params.Presolve = 0 p = m.presolve() p.printStats()
If the statistics look better with Aggregate=0 or
Presolve=0, you should further test these parameters.
For a continuous (LP) model, you can test them directly.
For a MIP, you should compare the LP relaxation with and without these
parameters. The following Python commands create three LP relaxations:
the model without presolve, the model with presolve, and the model
m = read('gurobi.rew') r = m.relax() r.write('gurobi.relax-nopre.rew') p = m.presolve() r = p.relax() r.write('gurobi.relax-pre.rew') m.reset() m.Params.Aggregate = 0 p = m.presolve() r = p.relax() r.write('gurobi.relax-agg0.rew')With these three files, use the techniques mentioned earlier to determine if Presolve=0 or Aggregate=0 improves the numerics of the LP relaxation.
Finally, if Aggregate=0 helps numerics but makes the model too slow, try AggFill=0 instead.