From LP or MPS to AMPL

1,878 views
Skip to first unread message

Paulo Sousa

unread,
Mar 19, 2011, 1:22:58 PM3/19/11
to AMPL Modeling Language
Dear All,

Can AMPL import a model written in LP or MPS format?

Thanks in advance,

Paulo

Paul

unread,
Mar 20, 2011, 3:05:55 PM3/20/11
to am...@googlegroups.com
AFAIK, no.  There are some scripts floating around the 'Net to convert MPS to AMPL, but the ones I found involve a mix of awk scripts and "template" AMPL model files.

Robert Fourer

unread,
Mar 20, 2011, 3:47:18 PM3/20/11
to am...@googlegroups.com
There are awk scripts for converting MPS files to AMPL data (.dat) files
that can be used with some predefined AMPL models. At
www.netlib.org/ampl/models see the awk files m2a and m2ai, and the model
files mps.mod, mps1.mod, and mpsi.mod; brief comments in the files explain
how to use them. Free implementations of awk are readily available for
download for all popular platforms.

This old MPS conversion facility is mainly intended for situations where a
non-AMPL source has provided test problems in MPS form, and you want to see
how well those problems are handled by some of your AMPL solvers. Most
likely there's some version of each of the solvers that has a way to read
MPS files directly, but by making the conversion once and then using AMPL,
you don't have to figure out each different solver's MPS interface.

(If you were building a new model for use with AMPL solvers, however, then
there would be no reason to want to use MPS form rather than building the
whole model in AMPL to begin with.)

Bob Fourer
4...@ampl.com

Paulo Sousa

unread,
Mar 21, 2011, 12:58:47 PM3/21/11
to AMPL Modeling Language
Thanks, Paul and Bob, for your replies.

Paul

fabian...@gmail.com

unread,
Apr 8, 2014, 3:53:23 PM4/8/14
to am...@googlegroups.com, psa...@gmail.com

Robert Fourer

unread,
Apr 10, 2014, 5:57:09 AM4/10/14
to am...@googlegroups.com
At www.ampl.com/netlib/ampl/models, you can find awk scripts m2a and m2ai for converting standard MPS format files into AMPL "dat" files. After the conversion, these dat files can be used with models mps.mod, mps1.mod, and mpsi.mod to solve the linear program that was represented by the MPS file. (There is a little more documentation at the site and in the files.) To use this scheme you need a copy of the "awk" program which can be found at various websites.

LP format is less standard and I don't know any way of using it with AMPL.

Most linear solvers accept MPS and LP formats directly, so normally there is no reason to want to use these formats with AMPL. If you only have the AMPL version of a solver, however, then the scheme described above might be convenient for running some test problems that are available only in MPS form.

Bob Fourer
am...@googlegroups.com

=======

SANTANU BANERJEE

unread,
Oct 5, 2022, 9:26:50 AM10/5/22
to AMPL Modeling Language
Hi! I am facing an issue while trying to access the COIN-OR CBC Lotsize variable type creation using its C++ Libraries (https://github.com/coin-or/Cbc/discussions/516#discussioncomment-3007885). I don't know how to create MPS files for my model. Kindly suggest how I may use the Lotsize or a similar variable Type

AMPL Google Group

unread,
Oct 5, 2022, 12:59:55 PM10/5/22
to AMPL Modeling Language
The MPS file format does not support CBC Lotsize variables, or any similar variable types (or constraint types). If you want to write MPS files representing your problems, you will need to instead use some equivalent formulation that only has ordinary numerical variables -- possibly with lower bounds, upper bounds, and/or integrality restrictions.

Also if you want to use MPS files with AMPL, your formulation will need to have a linear objective function and constraints. (There are some solvers that recognize extensions for quadratic constraints, but AMPL's MPS utilities do not support those.)


--
Robert Fourer
am...@googlegroups.com
{#HS:2029174846-112210#}
Reply all
Reply to author
Forward
0 new messages