The OPTLP Procedure

Getting Started: OPTLP Procedure

The following example illustrates how you can use the OPTLP procedure to solve linear programs. Suppose you want to solve the following problem:

StartLayout 1st Row 1st Column min 2nd Column 2 x 1 3rd Column minus 4th Column 3 x 2 5th Column minus 6th Column 4 x 3 7th Column Blank 8th Column Blank 9th Column Blank 2nd Row 1st Column subject to 2nd Column Blank 3rd Column minus 4th Column 2 x 2 5th Column minus 6th Column 3 x 3 7th Column greater-than-or-equal-to 8th Column negative 5 9th Column left-parenthesis upper R 1 right-parenthesis 3rd Row 1st Column Blank 2nd Column x 1 3rd Column plus 4th Column x 2 5th Column plus 6th Column 2 x 3 7th Column less-than-or-equal-to 8th Column 4 9th Column left-parenthesis upper R 2 right-parenthesis 4th Row 1st Column Blank 2nd Column x 1 3rd Column plus 4th Column 2 x 2 5th Column plus 6th Column 3 x 3 7th Column less-than-or-equal-to 8th Column 7 9th Column left-parenthesis upper R 3 right-parenthesis 5th Row 1st Column Blank 2nd Column Blank 3rd Column Blank 4th Column x 1 comma 5th Column x 2 comma 6th Column x 3 7th Column greater-than-or-equal-to 8th Column 0 9th Column Blank EndLayout

The corresponding MPS-format SAS data set is as follows:

data example;
   input field1 $ field2 $ field3 $ field4 field5 $ field6;
   datalines;
NAME        .      EXAMPLE   .    .     .
ROWS        .      .         .    .     .
N           COST   .         .    .     .
G           R1     .         .    .     .
L           R2     .         .    .     .
L           R3     .         .    .     .
COLUMNS     .      .         .    .     .
.           X1     COST      2    R2    1
.           X1     R3        1    .     .
.           X2     COST     -3    R1   -2
.           X2     R2        1    R3    2
.           X3     COST     -4    R1   -3
.           X3     R2        2    R3    3
RHS         .      .         .    .     .
.           RHS    R1       -5    R2    4
.           RHS    R3        7    .     .
ENDATA      .      .         .    .     .
;

You can also create this data set from an MPS-format flat file (examp.mps) by using the following SAS macro:

%mps2sasd(mpsfile = "examp.mps", outdata = example);

Note: The SAS macro %MPS2SASD is provided in SAS Optimization software. See Converting an MPS/QPS-Format File: %MPS2SASD for details.

To make the created data set available on the CAS server, you need to upload it as in the following statements. At the same time, you also add an _id_ column to ensure that the MPS reader can read the file in the correct order even if it is distributed across several machines and hence loses the original ordering. For more information about the MPS-format, see Chapter 8, The MPS-Format Data Table.

data mylib.example;
   set example;
   _id_ = _n_;
run;

Alternatively, you can create the MPS data table directly in CAS and include the _id_ column in the datalines input.

You can use the following statement to call the OPTLP procedure:

title1 'The OPTLP Procedure';
proc optlp data = mylib.example
  objsense  = min
  presolver = automatic
  algorithm = primal
  primalout = mylib.expout
  dualout   = mylib.exdout;
run;

Note: The "N" designation for "COST" in the rows section of the data table example also specifies a minimization problem. See the section ROWS Section for details.

The optimal primal and dual solutions are stored in the data tables expout and exdout, respectively, and are displayed in Figure 1.

title2 'Primal Solution';
proc print data=mylib.expout label;
run;

title2 'Dual Solution';
proc print data=mylib.exdout label;
run;

Figure 1: Primal and Dual Solution Output

The OPTLP Procedure
Primal Solution

ObsObjective
Function ID
RHS IDVariable
Name
Variable
Type
Objective
Coefficient
Lower
Bound
Upper BoundVariable
Value
Variable
Status
Reduced
Cost
1COSTRHSX1N201.7977E3080.0L2.0
2COSTRHSX2N-301.7977E3082.5B0.0
3COSTRHSX3N-401.7977E3080.0L0.5

The OPTLP Procedure
Dual Solution

ObsObjective
Function ID
RHS IDConstraint
Name
Constraint
Type
Constraint
RHS
Constraint
Lower
Bound
Constraint
Upper
Bound
Dual SolutionConstraint
Status
Constraint
Activity
1COSTRHSR1G-5..1.5U-5.0
2COSTRHSR2L4..0.0B2.5
3COSTRHSR3L7..0.0B5.0


For details about the type and status codes displayed for variables and constraints, see the section Data Input and Output.

Last updated: June 22, 2026