Skip to main content

Exporting the Reduced (Pre-solved) model

Answered

Comments

7 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    Hi Prabhu,

    you could try:

    reduced_model = model.presolve()
    reduced_model.write("reduced_model.lp")

    Best regards
    Jonasz

    0
  • Prabhu Manyem
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jonasz,  Thank you, but, as I asked in my previous post, is it possible to do all this from the command line?

     

    0
  • Jonasz Staszek
    • Community Moderator
    • Gurobi-versary
    • Thought Leader
    • First Question

    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,
    Jonasz

    1
  • Gwyneth Butera
    • Gurobi Staff

    Please also see the Knowledge Base article How does presolve work? for more information.

    0
  • Matthias Miltenberger
    • Gurobi Staff

    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,
    Matthias

    1
  • Prabhu Manyem
    • Gurobi-versary
    • First Comment
    • First Question

    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.