how to linearize the following constraint to be able to solve it with optmodel
con Con1 {i in Item ,j in Cust}: (limit[i,'A1'] -x[i,'A1']) * x[i,'A2']=0;
where x is the decision variable.
What kind of variable is x?
Also, the constraint is declared over i and j but does not depend on j. The effect is that you get multiple copies of the same equation. You can use the EXPAND statement to see this.
X is an integer variable "quantity". the constraint depends on Both i and j. where j is the customer A,B,C. for customer A I have two offers for customer A; A1& A2, where customer can only leverage the discounted price A2 if he takes a minimum of quantity x with price A1.
I used expand and the function is working fine.
The thing is that I need an integer variable, and I receive this error" The NLP solver does not allow integer variables" when x is defined as integer. while, when x is not an integer it works fine but with lots of decimals
But the equation for your constraint does not contain j anywhere. So for the same i but different j, the constraint declaration will generate the same equation. If you did not see duplicates when you used EXPAND, then I suspect the code you ran is somehow different than what you posted.
In any case, I think I understand what you want to accomplish. So let me describe the model generically and you can modify it as needed to use in your optimization problem. Suppose x and y are variables, with 0 <= x <= u, where u is some constant, and y >= 0. You want to model the logical implication "if x > 0 then y >= c," where c is some constant. Then you can introduce a binary variable z and the following constraints:
x <= u * z
and
y >= c * z.
If x > 0, the first constraint forces z = 1. If z = 1, the second constraint forces y >= c. So together they enforce the desired implication: if x > 0 then y >= c.
Thank you Rob,
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.