Professional Documents
Culture Documents
Summary - Logical - Constraints - For - Binary - Programs - UPDATED
Summary - Logical - Constraints - For - Binary - Programs - UPDATED
AND: Returns the value of true if both operands are true; false otherwise.
If projects A and B must both be selected, this is equivalent to the logical constraint that xA + xB = 2. The
left-hand side of this constraint is represented by the truth table in Table 1. Notice that this constraint ensures
that both projects will simultaneously be selected; it does not allow for only one project to be selected.
xA xB A AND B xA + xB = 2
0 0 False False
0 1 False False
1 0 False False
1 1 True True
OR: Returns the value of true if at least one operand is true; false otherwise.
If either project A or project B must be selected, this is equivalent to the logical constraint xA + xB ≥ 1. The
left-hand side of this constraint is represented by the truth table in Table 2. Notice that in contrast to the
AND operation, a single project can be selected and both projects can simultaneously be selected.
xA xB A OR B xA + xB ≥ 1
0 0 False False
0 1 True True
1 0 True True
1 1 True True
XOR: Returns the value of true if exactly one operand is true; false otherwise.
If either project A or B must be selected, this is equivalent to the constraint xA + xB = 1. The left-hand side
of this constraint is represented by the truth table in Table 3. Notice that in contrast to the OR operation,
exactly one project must be selected; both projects cannot simultaneously be selected.
xA xB A XOR B xA + xB = 1
0 0 False False
0 1 True True
1 0 True True
1 1 False False
IF-THEN: Ensures that if one operand is true, the other is also true.
If project A is selected then so must project B. This is equivalent to the constraint xA ≤ xB represented by the
truth table in Table 4. Notice that this condition does not specify what happens if project A is not selected.
xA xB IF A THEN B xA ≤ xB
0 0 True True
0 1 True True
1 0 False False
1 1 True True
EQUIVALENT (IFF): Ensures that both operands are simultaneously true or simultaneously false.
If project A is selected then so must project B. If project A is not selected then project B must also not be
selected. One can also say that project A is selected if and only if project B is selected. This is equivalent to
the constraint xA = xB represented by the truth table in Table 5.
xA xB A IFF B xA = xB
0 0 True True
0 1 False False
1 0 False False
1 1 True True
IF-AND-THEN: Ensures that if two operands are true, the third operand will also be true.
If project A and project B is selected, then so must project C. This is equivalent to the constraint xA + xB ≤
1 + xc represented by the truth table in Table 6. Notice that this condition does not specify what happens if
project A is selected but not B, if project B is selected but not A, or if neither A and nor B are selected.
xA xB xC If (A AND B) THEN C xA + xB ≤ 1 + xC
0 0 0 True True
0 0 1 True True
0 1 0 True True
0 1 1 True True
1 0 0 True True
1 0 1 True True
1 1 0 False False
1 1 1 True True
IF-OR-THEN: Ensures that if at least one of two operands are true, the third operand will also be true.
If project A or project B is selected (or both projects are selected), then so must project C. This is equivalent
to the constraint xA + xB ≤ 2xc represented by the truth table in Table 7. Notice that this condition does not
specify what happens if neither project A and nor project B are selected.
xA xB xC If (A OR B) THEN C xA + xB ≤ 2xC
0 0 0 True True
0 0 1 True True
0 1 0 False False
0 1 1 True True
1 0 0 False False
1 0 1 True True
1 1 0 False False
1 1 1 True True
Implications: Using the seven basic building blocks for logical conditions (discussed above), we can create more
difficult constraints involving more than three decision variables. Here are some examples:
Constructing your own constraints: Suppose you are given a problem and are asked to come up with your
own logical constraint(s). That is, you are tasked with converting a practical restriction into mathematical constraint.
Although at first glance it may seem impossible, here is a step-by-step approach that may help.
1. Write down, in words, the practical restriction you wish to convert into a mathematical constraint.
2. Clearly define your decision variables using a combination of words and mathematical notation.
3. Write down a trial mathematical expression using the decision variables you have defined.
4. Create a truth table using the decision variables and mathematical expression.
5. Does the truth table accurately express what is conveyed by the practical restriction?
• If yes, congratulations, you are done. Dance like nobody is watching!
• If no, revise the set of decision variables you defined and go to step 3.