Operations Research topics: SAS/OR,
SAS Optimization, and SAS Simulation Studio

Linear programming in SAS

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 85
Accepted Solution

Linear programming in SAS

Hi,

 

I want to solve a linear programming problem in SAS. I am using proc optmodel.

The relation between objective var and input var is not lineal and the procedure doesn't work in that kind of relationship.

This is my code, can anybody help me?. Any advice will be greatly appreciated

 

/* I want to know the mix pub1 + pub2 thar maximaces sales */

proc optmodel;
/* declare variables */
var pub1 >= 0, pub2 >= 0;

/* maximize objective function */
maximize sale = 3*pub1 - 0.15*pub1*pub1 + 1.5*pub2 - 0.05*pub2*pub2;

/* subject to constraints */
con process1: pub1 + pub2 = 10;
/* solve LP using primal simplex solver */
solve with milp / presolver=none;

/* display solution */
print pub1 pub2;
quit;

 


Accepted Solutions
Solution
‎10-22-2016 07:01 PM
SAS Employee
Posts: 414

Re: Linear programming in SAS

First note that your SOLVE statement invokes the MILP solver, not the LP solver.  But both MILP and LP require a linear objective.  For your problem with a quadratic objective and linear constraints, use instead the QP solver:

http://support.sas.com/documentation/cdl/en/ormpug/68156/HTML/default/viewer.htm#ormpug_qpsolver_toc...

 

SOLVE WITH QP;

 

or just:

 

SOLVE;

 

The optimal objective value turns out to be 17.8125, with optimal solution:

 

pub1 pub2
6.25 3.75

 

View solution in original post


All Replies
Solution
‎10-22-2016 07:01 PM
SAS Employee
Posts: 414

Re: Linear programming in SAS

First note that your SOLVE statement invokes the MILP solver, not the LP solver.  But both MILP and LP require a linear objective.  For your problem with a quadratic objective and linear constraints, use instead the QP solver:

http://support.sas.com/documentation/cdl/en/ormpug/68156/HTML/default/viewer.htm#ormpug_qpsolver_toc...

 

SOLVE WITH QP;

 

or just:

 

SOLVE;

 

The optimal objective value turns out to be 17.8125, with optimal solution:

 

pub1 pub2
6.25 3.75

 

Frequent Contributor
Posts: 85

Re: Linear programming in SAS

Thank you very much for your help Rob.

 

I have another question I have a table with two vars, that have a non-linear relation, it is a polinomic relation like this:

 

y = a.x + b.x2 + cx3 + ....

 

is there anyway to obtain that model?, something simllar to proc reg but with polinomic relattonship??

 

Thanks

SAS Employee
Posts: 414

Re: Linear programming in SAS

Check out this example for polynomial regression with LP:

http://support.sas.com/documentation/cdl/en/ormpex/68157/HTML/default/viewer.htm#ormpex_ex11_toc.htm

 

You can also do least-squares by using a quadratic objective instead.

Grand Advisor
Posts: 9,447

Re: Linear programming in SAS

IML can do that. Check IML forum. There is already an example in there.

Grand Advisor
Posts: 9,447

Re: Linear programming in SAS

It is not called Linear Programming. your variable is countinuous , not discrete .

It is called Nonlinear Optimization, Check IML documentation.

 

proc iml;
start function(x);
 sale=3#x[1]-0.15#x[1]#x[1]+1.5#x[2]-0.05#x[2]#x[2];
 return (sale);
finish;
con={0 0 . .,
     . . . .,
     1 1 0 10};
optn={1 2};
x={0.5 0.5};
call nlpnra(rc,xres,'function',x,optn,con);
quit;

 

OUTPUT:

GCONV convergence criterion satisfied.

Optimization Results
Parameter Estimates
N Parameter Estimate Gradient
Objective
Function
1 X1 6.250000 1.125000
2 X2 3.750000 1.125000

Value of Objective Function = 17.8125

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 409 views
  • 4 likes
  • 3 in conversation