450 likes | 504 Views
CS464: Soft Computing Lecture 9: Fuzzy Logic Introduction. Dr. Mohammad Nassef Department of Computer Science Faculty of Computers and Information Cairo University Egypt. Outline. Fuzzy Logic What is Fuzzy Logic? History Fuzzy Sets Examples. WHAT IS FUZZY LOGIC?.
E N D
CS464: Soft ComputingLecture 9: Fuzzy LogicIntroduction Dr. Mohammad Nassef Department of Computer Science Faculty of Computers and Information Cairo University Egypt CS-FCI-CU-EG
Outline • Fuzzy Logic • What is Fuzzy Logic? • History • Fuzzy Sets • Examples FCI-CU-EG
WHAT IS FUZZY LOGIC? • Definition of fuzzy • Fuzzy – “not clear, distinct, or precise; blurred” • Definition of Fuzzy Logic • A form of knowledge representation suitable for notions that cannot be defined precisely, but which depend upon their contexts.
WHAT IS FUZZY LOGIC? • Fuzzy logic: • A way to represent variation or imprecision in logic • A way to make use of natural language in logic • Approximate reasoning • Humans say things like "If it is sunny and warm today, I will drive fast" • Linguistic variables: • Temp: {freezing, cool, warm, hot, very hot} • Cloud Cover: {overcast, partly cloudy, sunny} • Speed: {very slow, slow, fast, very fast} Fuzzy Logic
TRADITIONAL REPRESENTATION OF LOGIC Slow Fast Speed = 0 Speed = 1 bool speed; // get the speed if ( speed == 0) { // speed is slow } else { // speed is fast }
FUZZY LOGIC REPRESENTATION • Some problems must be represented in terms of fuzzy sets. • What are Fuzzy Sets? Slowest [ 0.0 – 0.25 ] Slow [ 0.25 – 0.50 ] Fast [ 0.50 – 0.75 ] Fastest [ 0.75 – 1.00 ]
FUZZY LOGIC REPRESENTATION Slowest Slow Fast Fastest float speed; // get the speed if ((speed >= 0.0)&&(speed < 0.25)) { // speed is slowest } else if ((speed >= 0.25)&&(speed < 0.5)) { // speed is slow } else if ((speed >= 0.5)&&(speed < 0.75)) { // speed is fast } else // speed >= 0.75 && speed < 1.0 { // speed is fastest }
ORIGINS OF FUZZY LOGIC • Traces back to Ancient Greece • Lotfi Asker Zadeh ( 1965 ) • First to publish ideas of fuzzy logic. • Professor ToshireTerano ( 1972 ) • Organized the world's first working group on fuzzy systems. • F.L. Smidth & Co. ( 1980 ) • First to market fuzzy expert systems.
ORIGINS OF FUZZY LOGIC • Professor Lotfi Zadeh, UC Berkeley, 1965 “People do not require precise numerical information input, and yet they are capable of highly adaptive control.” • Accepts noisy, imprecise input! • Fuzzy logic can be defined as a superset of conventional (Boolean) logic that has been extended to handle the concept of partial truth - truth values between “completely true” and “completely false”
ORIGINS OF FUZZY LOGIC 1965 Seminal Paper “Fuzzy Logic” by Prof. Lotfi Zadeh, Faculty in Electrical Engineering, U.C. Berkeley, Sets the Foundation of the “Fuzzy Set Theory” 1970 First Application of Fuzzy Logic in Control Engineering (Europe) 1975 Introduction of Fuzzy Logic in Japan 1980 Empirical Verification of Fuzzy Logic in Europe 1985 Broad Application of Fuzzy Logic in Japan 1990 Broad Application of Fuzzy Logic in Europe 1995 Broad Application of Fuzzy Logic in the U.S. 2000 Fuzzy Logic Becomes a Standard Technology and Is Also Applied in Data and Sensor Signal Analysis. Application of Fuzzy Logic in Business and Finance. Today, Fuzzy Logic Has Already Become the Standard Technique for Multi-Variable Control !
Another Example • A class of students(e.g. SWE Students learning“Fuzzy Logic”) • The universe of discourse: X • “Who does have a driving licence?” • A subset of X = a (Crisp) Set • (X) = CHARACTERISTIC FUNCTION 1 0 1 1 0 1 1 • “Who can drive very well?” (X) = MEMBERSHIP FUNCTION 0.7 0 1.0 0.8 0 0.4 0.2 FUZZY SET
Crisp (Traditional) Variables • Crisp variables represent precise quantities: • x = 3.1415296 • A {0,1} • A proposition is either True or False • A B C • King(Richard) Greedy(Richard) Evil(Richard) • Richard is either greedy or he isn't: • Greedy(Richard) {0,1} Fuzzy Logic
Fuzzy Sets • What if Richard is only somewhat greedy? • Fuzzy Sets can represent the degree to which a quality/degree is possessed. • Fuzzy Sets (Simple Fuzzy Variables) have values in the range of [0…1] • Greedy(Richard) = 0.7 • Question: How evil is Richard? Fuzzy Logic
Fuzzy Linguistic Variables • Fuzzy Linguistic Variables are used to represent qualities spanning a particular spectrum • Temp: {Freezing, Cool, Warm, Hot} • Membership Function • Question: What is the temperature? • Answer: It is warm. • Question: How warm is it? Fuzzy Logic
Membership Functions • Temp: {Freezing, Cool, Warm, Hot} • Degree of Truth or "Membership" Fuzzy Logic
Membership Functions • How cool is 36 F° ? Fuzzy Logic
Membership Functions • How cool is 36 F° ? • It is 30% Cool and 70% Freezing 0.7 0.3 Fuzzy Logic
Fuzzy Logic • How do we use fuzzy membership functions in predicate logic? • Fuzzy logic Connectives: • Fuzzy Conjunction, • Fuzzy Disjunction, • Operate on degrees of membership in fuzzy sets Fuzzy Logic
Fuzzy Disjunction • AB max(A, B) • AB = C "Quality C is the disjunction of Quality A and B" • (AB = C) (C = 0.75) Fuzzy Logic
Fuzzy Conjunction • AB min(A, B) • AB = C "Quality C is the conjunction of Quality A and B" • (AB = C) (C = 0.375) Fuzzy Logic
Example: Fuzzy Conjunction Calculate AB given that A is .4 and B is 20 Fuzzy Logic
Example: Fuzzy Conjunction Calculate AB given that A is .4 and B is 20 • Determine degrees of membership: Fuzzy Logic
Example: Fuzzy Conjunction Calculate AB given that A is .4 and B is 20 0.7 • Determine degrees of membership: • A = 0.7 Fuzzy Logic
Example: Fuzzy Conjunction Calculate AB given that A is .4 and B is 20 0.9 0.7 • Determine degrees of membership: • A = 0.7 B = 0.9 Fuzzy Logic
Example: Fuzzy Conjunction Calculate AB given that A is .4 and B is 20 0.9 0.7 • Determine degrees of membership: • A = 0.7 B = 0.9 • Apply Fuzzy AND • AB = min(A, B) = 0.7 Fuzzy Logic
Fuzzy Control • Fuzzy Control combines the use of fuzzy linguistic variables with fuzzy logic • Example: Speed Control • How fast am I going to drive today? • It depends on the weather. • Disjunction of Conjunctions Fuzzy Logic
What can we do now? • What should be done is summarized into three main stages • Fuzzification • Membership functions used to graphically describe a situation • Evaluation of Rules (Inference) • Application of the fuzzy logic rules • De-fuzzification • Obtaining the crisp results
Inputs: Temperature • Temp: {Freezing, Cool, Warm, Hot} Fuzzy Logic
Inputs: Temperature, Cloud Cover • Temp: {Freezing, Cool, Warm, Hot} • Cover: {Sunny, Partly, Overcast} Fuzzy Logic
Output: Speed • Speed: {Slow, Fast} Fuzzy Logic
Rules • If it's Sunny and Warm, drive Fast Sunny(Cover)Warm(Temp) Fast(Speed) • If it's Cloudy and Cool, drive Slow Cloudy(Cover)Cool(Temp) Slow(Speed) • Driving Speed is the combination of output of these rules... Fuzzy Logic
Example: Speed Calculation • How fast will I go if it is • 65 F° • 25 % Cloud Cover ? Fuzzy Logic
Fuzzification:Calculate Input Membership Levels • 65 F° Cool = 0.4, Warm= 0.7 Fuzzy Logic
Fuzzification:Calculate Input Membership Levels • 65 F° Cool = 0.4, Warm= 0.7 • 25% Cover Sunny = 0.8, Cloudy = 0.2 Fuzzy Logic
...Calculating... • If it's Sunny and Warm, drive Fast Sunny(Cover)Warm(Temp)Fast(Speed) 0.8 0.7 = 0.7 Fast = 0.7 • If it's Cloudy and Cool, drive Slow Cloudy(Cover)Cool(Temp)Slow(Speed) 0.2 0.4 = 0.2 Slow = 0.2 Fuzzy Logic
Defuzzification: Constructing the Output • Speed is 20% Slow and 70% Fast • Find centroids: Location where membership is 100% Fuzzy Logic
Defuzzification: Constructing the Output • Speed is 20% Slow and 70% Fast • Find centroids: Location where membership is 100% Fuzzy Logic
Defuzzification: Constructing the Output • Speed is 20% Slow and 70% Fast • Speed = weighted mean = (0.2*25+... Fuzzy Logic
Defuzzification: Constructing the Output • Speed is 20% Slow and 70% Fast • Speed = weighted mean = (0.2*25+0.7*75)/(0.2+0.7) = 63.8 mph Fuzzy Logic