Optimization Results | |||
---|---|---|---|
Parameter Estimates | |||
N | Parameter | Estimate | Gradient Objective Function |
1 | X1 | 6.250000 | 1.125000 |
2 | X2 | 3.750000 | 1.125000 |
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;
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:
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 |
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:
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 |
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
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.
IML can do that. Check IML forum. There is already an example in there.
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
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.