You are on page 1of 3

Adam Diamant© OMIS 2010 - Fall 2018

Logical constraints for binary programs

Let xi be a binary decision variable corresponding to project i = A, B, . . . where


(
1 if project i is taken,
xi =
0 if project i is not taken.
We express logical conditions by defining constraints on groups of decision variables. In this document, we present
an introduction on how to formulate logical conditions. We first define a fundamental set of seven logical conditions
defined by using two or three decision variables. We then discuss how to extend this basic set to more complicated
logical constraints. Finally, we present a basic framework that one can use to create new logical conditions.

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

Table 1: The AND logical condition.

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

Table 2: The OR logical condition.

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

Table 3: The XOR logical condition.

Operations Management & Information Systems Page 1


Adam Diamant© OMIS 2010 - Fall 2018

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

Table 4: The If-THEN logical condition.

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

Table 5: The EQUIVALENT logical condition.

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

Table 6: The IF-AND-THEN logical condition.

Operations Management & Information Systems Page 2


Adam Diamant© OMIS 2010 - Fall 2018

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

Table 7: The IF-OR-THEN logical condition.

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:

• Select at least k of the first 5 projects: xA + xB + xC + xD + xE ≥ k.

• Select exactly k of the first 5 projects: xA + xB + xC + xD + xE = k.


• Select at most k of the first 5 projects: xA + xB + xC + xD + xE ≤ k.

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.

Operations Management & Information Systems Page 3

You might also like