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:
You can use the following statement 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 / solver = ps presolver = none printfreq = 1;
print x;
quit;
The optimal solution and the optimal objective value are displayed in Figure 10.1.
Figure 10.1
Solution Summary
Maximization |
f |
Linear |
|
3 |
0 |
3 |
0 |
0 |
0 |
|
2 |
2 |
0 |
0 |
0 |
Primal Simplex |
f |
Optimal |
8 |
3 |
|
0 |
0 |
0 |
The iteration log displaying problem statistics, progress of the solution, and the optimal objective value is shown in Figure 10.2.
Figure 10.2
Log
|
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 OPTMODEL presolver removed 0 variables, 0 linear constraints, and 0 |
nonlinear constraints. |
WARNING: No output destinations active. |
NOTE: The OPTLP presolver value NONE is applied. |
NOTE: The PRIMAL SIMPLEX solver is called. |
Objective Entering Leaving |
Phase Iteration Value Variable Variable |
2 1 0.500000 x[3] c2 (S) |
2 2 8.000000 x[2] c1 (S) |
NOTE: Optimal. |
NOTE: Objective = 8. |
|
|
Copyright © SAS Institute, Inc. All Rights Reserved.