## Non-linear constraint

Occasional Contributor
Posts: 5

# Non-linear constraint

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.

SAS Employee
Posts: 21

## Re: Non-linear constraint

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?

Occasional Contributor
Posts: 5

## Re: Non-linear constraint

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.

SAS Employee
Posts: 538

## Re: Non-linear constraint

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.

SAS Employee
Posts: 21

## Re: Non-linear constraint

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.

Occasional Contributor
Posts: 5

## Re: Non-linear constraint

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?

SAS Employee
Posts: 538

## Re: Non-linear constraint

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).

Occasional Contributor
Posts: 5

## Re: Non-linear constraint

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

SAS Employee
Posts: 538

## Re: Non-linear constraint

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;

Discussion stats
• 8 replies
• 643 views
• 0 likes
• 3 in conversation