BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ayush_sas
Fluorite | Level 6

I have a dataset having item_id as a column, where item_id ranges from 1 to 10, i want to select some of them based on some constraints in the optimization model. I defined a binary variable Yi={0,1} to decide which are selected and which not based on other constarints.
Now I have another dataset, having 2 columns item_id1 and item_id2, both have item ids from 1 to 10 only.
Eg dataset:

Item_id1  Item_id2
1               2

2               5

3               7

4               1

5               2

and so on

Now, i have to impose 1 more constraint that if any value from item_id1 is selected, then corresponding value from item_id2 is also selected, else both are not selected. In other words, if 1 is getting selected, then 2 is also selected. If 2 is getting selected, then 5 is also getting selected.

And i want to do that using only 1 binary variable Yi, to write that as a constaraint in the optimization model.

 

1 ACCEPTED SOLUTION

Accepted Solutions
RobPratt
SAS Super FREQ

You can linearize an if-then implication like yours by imposing a constraint Yi[i] <= Yi[j].  A left-hand side of 1 forces the right-hand side to be 1.

 

For several examples like this, follow the first item ("binary variables, modeling if-then constraints") in the Subject Index in this documentation book:

https://go.documentation.sas.com/api/docsets/ormpex/15.1/content/ormpex.pdf?locale=en#nameddest=titl...

View solution in original post

2 REPLIES 2
RobPratt
SAS Super FREQ

You can linearize an if-then implication like yours by imposing a constraint Yi[i] <= Yi[j].  A left-hand side of 1 forces the right-hand side to be 1.

 

For several examples like this, follow the first item ("binary variables, modeling if-then constraints") in the Subject Index in this documentation book:

https://go.documentation.sas.com/api/docsets/ormpex/15.1/content/ormpex.pdf?locale=en#nameddest=titl...

Ayush_sas
Fluorite | Level 6
Thanks a lot Rob!!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 1487 views
  • 2 likes
  • 2 in conversation