Вы находитесь на странице: 1из 3

Binary Logic

General convention: if x = 1 then it is selected, if 0 it is not selected. Define five binary alternatives: x1, x2, x3, x4, x5 k out of n alternatives: (n = the number of alternatives, k = the number to choose) If exactly three of the alternatives must be chosen, 1x1 + 1x2 + 1x3 + 1x4 + 1x5 = 3 If no more than four are to be selected: 1x1 + 1x2 + 1x3 + 1x4 + 1x5 4 Corequisite Constraints: If one must be chosen if a second is chosen (and vice versa), 1x1 = 1x5. This constrains x1 and x2 to the same value. Conditional Constraints: When the inclusion of one is conditional on the acceptance of another, the conditional one is subordinate to the driver. If x1 will not be considered unless x5 is chosen, 1x1 1x5. without x1 but x1 can only exist if x5 exists. In this case, x5 can exist with or T/F x1 T 0 F 1 T 0 T 1 x5 0 0 1 1

The validity of such a statement can be tested with a truth table:

If only one or the other of x1 or x2 can be considered if x5 is chosen, but not both, combine them into one: 1x1 + 1x2 1x5. T/F x x x
1 2 5

F F F F F T T T

1 1 0 0 1 1 0 0

1 0 1 0 1 0 1 0

0 0 0 0 1 1 1 1

If one or the other or both of x1 and x2 can be considered if x5 is chosen, increase the coefficient of the driver to the number that can be considered: 1x1 + 1x2 2x5.

T/F x1 x2 F 1 1 F 1 0 F 0 1 F 0 0 F 1 1 T 1 0 T 0 1 T 0 0 T 1 1 T 1 0 T 0 1 T 0 0

x5 0 0 0 0 1 1 1 1 2 2 2 2

Some more examples: Define five binary alternatives: x1, x2, x3, x4, x5. if xi = 1 then it is selected, if xi = 0 it is not selected.

a) If x1 is selected, x2 should not be selected. One thing is to be elected so set the relationship equal to 1 and add up the selected elements. Letting the relationship be less than or equal to zero also allows neither one to be selected. If one or the other had to be selected, make the relationship an equality. x1 + x2 1

b) x3 should be selected only if x1 is selected. Since x3 is subordinate to x1, a less than relationship is warranted. This allows x1 to be selected without forcing x3 to be selected, but still allows it. x3 x1 or, rewritten: x1 + x3 0

c) x4 should not be selected if either x1 or x2 is selected. Since two things block selecting x4, set 2 as a constant and add in either conditional choice (x1 or x2) and the dependent choice x4 (multiplied by the constant to increase its power). An equality would force both of x1 or x2 to be selected if x4 was not selected. Making it less than or equal allows x1 and x2 to be selected independently. x1 + x2 + 2x4 2 This truth table shows how it works: T/F T T T T T F F F x1 0 1 0 1 0 1 0 1 x2 2x4 0 0 0 0 1 0 1 0 0 1 0 1 1 1 1 1

2 2 2 2 2 2 2 2

d) x5 can be selected only if x1 and x3 are selected. Since two selections (x1 and x2) are required to allow x5 to be selected, set the sum of them equal to the dependent choice (x5) multiplied by the number of independent choices required (2). And since it is not required that x5 be chosen if x1 and x2 are chosen set the relationship to 0. x1 + x3 2x5 or, rewritten: x1 + x3 2x5 0 T/F T T T T F F F T x1 0 1 0 1 0 1 0 1 x3 0 0 1 1 0 0 1 1 -2x5 0 0 0 0 1 1 1 1

0 0 0 0 0 0 0 0

e) x5 should be selected only if x1 is selected and x3 is not selected. This combines both conditions a) and b) above: Only either x3 or x5 can be chosen: 1x3 + 1x5 1 and Choose x5 only if x1: 1x5 1x1 or rewritten: 1x1 + 1x5 0 Combine (add) these two and you get: 1x1 + 1x3 + 2x5 1 T/F T T T T F T F F -x1 0 1 0 1 0 1 0 1 x3 0 0 1 1 0 0 1 1 2x5 0 0 0 0 1 1 1 1

1 1 1 1 1 1 1 1

Вам также может понравиться