optimization

loadMps

Description

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.

optimization.loadMps result=<results> status=<rc> / casOut={caslib="string", compress=TRUE | FALSE, indexVars={"variable-name-1" <, "variable-name-2", ...>}, label="string", lifetime=64-bit-integer, maxMemSize=64-bit-integer, memoryFormat="DVR" | "INHERIT" | "STANDARD", name="table-name", promote=TRUE | FALSE, replace=TRUE | FALSE, replication=integer, tableRedistUpPolicy="DEFER" | "NOREDIST" | "REBALANCE", threadBlockSize=64-bit-integer, timeStamp="string", where={"string-1" <, "string-2", ...>}}, format="FIXED" | "FREE", maxLength=integer, mpsFileString="string";
Settings
ParameterDescription
casOutSpecifies the output data table that will be in MPS format, which can be passed to the solvers.
formatSpecifies whether the contents of the mpsFileString parameter are in fixed or free format. Default is 'FIXED'.
maxLengthSpecifies the maximum variable or constraint name length. The default is 8.
mpsFileStringSpecifies the string that has the entire contents of a .mps file.
Data Preparation View data prep sheet
Defining an MPS Problem as a String

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.

Copied!
1PROC CAS;
2 mps_string = "
3* Simple LP problem;
4NAME LpProblem
5ROWS
6 N COST
7 L LIM1
8 L LIM2
9 G LIM3
10COLUMNS
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
20RHS
21 RHS LIM1 10
22 RHS LIM2 5
23 RHS LIM3 4
24ENDATA
25";
26RUN;

Examples

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 mps_string = "
3NAME Example
4ROWS
5 N OBJ
6 L R1
7 L R2
8COLUMNS
9 X1 OBJ 1
10 X1 R1 2
11 X2 OBJ 2
12 X2 R1 1
13 X2 R2 5
14RHS
15 RHS1 R1 20
16 RHS1 R2 10
17ENDATA
18";
19 optimization.loadMps /
20 casOut={name='mps_data', replace=true}
21 mpsFileString=mps_string;
22RUN;
Result :
The action creates a CAS table named 'mps_data' in the active caslib. The table contains the problem 'Example' in a structured format ready for a solver. A confirmation message indicating the successful creation of the output table will be displayed in the logs.

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.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 mps_string = "
3NAME A_MORE_COMPLEX_PROBLEM
4ROWS
5 N TOTAL_PROFIT
6 L RESOURCE_LIMIT_A
7 L RESOURCE_LIMIT_B
8COLUMNS
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
13RHS
14 LIMITS RESOURCE_LIMIT_A 2000.0
15 LIMITS RESOURCE_LIMIT_B 3500.0
16ENDATA
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;
23RUN;
Result :
A global CAS table named 'mps_problem_free' is created in the 'casuser' caslib. The logs will confirm the creation and promotion of this table, which now contains the problem data parsed from the free-format MPS string.

FAQ

What is the purpose of the optimization.loadMps action?
What parameters are available for the loadMps action?
How do you specify the output table for the loadMps action?
What are the possible values for the 'format' parameter?
What is the role of the 'mpsFileString' parameter?