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?
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?
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.
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.
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.
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?
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).
Neither of y and z is binary. Rob, I am not sure how I can discretize them so that the equation becomes linear.
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.