BookmarkSubscribeRSS Feed
Abhik
Calcite | Level 5

When I write an equation in the form:

(x1+x2)/(y1+y2)=2 (where x(i), y(i) are decision variables)

SAS-OR considers the equation as a non-linear constraint.

However when I re-write the same equation in the form:

x1+x2=2*(y1+y2), SAS-OR considers it as a linear constraint.

Can somebody please help?

8 REPLIES 8
YanXu
SAS Employee

There is no auto linearization in SAS/OR yet. We do have plans to do some auto linearization in the future.

Are you using OPTMODEL or PROC NLP?

Abhik
Calcite | Level 5

I am using OPTMODEL. I am not very sure about what you mean by 'auto-linearization'. But (x1+x2)/(y1+y2)=2 is a linear equation, and if SAS considers this as a non-linear one, then it's wrong. 

RobPratt
SAS Super FREQ

No, (x1+x2) / (y1+y2) = 2 is not a linear equation and in fact it is not exactly equivalent to the linear equation x1+x2 = 2*(y1+y2) since the latter allows the solution (0,0,0,0).  When you linearize constraints of this form (and even more so for inequalities), you have to be careful about the sign of the denominator.  For example, (x1+x2) / (y1+y2) >= 2 is equivalent to x1+x2 >= 2*(y1+y2) if and only if y1+y2 > 0.

YanXu
SAS Employee

Linearization is technique to transfer nonlinear items to linear items.

Rob is right,  (x1+x2) / (y1+y2) = 2 ---> x1+x2 = 2*(y1+y2), only if you know that y1+y2 is never going to be 0. Otherwise, they are not equivalent.

Abhik
Calcite | Level 5

Thanks for the clarification.

By the way, I have an equation of the form x/y+z=c (where x,y,z are decision variables and >0, c is a constant).Is there a possible way of converting this to a linear form?

RobPratt
SAS Super FREQ

If you multiply both sides by y, you get x + y z = c y.  If y and z are binary variables, you can replace the product y z with a new binary variable w and add some constraints.  If only one of y and z is binary and the other is bounded, you can linearize the product in a similar manner.  If neither of y and z is binary, you can discretize one of them and apply the same techniques.

For details, please see Chapters 10 and 24 in the new book of mathematical programming examples available as part of the SAS/OR documentation:

https://support.sas.com/pubscat/bookdetails.jsp?pc=64980 (click on View This Title Online for a free pdf version).

Abhik
Calcite | Level 5

Neither of y and z is binary. Rob, I am not sure how I can discretize them so that the equation becomes linear.

RobPratt
SAS Super FREQ

Here is how to discretize a bounded variable y:

proc optmodel;

    var y >= 0 <= 3;

    num num_steps = 10;

    set STEPS = 0..num_steps-1;

    num a {s in STEPS} = (s - y.lb) / (y.ub - y.lb);

    var yb {STEPS} binary;

    con assign: sum {s in STEPS} yb = 1;

    con link: sum {s in STEPS} a * yb = y;

quit;

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
  • 8 replies
  • 1586 views
  • 0 likes
  • 3 in conversation