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.
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:
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:
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.