Exporting the Reduced (Pre-solved) model
AnsweredLet us call the model AFTER pre-solving as the "Reduced Model"... How can I get this reduced model? Is it possible to export this to a file from command line? Doesn't matter whether I can get this done with or without running the problem to completion.
I have seen this: https://support.gurobi.com/hc/en-us/articles/360024738352-How-does-presolve-work- and this: https://www.gurobi.com/documentation/9.5/refman/py_model_presolve.html
But unfortunately they don't say how to get the Reduced Model from the command line.
Why do I need the reduced model? So that I don't need to use the presolver repeatedly.
Thanks.
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Prabhu,
you could try:
reduced_model = model.presolve()
reduced_model.write("reduced_model.lp")Best regards
Jonasz0 -
Hi Jonasz, Thank you, but, as I asked in my previous post, is it possible to do all this from the command line?
0 -
Yes, exactly in the same fashion.
You first generate the presolved model:
> reduced_model = model.presolve()
and then you store it in your desired location:
> reduced_model.write("reduced_model.lp")Best regards,
Jonasz1 -
Please also see the Knowledge Base article How does presolve work? for more information.
0 -
Please note that you need to be in an interactive Python shell to run those commands. Exporting the presolved model does not work directly through the command line with gurobi_cl.
Cheers,
Matthias1 -
Thanks Matthias.. Yes, I should have made it clear that I was talking about the LINUX shell command line (gurobi_cl) -- NOT the Python shell :-)
Anyway, I got the job done by writing Python code, by following this post by Glockner at Stack Overflow. Here's my modified code:
#!/opt/gurobi951/linux64/bin/python3.7
(Your python3.7 may be located in a different directory.
So replace the above line accordingly.)
import gurobipy as gp
from gurobipy import GRB
modello = gp.read("Original_Model.lp")
reduced_model = modello.presolve()
reduced_model.write("reduced_model.lp")Thanks everyone.
0
Post is closed for comments.
Comments
7 comments