The Mixed Integer Linear Programming Solver

Getting Started: MILP Solver

The following example illustrates the use of the OPTMODEL procedure to solve mixed integer linear programs. For more examples, see the section Examples: MILP Solver. 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-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 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

You can use the following statements to call the OPTMODEL procedure for solving mixed integer linear programs:

proc optmodel;
   var x{1..3} >= 0 integer;

   min f = 2*x[1] - 3*x[2] - 4*x[3];

   con r1: -2*x[2] - 3*x[3] >= -5;
   con r2: x[1] + x[2] + 2*x[3] <= 4;
   con r3: x[1] + 2*x[2] + 3*x[3] <= 7;

   solve with milp / presolver = automatic heuristics = automatic;
   print x;
quit;

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 value of x is shown in Figure 1.

Figure 1: Solution Output

The OPTMODEL Procedure

[1]x
10
21
31


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

%put &_OROPTMODEL_;

This statement produces the output shown in Figure 2.

Figure 2: 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=1 SOLUTIONS_FOUND=2 ITERATIONS=3    
PRESOLVE_TIME=0.00 SOLUTION_TIME=0.03                                           


Last updated: June 04, 2025