Modeling Logical Constraints with Binaries (AND, OR, NOT)
Translate logical conditions on yes/no decisions — AND, OR, NOT, implications, and compound rules — into linear constraints on binary variables.
Step 1 of 157%
Tutorial
Logical Conditions as Linear Constraints
Recall that a binary variable encodes a yes/no decision. Once decisions are represented this way, we can translate logical conditions into linear constraints.
Let .
- AND (both selected): and becomes
- OR (at least one selected): or becomes
- NOT ( is not selected):
More generally,
- 'at least of are selected':
- 'at most are selected':
- 'exactly are selected':
- ' and cannot both be selected':
For instance, a factory must run at least two of three machines . With binaries the rule becomes