## Constraint in optimization model

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

## Re: Constraint in 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:

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

2 REPLIES 2

## Re: Constraint in 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:

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

## Re: Constraint in optimization model

Thanks a lot Rob!!
Discussion stats
• 2 replies
• 1201 views
• 2 likes
• 2 in conversation