How do I write an “MPS file” for my problem?

You can use AMPL’s write command to create a file that contains a representation of your linear or integer program in a standard format known as MPS form. To write an MPS-form file for the diet LP from Chapter 2 of the AMPL book, for example, you could proceed as follows:

ampl: model [diet.mod](; 
ampl: data [diet2a.dat](; 
ampl: option auxfiles rc; 
ampl: write mdiet2;

AMPL interprets write m... as indicating that you want to write an MPS file, and creates the filename by appending .mps to the letters after the m . Thus our example creates a file named diet2.mps. The format of this file is explained in the Linear Programming FAQ and in the manuals for many solvers.

Because MPS form limits the row (constraint or objective) and column (variable) names to 8 characters, AMPL substitutes artificial names such as R0001 and C0007 . You can ask for supplementary files of the true AMPL component names, by also resetting option auxfiles rc; in the above example, you would get files diet2.row and diet2.col. The ordering of the names in these files corresponds to their numbering in the MPS file. (For a more detailed description of write and the auxfiles option, see Sections A.18.3 and A.18.4 in the reference appendix to the AMPL book.)

An MPS file contains only the nonzero values that define one instance of your model. Thus an MPS file generated by AMPL is mainly useful as input to solvers that do not yet have a direct AMPL interface; because MPS form has been in use for a longer time than any comparable format, it is recognized by more solvers than any other file type. You may also find AMPL’s MPS-file option useful for generating new instances of test problems, for submission to libraries such as netlib’s lp/data or miplib. If you want to encourage people to use AMPL with your own solver, however, then you should consider hooking your solver to AMPL by use of AMPL’s file format, which takes less space, can be processed faster, represents numbers more accurately, and applies to a broader variety of optimization problems (especially nonlinear ones).