MPS2GMS

Translates an MPS or LP file into equivalent short generic GAMS and GAMSPy programs using a GDX file to store data. A number of solver specific extensions are recognized. If a DEC file is given, also decomposition information can be stored in the GDX file (stage attributes).

The MPS file is first attempted to be read in free format (no spaces in names). If it seems that row or column names have spaces but have at most 8 characters, parsing in fixed format is attempted. The MPS and LP readers of the HiGHS solver are utilized. GAMS Data Exchange (GDX) files and matching GAMS and GAMSPy source is written.

Notes:

  • Row, column, SOS (special ordered sets), and cone names can have up to 63 characters and are tested for case sensitivity and uniqueness because these names become GAMS set members. If the test fails, the tool attempts to modify the names. The original name, if not longer than 255 characters, can be stored in the explanatory text of the elements of sets i (for columns), j (for rows), and s (for SOS), by enabling option ORIGNAMES.
  • MPS files may contain multiple N rows. The first one will be used as objective function and remaining ones will be ignored.
  • If no optimization direction is given in a MPS file, minimization will be assumed.
  • Variables in SOS must be continuous.
  • SOS must not overlap. A variable cannot appear multiple times in the same SOS.

The MPS and LP formats have been extended in different forms by several solver vendors. Not all extensions are supported by MPS2GMS.

The following MPS sections are recognized by the free format parser:

  • NAME
  • OBJSENSE, MAX, MIN
  • ROWS
  • COLUMNS
  • RHS
  • BOUNDS
  • RANGES
  • QUADOBJ, QMATRIX
  • QSECTION, QCMATRIX
  • CSECTION with cone types QUAD and RQUAD
  • SETS, SOS
  • ENDATA

The fixed format parser also recognizes these sections except for QMATRIX, QSECTION, QCMATRIX, CSECTION, SETS, and SOS.

For a description of the MPS format, see also

The following LP format features are recognized:

  • Comments
  • Single objective function: linear or quadratic only
  • Constraints (Subject To section): linear or quadratic only
  • Variable bounds and types (Bounds, Binaries, Generals, Semis section); to specify semi-integer variables, they need to appear in sections Generals and Semis
  • Special ordered sets (SOS section)

For a description of the LP format, see also

A decomposition of the problem can be specified in GCG's DEC format. For example, for a standard form linear program, the corresponding block structure would have the form

\begin{align} \min\; & c^{-1} x_{-1} & + &\, c_0 x_0 \;+ && \cdots & c_{N-1}x_{N-1} \\ \text{s.t.}\; & T_{-1}x_{-1} & &&&&& = h_{-1} & (1) \\ & T_{0}x_{-1} &+ &\, W_{0}x_0 &&&& = h_0 & (2) \\ & T_{1}x_{-1} &+ && W_{1}x_1 &&& = h_1 & (3) \\ & \vdots & &&& \ddots && \vdots \\ & T_{N-1}x_{-1} &+ &&&& W_{N-1}x_{N-1} & = h_{N-1} & (4) \\ & U_{-1}x_{-1} &+ &\, U_0x_0 \;+ && \cdots & U_{N-1}x_{N-1} & = h_N & (5) \\ & x_{-1}, & & x_0, && \ldots & x_{N-1} & \geq 0 \end{align}

In the DEC file, either constraints or variable are assigned to blocks. Mixing decomposition info for constraints and variables is not supported. Section NBLOCKS specifies the number of regular blocks \(N\).

When specifying a decomposition via constraints, then constraints (2) to (4) are assigned to blocks \(0, \ldots, N-1\) via BLOCK, BLOCKCONS, or BLOCKCONSS sections. Constraints (5) can be listed in the MASTERCONSS section and will be given block label \(N\) by MPS2GMS. Any constraint that is not listed in the DEC file is assigned to \(N\) as well. Assigning to (1) is not possible by a DEC file that specifies a decomposition via constraints. From the assigned labels \(0, \ldots, N\) for the constraints, MPS2GMS assigns labels to variables such that matrices \(W_0,\ldots,W_{N-1}\) have as many columns as possible: Any variable that appears only in constraints of a block \(k\in\{0,\ldots,N-1\}\) and possibly in (5) is assigned to block \(k\). Any other variable (that is, appearing in constraints of at least two different blocks \(0,\ldots,N-1\), or appearing only in (5), or appearing in no constraint) is given label \(-1\).

When specifying a decomposition via variables, then variables are assigned to \(x_0,\ldots,x_{N-1}\), i.e., blocks \(0,\ldots,N-1\), via BLOCKVARS sections in the DEC file. Variables listed in sections MASTERVARS, MASTERVAR, LINKINGVARS, or LINKINGVAR are given block label \(-1\). Any variable that is not listed in the DEC file is assigned to \(-1\) as well. From the assigned labels \(-1, \ldots, N-1\) for the variables, MPS2GMS assigns labels to constraints such that matrices \(T_{-1}, W_0,\ldots,W_{N-1}\) have as many rows as possible: Any constraint that uses only variables with label \(-1\) ( \(x_{-1}\)) or no variable is given label \(-1\). Any constraint that uses variables from one block \(k\in\{0,\ldots,N-1\}\) and possibly label \(-1\) is assigned to block \(k\). Any other constraint (that is, using variables from at least two different blocks \(0,\ldots,N-1\)) is given label \(N\).

The variable that defines the objective function is assigned to block \(-1\). The constraint that defines the objective function is assigned to block \(N\).

The described labeling scheme generalizes logically to quadratic constraints, SOS, and discrete variables. The DEC sections CONSDEFAULTMASTER and PRESOLVED are ignored. Regarding SOS, block assignments are written to the GDX file in parameter stages, but the GAMS and GAMSPy programs do not pick these up (GAMS does not have stage attributes for SOS).

Since users of GAMS stage information often expect stages 1, 2, ..., a shift of 2 is applied to every block label, see also parameter STAGESHIFT. This way, linking variables will have stage 1.

Usage

mps2gms mpsfile | lpfile [ gdxfile [ gmsfile ] ] { key=value }

If the first parameter is not of the form key=value and ends with .lp or .lp.gz, it is assumed to be the name of an LP file, otherwise it is assumed to be the name of an MPS file. If no GDX filename is given, the name of the MPS or LP file is used, with .mps/.lp (or .mps.gz/.lp.gz) extension replaced by .gdx, or .gdx appended. If no GMS filename is given and the GMS option has not been set, the name of the GDX file is used, with .gdx extension replaced by .gms, or .gms appended. If the PY option has not been set, then the name of the GDX file is used, with .gdx extension replaced by .py, or .py appended.

Guide to parameters:

Key Description
MPS Name of MPS input file, can be compressed with GZIP
LP Name of LP input file, can be compressed with GZIP
DEC Name of DEC input file, can be compressed with GZIP
GDX Name of GDX output file
GMS Name of GAMS program output file. If explicitly set to be empty (GMS=), then the GAMS program is not written.
PY Name of GAMSPy program output file. If explicitly set to be empty (PY=), then the GAMSPy program is not written.
CEQUATIONS Whether to write quadratic cones from CSECTION sections into deprecated =C= equations. This option is deprecated.
Possible values: 0, N, 1, Y.
Default: 0
COLUMNINTVARSAREBINARY Whether integer variables that appear first in COLUMNS section should be assumed to be binary variables.
Possible values: 0, N, 1, Y.
Default: 0.
Note that modern solvers assume binary variables, but for backward compatibility the default is set to the original IBM interpretation.
DUPLICATES Whether to check and how to handle multiple coefficients for the same variable or product in LP files.
If set to NOCHECK, then no checks for multiple coefficients are done. In this case, writing the GDX file may fail. For performance reasons, this is the default.
If set to ADD, then coefficient are added up.
If set to IGNORE, then additional coefficients are ignored and a warning is printed to the log.
If set to ERROR, then warnings are printed to the log and MPS2GMS terminates with a nonzero return code.
ORIGNAMES Whether to make original names of columns, rows, and SOS available in texts of elements of sets i, j, and s, respectively.
If set to NO (default), original names are never stored in element texts.
If set to MODIFIED, original names are stored if the name has been changed.
If set to ALL, original names are stored for all columns, rows, and SOS.
STAGESHIFT Integer shift to add to block numbers when writing stage information.
Default: 2
CONVERTSENSE Whether to convert the objective function to ensure minimization (Y, 1, MIN) or maximization (-1, MAX) or preserve objective sense of input (0, N). Possible values: 0, N, 1, Y, MIN, -1, MAX. Default: 0