The MPS Data Format


The MPS data format is an industry standard for the description of a variety of linear programming problems.

Reference:

  1. Bruce Murtagh,
    Advanced Linear Programming: Computation and Practice,
    McGraw-Hill, 1981.
  2. J L Nazareth,
    Computer Solution of Linear Programs,
    Monographs on Numerical Analysis,
    Oxford University Press, 1996.

An MPS file is organized into named sections, which appear in the following order:

  1. NAME
  2. ROWS
  3. COLUMNS
  4. RHS
  5. RANGES (optional)
  6. BOUNDS (optional)
  7. ENDATA
Each section begins with a single line containing the name of the section in the Indicator field, and may be followed by a number of data lines, which have a very particular format.

An MPS file may also have comment lines. Such lines may occur anywhere in the file. They begin with an asterisk '*' in column 1. They may contain information intended to explain the problem, or other facts of interest to a human, and of no interest to a program parsing the file.

The data lines of an MPS file are divided into fields of a specific width:
  Field 1Field 2Field 3 Field 4Field 5Field 6
Columns 2-35-1215-22 25-3640-4750-61
Contents IndicatorName 1Name 2 Value 1Name 3Value 2
Indicator and Name fields contain names of things; Value fields contain numeric values. The particular use of these fields depends on the section in which the data line occurs.

We now discuss in detail the format of the data lines that occur in each data section.

  1. NAME: This section consists of just one card, with the word NAME in columns 1-4, and the title of the problem in columns 15-22.
  2. ROWS: In this section all the row labels are defined, as well as the row type. The row type is entered in field 1 (in column 2 or 3) and the row label is entered in field 2 (columns 5-12).

    The code for specifying row type is as follows:
    TypeSymbolMeaning
    = EEqual to.
    < LLess than or equal to.
    > GGreater than or equal to.
    ObjectiveNObjective function.
    Free NNo restriction imposed.

    This section of data begins with a card with ROWS in columns 1-4, followed by a data card for each row. The first N-type row encountered is regarded as the objective function.

    Linear combinations of rows may also be specified. In this case, the above row types are denoted respectively by the codes DE, DL, DG, and DN, in columns 2-3. Field 2 contains the linear combination rowname. Fields 3-6 contain the rowname(s) in fields 3 and 5, and their multiplier(s) in fields 4 and 6. A linear combination of three or more rows requires additional cards, following the first card contiguously. In the additional cards, field 1 is empty. The right-hand sides of a linear combination row must be specified in the RHS section, described below.

  3. COLUMNS: This section defines the names of the variable, the coefficients of the objective, and all the nonzero matrix elements Ai,j. The data is entered column by column, and all the data cards for the nonzero entries in each column must be grouped contiguously. The section begins with a card with COLUMNS in columns 1-7, followed by data cards which may have one or two matrix elements per card.

    The data card has the column label in field 2 (columns 5-12), the row label in field 3 (columns 15-22), and the value of the coefficient Ai,j or Cj in field 4 (columns 25-36), including a decimal point). If more than one nonzero row entry for the same column is to be made on the card, then field 5 (columns 40-47) has the next row label and field 6 (columns 50-61) has its corresponding coefficient value. The use of fields 5 and 6 is optional.

    There is no need to specify columns for slack variables; this is taken care of automatically, based on the definitions of the row types.

  4. RHS: This section contains the elements of the right-hand side. The section begins with a card with RHS in columns 1-3. Since the right-hand side can be regarded as another column of the matrix, the data cards specifying the nonzero entries are in exactly the same format as the COLUMNS data cards, except that field 2 (columns 5-12) has a label for the right-hand side. More than one right-hand side may thus be specified in this section.
  5. RANGES: (optional). This section is for constraints of the form:
    hi <= Ai,1x1 + Ai,2x2 + ... + Ai,nxn <= ui
    that is, both an upper and lower bound are specified for the row. The range of the constraint is
    ri = ui - hi
    The value of ui or hi is specified in the RHS section data, and the value of ri is specified in the RANGES section data. This information, plus the row type specified in the ROWS section, defines the bounds ui and hi.

    If bi is the number entered in the RHS section and ri is the number specified in the RANGES section, the ui and hi are defined as follows:
    Row Symbol Meaning Sign of ri Lower limit hi Upper limit ui
    G >= + or - bi bi+|ri|
    L <= + or - bi-|ri| bi
    E = + bi bi+|ri|
    E = - bi-|ri| bi

    The section begins with a card with RANGES in columns 1-6. The data cards specifying the values of ri are in exactly the same format as the COLUMNS data cards, except that field 2 (columns 5-12) has a label for the column of ranges (which can also be regarded as another column of the matrix). More than one column of ranges may be specified, but all the data cards for each column must be grouped contiguously.

  6. BOUNDS: (optional). In this section, bounds on the variables are specified. The section begins with a card with BOUNDS in columns 1-6. The bounds are entered as a row, with a corresponding row label. The nonzero entries in this row vector correspond to columns in the matrix and must be in the same order in which the column names appear in the COLUMNS section. When bounds are not specified for a column, or if the entire BOUNDS section is omitted, the usual bounds are assumed,
    0 <= xj < infinity

    More than one bound for a particular variable may be entered, that is, both a lower and an upper bound; when only one bound is specified the other is assumed to be one of the default values of 0 or infinity as shown in parentheses below.

  7. ENDATA: This section is just one card, with ENDATA in columns 1-6, signalling the end of input.

Example: the file afiro.mps.


NAME          AFIRO                                                  
ROWS
 E  R09     
 E  R10     
 L  X05     
 L  X21     
 E  R12     
 E  R13     
 L  X17     
 L  X18     
 L  X19     
 L  X20     
 E  R19     
 E  R20     
 L  X27     
 L  X44     
 E  R22     
 E  R23     
 L  X40     
 L  X41     
 L  X42     
 L  X43     
 L  X45     
 L  X46     
 L  X47     
 L  X48     
 L  X49     
 L  X50     
 L  X51     
 N  COST    
COLUMNS
    X01       X48               .301   R09                -1.   
    X01       R10              -1.06   X05                 1.   
    X02       X21                -1.   R09                 1.   
    X02       COST               -.4   
    X03       X46                -1.   R09                 1.   
    X04       X50                 1.   R10                 1.   
    X06       X49               .301   R12                -1.   
    X06       R13              -1.06   X17                 1.   
    X07       X49               .313   R12                -1.   
    X07       R13              -1.06   X18                 1.   
    X08       X49               .313   R12                -1.   
    X08       R13               -.96   X19                 1.   
    X09       X49               .326   R12                -1.   
    X09       R13               -.86   X20                 1.   
    X10       X45              2.364   X17                -1.   
    X11       X45              2.386   X18                -1.   
    X12       X45              2.408   X19                -1.   
    X13       X45              2.429   X20                -1.   
    X14       X21                1.4   R12                 1.   
    X14       COST              -.32   
    X15       X47                -1.   R12                 1.   
    X16       X51                 1.   R13                 1.   
    X22       X46               .109   R19                -1.   
    X22       R20               -.43   X27                 1.   
    X23       X44                -1.   R19                 1.   
    X23       COST               -.6   
    X24       X48                -1.   R19                 1.   
    X25       X45                -1.   R19                 1.   
    X26       X50                 1.   R20                 1.   
    X28       X47               .109   R22               -.43   
    X28       R23                 1.   X40                 1.   
    X29       X47               .108   R22               -.43   
    X29       R23                 1.   X41                 1.   
    X30       X47               .108   R22               -.39   
    X30       R23                 1.   X42                 1.   
    X31       X47               .107   R22               -.37   
    X31       R23                 1.   X43                 1.   
    X32       X45              2.191   X40                -1.   
    X33       X45              2.219   X41                -1.   
    X34       X45              2.249   X42                -1.   
    X35       X45              2.279   X43                -1.   
    X36       X44                1.4   R23                -1.   
    X36       COST              -.48   
    X37       X49                -1.   R23                 1.   
    X38       X51                 1.   R22                 1.   
    X39       R23                 1.   COST               10.   
RHS
    B         X50               310.   X51               300.   
    B         X05                80.   X17                80.   
    B         X27               500.   R23                44.   
    B         X40               500.   
ENDATA

You can return to the HTML web page.


Last revised on 02 August 2006.