Write and run SAS programs in your web browser

Linear programming in SAS

Reply
New Contributor
Posts: 2

Linear programming in SAS

hello, I've been trying to resolve the next linear programming problem...but, what I only got is an error:

 

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

proc optmodel;
ERROR: Procedure OPTMODEL not found.
 
var x1 integer =>0;
var x2 integer =>0;
 
maximize z=3*x1+5*x2;
 
con c1: 3*x1-2*x2<=10;
con c2: 5*x1+10*x2<=56;
 
solve;
 
print x1 x2;
 
quit;
 
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDIMIENTO OPTMODEL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 
 
can you please help me..I dont know where I'm wrong. Thanks
 
franklin
Grand Advisor
Posts: 16,315

Re: Linear programming in SAS

Are you using SAS UE? If so, I don't think proc optmodel is included. 

It falls under SAS/OR which is not part of SAS UE. 

New Contributor
Posts: 2

Re: Linear programming in SAS

Yes I do 

SAS Super FREQ
Posts: 3,225

Re: Linear programming in SAS

[ Edited ]

If you are using SAS University Edition, then you have access to SAS/IML, which supports linear programming (LP) and mixed-integer LP. . Use the MILPSOLVE subroutine, as follows

 

/* Problem: x is a vector of integers 0 <= x[i] <= 10 
maximize c*x = 3*x1 + 5*x2
subject to 
A*x SYMBOL b 
where SYMBOL is a vector of symbols that indicate <=, =, or >=
*/
proc optmodel;
var x{i in 1..2} integer >= 0;
max z = 3*x[1] +  5*x[2];
con c1: 3*x[1] + -2*x[2] <= 10;
con c2: 5*x[1] + 10*x[2] <= 56;
solve with milp;
print x;
quit;

proc iml;
/* information about variables (row of column, doesn't matter) */
colType = {I, I};  /* variables are integers */
LowerB =  {0, 0};  /* lower bound contraints on x */
UpperB = {10,10};  /* upper bound contraints on x */

/* objective function */
c = {3 5};        /* vector for objective function c*x */

/* linear constraints */
A = {3 -2,        /* matrix of contraint coefficients */
     5 10};
b = {10,          /* RHS of constraint eqns (column vector) */
     56};         

/* specify symbols for constraints:
   'L' for less than or equal
   'E' for equal
   'G' for greater than or equal */
LEG = {L, L}; 

/* control vector for optimization */
ctrl = {-1,       /* maximize objective */
         1};      /* print level */

CALL MILPSOLVE(rc, objVal, result, relgap, /* output variables */
               c, A, b,      /* objective and linear constraints */
               ctrl,         /* control vector */
               coltype, LEG, /*range*/, LowerB, UpperB); 
print rc objVal relgap, result[rowname={x1 x2}];

 

Post a Question
Discussion Stats
  • 3 replies
  • 116 views
  • 0 likes
  • 3 in conversation