Writing LP without solving problem

2,200 views
Skip to first unread message

Cristián Serpell

unread,
Jun 8, 2015, 2:06:53 PM6/8/15
to pyomo...@googlegroups.com
Hi pyomo team,

Is there a known way to write the generated LP file of a problem, without starting the solving steps? I would like to use pyomo to formulate the model, write the instance as LP and then finish. Is it necessary to even create a solver instance? I already write the pprint version.

Thanks,
Cristián

David Woodruff

unread,
Jun 8, 2015, 3:04:26 PM6/8/15
to pyomo...@googlegroups.com
The pyomo convert command is what you need. Try
pyomo convert -h


--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hart

unread,
Jun 8, 2015, 3:25:18 PM6/8/15
to pyomo...@googlegroups.com
Use the 'pyomo convert' subcommand:

  pyomo convert --format=lp model.py

--

Cristián Serpell

unread,
Jun 8, 2015, 3:29:44 PM6/8/15
to pyomo...@googlegroups.com
Can I instantiate that command from a python program using a concrete model?

Thanks for your fast response,
Cristián

Gabriel Hackebeil

unread,
Jun 8, 2015, 3:39:27 PM6/8/15
to pyomo...@googlegroups.com
I believe the PyomoModel object has a “write” method on it. It will try to infer the format you want by looking at the suffix you give the file name. E.g., instance.write(‘junk.lp’). If you want to see variable names rather than shortened symbols in the LP file you would add the keyword ‘io_options={‘symbolic_solver_labels’:True}”.

Gabe

Cristián Serpell

unread,
Jun 8, 2015, 3:51:12 PM6/8/15
to pyomo...@googlegroups.com
Ahh! It is true, I had that code somewhere and had lost it. Thanks a lot, it works perfectly.
Reply all
Reply to author
Forward
0 new messages