BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
juanvg1972
Pyrite | Level 9

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

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

5 REPLIES 5
RobPratt
SAS Super FREQ

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

 

juanvg1972
Pyrite | Level 9

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

RobPratt
SAS Super FREQ

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.

Ksharp
Super User

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

Ksharp
Super User

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Multiple Linear Regression in SAS

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.

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