Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-24-2017 08:39 AM
(1109 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you Rob,

**Available on demand!**

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

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.