The convertMps action is a utility function within the Optimization action set. It takes a CAS table that represents a mathematical optimization problem in a simple two-column format (typically read from a raw MPS file) and transforms it into a standard seven-column MPS-format CAS table. This resulting table is the required input format for other optimization solvers in SAS Viya, such as `solveLp`, `solveMilp`, and `solveQp`. This action is particularly useful when you have an MPS problem definition already loaded into a CAS table and need to prepare it for solving.
| Parameter | Description |
|---|---|
| casOut | Specifies the output data table that will be in the standard seven-column MPS format, ready to be used by solvers like `solveLp` or `solveMilp`. |
| data | Specifies the input data table. This table should contain the MPS problem definition, with each row corresponding to a line from the original MPS file. |
| format | Specifies whether the input data is in fixed-column or free-text format. 'FIXED' is for legacy MPS files with strict column alignments, while 'FREE' is more flexible and common for modern files. |
| maxLength | Defines the maximum length for variable and constraint names. The default is 8 characters, but this can be increased for problems with longer names. |
This example creates a simple two-column CAS table named `mps_free`. The first column, `id`, is a row identifier. The second column, `line`, contains the lines of a simple optimization problem in free-format MPS style.
| 1 | DATA mycas.mps_free; |
| 2 | INFILE DATALINES; |
| 3 | INPUT id line $80.; |
| 4 | DATALINES; |
| 5 | 1 NAME EXAMPLE |
| 6 | 2 ROWS |
| 7 | 3 N OBJ |
| 8 | 4 L R1 |
| 9 | 5 G R2 |
| 10 | 6 COLUMNS |
| 11 | 7 X1 OBJ 1 |
| 12 | 8 X1 R1 1 |
| 13 | 9 X2 OBJ 2 |
| 14 | 10 X2 R1 1 |
| 15 | 11 X2 R2 1 |
| 16 | 12 RHS |
| 17 | 13 RHS1 R1 10 |
| 18 | 14 RHS1 R2 5 |
| 19 | 15 ENDATA |
| 20 | ; |
| 21 | RUN; |
This example demonstrates the basic usage of the `convertMps` action. It converts the `mps_free` table (which is in free format) into a standard seven-column MPS-format CAS table named `mps_out`.
| 1 | |
| 2 | PROC CAS; |
| 3 | optimization.convertMps / |
| 4 | DATA={name='mps_free'} FORMAT='FREE' casOut={name='mps_out', replace=true}; |
| 5 | |
| 6 | RUN; |
| 7 | |
| 8 | QUIT; |
| 9 |
This example shows how to handle MPS data where variable or constraint names might be longer than the default 8 characters. The `maxLength` parameter is set to 12 to accommodate longer names during the conversion.
| 1 | |
| 2 | PROC CAS; |
| 3 | optimization.convertMps / |
| 4 | DATA={name='mps_free'} FORMAT='FREE' maxLength=12 casOut={name='mps_out_longnames', replace=true}; |
| 5 | |
| 6 | RUN; |
| 7 | |
| 8 | QUIT; |
| 9 |