Obtain presolve output (reduced) model without solving the problem

I am using a community edition of AMPL.. I have an instance of MIP.. How can I obtain the reduced model after presolve without solving the problem? Unfortunately my instance is too large to be solved by CPLEX, Gurobi, etc (since I am using an AMPL community edition). I tried inserting the expand and solexpand commands after the model description - but they only export the original model, not the reduced (presolved) model. Any help will be great. Is solve really necessary before we can export the presolved model?

Hi @Shuxue_Jiaoshou ,

The command solexpand should display the model that is going to be sent to the solver after presolve. On the other hand, expand shows the model before presolve.

Isn’t that you were looking for? Or you were looking for something else?

Marco, I already tried your suggestion - unfortunately it’s not working.. Let me attach the instance.
IPF.mod (46.8 KB)

Hi @Shuxue_Jiaoshou ,

Thanks for your message, I would really suggest first to use Amplpy instead of Ampl-standalone version. It’s much easier to import and export data there, you can even easily plot the solution:

from amplpy import AMPL
import pandas as pd

ampl = AMPL()
ampl.read('ipf.mod')

ampl.param["N"] = 180
ampl.param["solutionValue"] = 162

edges = [(1, 180), (5, 180)]  # Minimal example!
ampl.set["Edges"] = edges

ampl.option['presolve'] = 20

ampl.eval('solexpand > presolved-instance-solexp.lp')
ampl.solve(solver=solvername)

solution = ampl.get_solution(zeros=False, flat=False)
print(solution)

And just keep your model (ipf.mod) as:

param N;
param solutionValue;

set Vertices := 1..N;
set Edges within (Vertices cross Vertices);

var F {Vertices} binary;

subject to total_summation:
sum {t in Vertices} F[t] <= solutionValue;

subject to independence {(x,y) in Edges}:
F[x] + F[y] >= 1;

Take a look at some useful resources about amplpy:

Here expand and solexpand are returning exactly the same model because there’s no chance for Ampl presolve to remove any variable or constraint. No variable bound can be tighten, the only way to remove “independence“ constraints is through fixing some of the F. Is there a way to know which F’s can be fixed?

If you increase the value of solutionValue, you’ll see that presolve will do some work, for example, the total_summation constraint can be eliminated.

Again, I encourage you to use Ampl through VS Code and Amplpy, that should be much easier to manage than dealing with the “dat“ format and easier to write scripts

Very valuable and detailed information - Thanks Marcos.

1 Like