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

**URL:** <https://discuss.ampl.com/t/how-do-i-write-an-mps-file-for-my-problem/74>\
**Category:** FAQs\
**Tags:** files-preprocessing\
**Created:** [December 15, 2021, 6:00pm UTC](https://discuss.ampl.com/t/how-do-i-write-an-mps-file-for-my-problem/74 "2021-12-15T18:00:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![megrobert](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@megrobert](https://discuss.ampl.com/u/megrobert)\
**Post date:** [December 15, 2021, 6:00pm UTC](https://discuss.ampl.com/t/how-do-i-write-an-mps-file-for-my-problem/74/1 "2021-12-15T18:00:44Z")

</div>

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](https://ampl.com/BOOK/CHAPTERS/05-tut2.pdf) of the [AMPL book](https://ampl.com/resources/the-ampl-book/), for example, you could proceed as follows:

```auto
ampl: model [diet.mod](https://ampl.com/BOOK/EXAMPLES/EXAMPLES2/diet.mod); 
ampl: data [diet2a.dat](https://ampl.com/BOOK/EXAMPLES/EXAMPLES2/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](https://ampl.com/FAQ/diet2.mps). The format of this file is explained in the [Linear Programming FAQ](http://www.neos-guide.org/lp-faq) and in the manuals for many [solvers](https://ampl.com/resources/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](https://ampl.com/FAQ/diet2.row) and [diet2.col](https://ampl.com/FAQ/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](https://ampl.com/BOOK/CHAPTERS/24-refman.pdf#page=35) and [A.18.4](https://ampl.com/BOOK/CHAPTERS/24-refman.pdf#page=35) in the reference appendix to the [AMPL book](https://ampl.com/resources/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](http://www.netlib.org/lp/index.html) or [miplib](http://miplib.zib.de/). If you want to encourage people to use AMPL with your own solver, however, then you should consider [hooking your solver to AMPL](https://ampl.com/resources/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).
