The Linear Programming Solver

Getting Started: LP Solver

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

StartLayout 1st Row 1st Column max 2nd Column x 1 3rd Column plus 4th Column x 2 5th Column plus 6th Column x 3 7th Column Blank 8th Column Blank 2nd Row 1st Column subject to 2nd Column 3 x 1 3rd Column plus 4th Column 2 x 2 5th Column minus 6th Column x 3 7th Column less-than-or-equal-to 8th Column 1 3rd Row 1st Column Blank 2nd Column minus 2 x 1 3rd Column minus 4th Column 3 x 2 5th Column plus 6th Column 2 x 3 7th Column less-than-or-equal-to 8th Column 1 4th 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 EndLayout

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

proc optmodel;
   var x{i in 1..3} >= 0;
   max f =    x[1] +   x[2] +   x[3];
   con c1:  3*x[1] + 2*x[2] -   x[3] <= 1;
   con c2: -2*x[1] - 3*x[2] + 2*x[3] <= 1;
   solve with lp / algorithm = ps presolver = none logfreq = 1;
   print x;
quit;

The optimal solution and the optimal objective value are displayed in Figure 1.

Figure 1: Solution Summary

The OPTMODEL Procedure

Problem Summary
Objective SenseMaximization
Objective Functionf
Objective TypeLinear
  
Number of Variables3
Bounded Above0
Bounded Below3
Bounded Below and Above0
Free0
Fixed0
  
Number of Constraints2
Linear LE (<=)2
Linear EQ (=)0
Linear GE (>=)0
Linear Range0
  
Constraint Coefficients6

Solution Summary
SolverLP
AlgorithmPrimal Simplex
Objective Functionf
Solution StatusOptimal
Objective Value8
  
Primal Infeasibility0
Dual Infeasibility8.881784E-16
Bound Infeasibility0
  
Iterations4
Presolve Time0.01
Solution Time0.02

[1]x
10
23
35


The iteration log displaying problem statistics, progress of the solution, and the optimal objective value is shown in Figure 2.

Figure 2: Log

NOTE: Problem generation will use 12 threads.                                   
NOTE: The problem has 3 variables (0 free, 0 fixed).                            
NOTE: The problem has 2 linear constraints (2 LE, 0 EQ, 0 GE, 0 range).         
NOTE: The problem has 6 linear constraint coefficients.                         
NOTE: The problem has 0 nonlinear constraints (0 LE, 0 EQ, 0 GE, 0 range).      
NOTE: The LP presolver value NONE is applied.                                   
NOTE: The LP solver is called.                                                  
NOTE: The Primal Simplex algorithm is used.                                     
                           Objective                Entering      Leaving       
      Phase Iteration        Value         Time     Variable      Variable      
       P 2          1    0.000000E+00         0       x[1]             c1 (S)   
       P 2          2    3.333333E-01         0       x[3]             c2 (S)   
       P 2          3    2.000000E+00         0       x[2]           x[1]       
       P 2          4    8.000000E+00         0                                 
NOTE: Optimal.                                                                  
NOTE: Objective = 8.                                                            
NOTE: The Primal Simplex solve time is 0.00 seconds.                            


Last updated: June 22, 2026