The loadMps action loads a string that represents a problem in standard MPS (Mathematical Programming System) format into a CAS data table. This resulting data table is structured to be directly usable by optimization solvers within the SAS Viya platform, such as 'solveLp' for linear programming or 'solveMilp' for mixed-integer linear programming. It serves as a crucial bridge for importing optimization problems defined in this classic, widely-used format.
| Parameter | Description |
|---|---|
| casOut | Specifies the output data table that will be in MPS format, which can be passed to the solvers. |
| format | Specifies whether the contents of the mpsFileString parameter are in fixed or free format. Default is 'FIXED'. |
| maxLength | Specifies the maximum variable or constraint name length. The default is 8. |
| mpsFileString | Specifies the string that has the entire contents of a .mps file. |
The 'loadMps' action does not create data in a traditional sense but rather parses a string containing a full problem definition in MPS format. Below is an example of how to define a simple linear programming problem as a multi-line string in SAS.
| 1 | PROC CAS; |
| 2 | mps_string = " |
| 3 | * Simple LP problem; |
| 4 | NAME LpProblem |
| 5 | ROWS |
| 6 | N COST |
| 7 | L LIM1 |
| 8 | L LIM2 |
| 9 | G LIM3 |
| 10 | COLUMNS |
| 11 | X1 COST 2 |
| 12 | X1 LIM1 1 |
| 13 | X1 LIM2 1 |
| 14 | X2 COST 3 |
| 15 | X2 LIM1 1 |
| 16 | X2 LIM3 1 |
| 17 | X3 COST 4 |
| 18 | X3 LIM2 1 |
| 19 | X3 LIM3 1 |
| 20 | RHS |
| 21 | RHS LIM1 10 |
| 22 | RHS LIM2 5 |
| 23 | RHS LIM3 4 |
| 24 | ENDATA |
| 25 | "; |
| 26 | RUN; |
This example demonstrates how to load a simple linear programming problem, defined in a string variable, into a CAS table named 'mps_data' using the loadMps action. This table can then be used by other optimization actions.
| 1 | PROC CAS; |
| 2 | mps_string = " |
| 3 | NAME Example |
| 4 | ROWS |
| 5 | N OBJ |
| 6 | L R1 |
| 7 | L R2 |
| 8 | COLUMNS |
| 9 | X1 OBJ 1 |
| 10 | X1 R1 2 |
| 11 | X2 OBJ 2 |
| 12 | X2 R1 1 |
| 13 | X2 R2 5 |
| 14 | RHS |
| 15 | RHS1 R1 20 |
| 16 | RHS1 R2 10 |
| 17 | ENDATA |
| 18 | "; |
| 19 | optimization.loadMps / |
| 20 | casOut={name='mps_data', replace=true} |
| 21 | mpsFileString=mps_string; |
| 22 | RUN; |
This example shows loading an MPS problem using 'FREE' format and extending the maximum name length for variables and constraints to 32 characters. The output table 'mps_problem_free' is created in the 'casuser' caslib and will be promoted to global scope.
| 1 | PROC CAS; |
| 2 | mps_string = " |
| 3 | NAME A_MORE_COMPLEX_PROBLEM |
| 4 | ROWS |
| 5 | N TOTAL_PROFIT |
| 6 | L RESOURCE_LIMIT_A |
| 7 | L RESOURCE_LIMIT_B |
| 8 | COLUMNS |
| 9 | PRODUCT_ONE TOTAL_PROFIT 150.0 RESOURCE_LIMIT_A 10.0 |
| 10 | PRODUCT_ONE RESOURCE_LIMIT_B 25.0 |
| 11 | PRODUCT_TWO TOTAL_PROFIT 175.0 RESOURCE_LIMIT_A 12.5 |
| 12 | PRODUCT_TWO RESOURCE_LIMIT_B 18.0 |
| 13 | RHS |
| 14 | LIMITS RESOURCE_LIMIT_A 2000.0 |
| 15 | LIMITS RESOURCE_LIMIT_B 3500.0 |
| 16 | ENDATA |
| 17 | "; |
| 18 | optimization.loadMps / |
| 19 | casOut={name='mps_problem_free', caslib='casuser', replace=true, promote=true} |
| 20 | mpsFileString=mps_string |
| 21 | FORMAT='FREE' |
| 22 | maxLength=32; |
| 23 | RUN; |