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:

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

To make the created data set available in the CAS server, you need to upload it. At the same time, you also need to 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 9: The MPS-Format Data Table.

data mycas.ex_mip;
   set ex_mip;
   _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 also create this data set from an MPS format flat file (ex_mip.mps) by using the following SAS macro:

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

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

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

The DATA= option names the MPS format data table that contains the problem data. The OBJSENSE= option specifies whether to maximize or minimize the objective function. The PRIMALOUT= option names the data table to contain the optimal solution or the best feasible solution found by the solver. The DUALOUT= option names the data table 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 tables primal_out and dual_out, respectively, are displayed in Figure 7.1 and Figure 7.2.

Figure 7.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 7.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 7.3.

Figure 7.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.00 SOLUTION_TIME=0.00                                           


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

Last updated: June 14, 2018