Modelling Logical Relations
Modelling with Binary Variables
Consider the following investment example:
- We would like to invest in 5 assets, labelled \(\left\{ 1, 2, 3, 4, 5 \right\}\).
- We can invest only nonnegative amounts, and have a total budget of $1000 dollars.
Let \(x_j\) to denote the amount invested in asset \(j\). Then we can formulate an optimization model:
Let \(y_j\) be a binary variable which will take a value \(1\) if \(x_j > 0\). Then we have:
OR Constraint
Consider a case where we have to invest at least $100 in asset 1 or asset 5. Logically, this constraint is:
Algebraically, we can write this as:
XOR Constraint
Consider a case where we have to invest at least $100 in asset 1 or asset 5 but not both. Logically, this constraint is:
Algebraically, we can write this as:
Implications
Consider a case where if we invest $100 or more in asset 1, then we must invest $100 or more in asset 5. Logically, this constraint is:
Let \(z\) be a binary variable that gets set to 1 if \(x_1 \geq 100\). Algebraically, we can write this as:
where \(\epsilon\) is a small positive number.
Examples
-
If \(x_1 > 0\), then \(x_2 = 0\) or \(x_3 = 0\). Constraint:
\[ y_2 + y_3 \leq 2 - y_1. \] -
If \(x_1 > 0\) or \(x_2 > 0\), then \(x_5 = 0\). Constraint:
\[ y_5 \leq 1 - y_1, y_5 \leq 1 - y_2. \]