The OPTMILP Procedure

Getting Started: OPTMILP Procedure

The following example illustrates the use of the OPTMILP procedure to solve mixed integer linear programs. For more examples, see the section Examples: OPTMILP Procedure. 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 s period t period 2nd Column Blank 3rd Column minus 4th Column 2 x 2 5th Column minus 6th Column 3 x 3 7th Column greater than or equals 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 equals 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 equals 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 equals 8th Column 0 9th Column Blank 6th 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 element of double struck upper Z 8th Column Blank 9th Column Blank EndLayout

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

data ex_mip;
   input field1 $ field2 $ field3 $ field4 field5 $ field6;
   datalines;
NAME        .      EX_MIP      .   .        .
ROWS        .        .         .   .        .
N           COST     .         .   .        .
G           R1       .         .   .        .
L           R2       .         .   .        .
L           R3       .         .   .        .
COLUMNS     .        .         .   .        .
.           MARK00 'MARKER'    .   'INTORG' .
.           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
.           MARK01 'MARKER'    .   'INTEND' .
RHS         .      .           .   .        .
.           RHS    R1         -5   R2       4
.           RHS    R3          7   .        .
ENDATA      .      .           .   .        .
;

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

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

This problem can be solved by using the following statement to call the OPTMILP procedure:

proc optmilp data = ex_mip
   objsense   = min
   primalout  = primal_out
   dualout    = dual_out
   presolver  = automatic
   heuristics = automatic;
run;

The DATA= option names the MPS-format SAS data set that contains the problem data. The OBJSENSE= option specifies whether to maximize or minimize the objective function. The PRIMALOUT= option names the SAS data set to contain the optimal solution or the best feasible solution found by the solver. The DUALOUT= option names the SAS data set to contain the constraint activities. The PRESOLVER= and HEURISTICS= options specify the levels for presolving and applying heuristics, respectively. In this example, each option is set to its default value AUTOMATIC, meaning that the solver automatically determines the appropriate levels for presolve and heuristics.

The optimal integer solution and its corresponding constraint activities, stored in the data sets primal_out and dual_out, respectively, are displayed in Figure 1 and Figure 2.

Figure 1: Optimal Solution

The OPTMILP Procedure
Primal Integer Solution

ObsObjective
Function ID
RHS IDVariable
Name
Variable
Type
Objective
Coefficient
Lower
Bound
Upper
Bound
Variable
Value
Solution
1COSTRHSX1B20101
2COSTRHSX2B-30111
3COSTRHSX3B-40111


Figure 2: Constraint Activities

The OPTMILP Procedure
Constraint Information

ObsObjective
Function ID
RHS IDConstraint
Name
Constraint
Type
Constraint
RHS
Constraint
Lower
Bound
Constraint
Upper
Bound
Constraint
Activity
Solution
1COSTRHSR1G-5..-51
2COSTRHSR2L4..31
3COSTRHSR3L7..51


The solution summary stored in the macro variable _OROPTMILP_ can be viewed by issuing the following statement:

   %put &_OROPTMILP_;

This produces the output shown in Figure 3.

Figure 3: Macro Output

STATUS=OK ALGORITHM=BAC SOLUTION_STATUS=OPTIMAL OBJECTIVE=-7 RELATIVE_GAP=0     
ABSOLUTE_GAP=0 PRIMAL_INFEASIBILITY=0 BOUND_INFEASIBILITY=0                     
INTEGER_INFEASIBILITY=0 BEST_BOUND=-7 NODES=0 SOLUTIONS_FOUND=2 ITERATIONS=0    
PRESOLVE_TIME=0.01 SOLUTION_TIME=0.01                                           


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

Last updated: October 07, 2022