Records in MPS format
CPLEX supports indicator records and data records in MPS file format.
MPS data files are analogous to a deck of computer input cards: each line of the MPS file represents a single card record. Records in an MPS data file consist of two types: indicator records and data records. The records contain fields delimited by blank spaces.
Indicator records
Indicator records separate the individual sections of the MPS file. Each indicator record contains a single word that begins in the first column. There are seven kinds of indicator records, each corresponding to sections of the MPS file. They are listed in Table 1.
Section name/indicator record | Purpose |
---|---|
NAME | specifies the problem name; unlike other indicator records, the name record contains data |
ROWS | specifies name and sense for each constraint |
COLUMNS | specifies the name assigned to each variable (column) and the nonzero constraint coefficients corresponding to that variable |
RHS | specifies the names of righthand side vectors and values for each constraint (row) |
RANGES | specifies constraints that are restricted to lie in the interval between two values; interval endpoints are also specified |
BOUNDS | specifies the limits within which each variable (column) must remain |
ENDATA | signals the end of the data; always the last entry in an MPS file |
Each section of the MPS file except the RANGES and BOUNDS sections is mandatory. If no BOUNDS section is present, all variables have their bounds set from 0 (zero) to +∞ (positive infinity). Failure to include an RHS section causes CPLEX to generate a warning message and set all righthand side values to 0 (zero). Variables and constraints must be declared in the ROWS and COLUMNS sections before they are referenced in the RHS , RANGES , and BOUNDS sections.
Data records
Data records contain the information that describes the LP problem. Each data record comprises six fields, as in Table 2. The fields must be separated by white space (that is, blank space, tab, etc.), and the first field must begin in column 2 or beyond. Not all fields are used within each section of the input file.
Field 1 | Field 2 | Field 3 | Field 4 | Field 5 | Field 6 | |
---|---|---|---|---|---|---|
Contents | Indicator | Name | Name | Value | Name | Value |
Any ASCII character (32 through 126) is legal, but names must contain no embedded blanks. In addition, names over 255 characters are truncated. CPLEX issues an error message if truncation causes the names to lose their uniqueness. Numeric fields can be at most 25 characters long.
If the first character in Field 3 or 5 is a dollar sign ($), the remaining characters in the record are treated as a comment. Another method for inserting comments is to place an asterisk (*) in column 1. Everything on such a line is treated as a comment.
Values may be defined with decimal or exponential notation and may use 25 characters. In exponential notation, plus (+) and minus (-) signs must precede the exponent value. If an exponent value is missing where one is expected, it is assigned a value of 0 (zero).
The ROWS section
In the ROWS section, each row of the problem is specified with its name and sense, one row per record.
Field 1 contains a single letter designating the sense of each row. Acceptable values are:
N indicates a free row.
G indicates a greater-than-or-equal-to row.
L indicates a less-than-or-equal-to row.
E indicates an equality row.
Field 2 contains a character identifier, maximum length of 255 characters, specifying the name of the row.
Fields 3-6 are not used in the ROWS section.
If more than one free row is specified, the first one is used as the objective function and the others are discarded.
The ROWS section of our example looks like this:
ROWS
N obj
L c1
L c2
The COLUMNS section
In the COLUMNS section, all the columns of the constraint matrix are specified with their name and all of the nonzero elements. Multiple records may be required to completely specify a given column.
Field 1: Blank
Field 2: Column identifier
Field 3: Row identifier
Field 4: Value of matrix coefficient specified by Fields 2 and 3
Field 5: Row identifier (optional)
Field 6: Value of matrix coefficient specified by Fields 2 and 5 (optional)
After a matrix element is specified for a column, all other nonzero elements in that same column should be specified.
The COLUMNS section of our example looks like this:
COLUMNS
x1 obj -1 c1 -1
x1 c2 1
x2 obj -2 c1 1
x2 c2 -3
x3 obj -3 c1 1
x3 c2 1
The RHS section
In the RHS section, the nonzero righthand-side values of the constraints are specified.
Field 1: Blank
Field 2: RHS identifier
Field 3: Row identifier
Field 4: Value of RHS coefficient specified by Field 2 and 3
Field 5: Row identifier (optional)
Field 6: Value of RHS coefficient specified by Field 2 and 5 (optional)
Several RHS vectors can exist. The name of each RHS vector appears in Field 2. However, only the first RHS vector is selected when a problem is read. Additional RHS vectors are discarded.
The RHS section of our example looks like this:
RHS
rhs c1 20 c2 30
rhs obj -3.1415
Notice particularly the reversal of the sign from 3.1415 to -3.1415.The RANGES section
In the RANGES section, RHS range values to be applied to constraints may be specified.
Field 1: Blank
Field 2: Righthand side range vector identifier
Field 3: Row identifier
Field 4: Value of the range applied to row specified by Field 3
Field 5: Row identifier (optional)
Field 6: Value of the range applied to row specified by Field 5 (optional)
The effect of specifying a righthand side range depends on the sense of the specified row and whether the range has a positive or negative coefficient. Table 3 specifies how range values are interpreted. For a given row, rhs is the righthand side value and range is the corresponding range value.
Row type | Range value sign | Resulting rhs upper limit | Resulting rhs lower limit |
---|---|---|---|
G | + or - | rhs + |range| | rhs |
L | + or - | rhs | rhs - |range| |
E | + | rhs + range | rhs |
E | - | rhs | rhs + range |
The name of each range vector appears in Field 2. More than one range vector can be specified within an MPS file. However, only the first range vector is selected when a problem is read. Additional range vectors are discarded.
In our example, there are no ranged rows, but suppose we want to add the following constraint to our problem:
x1 - 3x2 + x3 >= 15
Instead of explicitly adding another row to the problem, we can represent this additional constraint by modifying row 2 of the example to make it a ranged row in this way:
15 <= x1 - 3x2 + x3 <= 30
The RANGES section of the MPS file to support this modification looks like this:
RANGES
rhs c2 15
The name of each range vector appears in Field 2. However, only the first range vector is selected when a problem is read. Additional range vectors are discarded.
The BOUNDS section
In the BOUNDS section, bound values for variables may be specified.
Field 1: Type of bound. Acceptable values are:
LO Lower bound
LI Lower bound, integer
UP Upper bound
UI Upper bound, integer
FX Fixed value (upper and lower bound the same)
FR Free variable (lower bound -∞ and upper bound +∞)
MI Minus infinity (lower bound = -∞)
PL Plus infinity (upper bound = +∞)
BV Binary variable, integer (0 or 1)
SC Upper bound of a semi-continuous variable, see What are semi-continuous variables?
Field 2: Bound identifier
Field 3: Column identifier to be bounded
Field 4: Value of the specified bound
Fields 5 and 6 are not used in the BOUNDS section.
In our example, the BOUNDS section looks like this:
BOUNDS
UP BOUND x1 40
If no bounds are specified, CPLEX assumes a lower bound of 0 (zero) and an upper bound of +∞. If only a single bound is specified, the unspecified bound remains at 0 or +∞, whichever applies, with one exception. If an upper bound of less than 0 is specified and no other bound is specified, the lower bound is automatically set to -∞. CPLEX deviates slightly from a convention used by some MPS readers when it encounters an upper bound of 0 (zero). Rather than automatically set this variable’s lower bound to -∞, CPLEX accepts both a lower and upper bound of 0, effectively fixing that variable at 0. CPLEX resets the lower bound to -∞ only if the upper bound is less than 0. A warning message is issued when this exception is encountered.
More than one bound vector may exist. The name of each bound vector appears in Field 2. However, only the first bound vector is selected when a problem is read. Additional bound vectors are discarded.
Each of the bound types above specify the lower bound, the upper bound, or both, for a specific variable. CPLEX will reject an MPS file in which there is a variable for which multiple lower (or multiple upper) bounds are specified. For example, since FX specifies both the lower and upper bounds for a variable, it is invalid to have both an UP and an FX bound type for a variable (as there would be two upper bound specifications).