BookmarkSubscribeRSS Feed
AAZ
Fluorite | Level 6 AAZ
Fluorite | Level 6

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.

4 REPLIES 4
RobPratt
SAS Super FREQ

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.

AAZ
Fluorite | Level 6 AAZ
Fluorite | Level 6

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 

 

RobPratt
SAS Super FREQ

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.

AAZ
Fluorite | Level 6 AAZ
Fluorite | Level 6

Thank you Rob,

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 1045 views
  • 1 like
  • 2 in conversation