15
Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Embed Size (px)

Citation preview

Page 1: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Decision Modeling Using Boolean Algebra in

SpreadsheetsBryan Barney Reagan, Ph.D.

Saint Leo University

Page 2: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Law of Excluded MiddleAristotle (384 – 322 BC)

“For every assertion must, as is admitted, be either true or false, ….”

- Aristotle, Section 1, Part 4, “Categories”, The Organon, Translated by E. M. Edghill (2011) Page 15.

Bust of Aristotle. Marble, Roman copy after a Greek bronze original By Lysippos from 330 BC; Photo http://commons.wikimedia.org/wiki/Lysippos

Page 3: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Roots of X*X = XGeorge Boole (1815 -1864 A.D.)

Founded the field of Boolean Algebra in his two works: Mathematical Analysis of Logic (1847) and An Investigation of the Laws of Thought (1854)

In order to use simple mathematical operations to model logic. In order for X*X to equal X, he used the values zero (0) and one (1) for false and true. (Boole, George, Investigation of the Laws of Thought, Chapter 3. pp. 39-51)

http://www.maa.org

Page 4: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Boole’s Notation

Operation English BooleNegation NOT (1-A)

Conjunction AND A*B

Disjunction OR A+B

Aristotle BooleFalse 0

True 1

Page 5: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Negation

A NOT AFalse True

True False

A NOT A = (1-A)0 1

1 0

Page 6: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Conjunction

A B A AND BFalse False FalseFalse True FalseTrue False FalseTrue True True

A B A*B0 0 00 1 01 0 01 1 1

Page 7: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Disjunction

Disjunction is denoted with +, but it is not simple addition since it must not produce results greater than 1.We can derive an expression for “A + B” using DeMorgan’s Thereom, with which Boole was familiar.

A + B = 1 – ((1-A)*(1-B))= 1 – (1 – A – B + AB) = 1 – 1 + A + B – AB = A + B - AB

Page 8: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Disjunction

A B A OR BFalse False FalseFalse True TrueTrue False TrueTrue True True

A B A + B – (A*B)0 0 00 1 11 0 11 1 1

Page 9: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Distributive Properties in Boolean Algebras

Page 10: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Logical Values in Spreadsheets

Modern spreadsheets such as Excel support the Logical Values TRUE and FALSE , which may be entered as text or the result of comparisons using relational operators.

Comparison Type SampleEquality =(B12 = 42)

Non-Equality =(B12 <> 42)Less Than =(B12 < 42)

Less Than or Equal to =(B12 <= 42)Greater Than =(B12 > 42)

Greater Than or Equal To =(B12 >= 42)

Page 11: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Logical /Boolean Operators in Excel

Operator Excel NotationNegation =NOT(B12)Conjunction =AND(B12, C12)

=AND(B12:C12)Disjunction =OR(B12, C12)

=OR(B12:C12)

Page 12: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Conditional Formulas in Excel

=IF( Test Expression, Value if True, Value if False)

=IF(B12>500, 400, 0)

=IF(AND(B12>500,C12>0), 400, 0)

=IF(B12=MAX($B$2:$B$26),”*”,””)

Page 13: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Conversion Between Logical and Binary Values

• To convert from Logical to Binary, Excel allows multiplication of the values {False, True} by 1 to produce {0, 1}.

= B12 * 1

• To convert from Binary values to Logical, you can use the OR function with a single parameter to convert an value from {0, 1} to {False, True}.

= OR(C12)

Page 14: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Solver Constraints

Page 15: Decision Modeling Using Boolean Algebra in Spreadsheets Bryan Barney Reagan, Ph.D. Saint Leo University

Thank you [email protected]