optimization

convertMps

Description

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.

optimization.convertMps <result=results> <status=rc> / casOut={casouttable} data={castable} format="FIXED" | "FREE" maxLength=integer;
Settings
ParameterDescription
casOutSpecifies the output data table that will be in the standard seven-column MPS format, ready to be used by solvers like `solveLp` or `solveMilp`.
dataSpecifies the input data table. This table should contain the MPS problem definition, with each row corresponding to a line from the original MPS file.
formatSpecifies 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.
maxLengthDefines the maximum length for variable and constraint names. The default is 8 characters, but this can be increased for problems with longer names.
Data Preparation View data prep sheet
Creating the Input Data Table

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.

Copied!
1DATA mycas.mps_free;
2 INFILE DATALINES;
3 INPUT id line $80.;
4 DATALINES;
51 NAME EXAMPLE
62 ROWS
73 N OBJ
84 L R1
95 G R2
106 COLUMNS
117 X1 OBJ 1
128 X1 R1 1
139 X2 OBJ 2
1410 X2 R1 1
1511 X2 R2 1
1612 RHS
1713 RHS1 R1 10
1814 RHS1 R2 5
1915 ENDATA
20;
21RUN;

Examples

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`.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3optimization.convertMps /
4DATA={name='mps_free'} FORMAT='FREE' casOut={name='mps_out', replace=true};
5 
6RUN;
7 
8QUIT;
9 
Result :
The action creates a new CAS table named `mps_out` in the active caslib. This table contains the optimization problem structured in the seven-column MPS format, ready to be used by solvers like `solveLp` or `solveMilp`.

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1 
2PROC CAS;
3optimization.convertMps /
4DATA={name='mps_free'} FORMAT='FREE' maxLength=12 casOut={name='mps_out_longnames', replace=true};
5 
6RUN;
7 
8QUIT;
9 
Result :
A new CAS table `mps_out_longnames` is created. The conversion process correctly handles names up to 12 characters long without truncation, ensuring the problem structure is preserved.

FAQ

What is the primary purpose of the convertMps action?
What are the required input and output parameters for the convertMps action?
How can you specify the format of the input data table?
What does the 'maxLength' parameter control in the convertMps action?