UNIT III FUZZY LOGIC I Prepared by Mrs
UNIT III FUZZY LOGIC I Prepared by Mrs. Priya charles
What is Fuzzy Logic was developed by Lotfi Zadeh at UC Berkleyin 1960. “Fuzzy logic is derived from fuzzy set theory dealing with reasoning which is approximate rather than precisely deduced from classical predicate logic”
A. Introduction (figure from Earl Cox) 4
Introduction Steps (Earl Cox based on previous slide): 1. Input – vocabulary, fuzzification (creating fuzzy sets) 2. Fuzzy propositions – IF X is Y THEN Z (or Z is A) … there are four types of propositions 3. Hedges – very, extremely, somewhat, more, less 4. Combination and evaluation – computation of the results given the inputs 5. Action - defuzzification 5
Fuzzy Logic Example Automotive Speed Controller 3 inputs: speed (5 levels) acceleration (3 levels) distance to destination (3 levels) 1 output: power (fuel flow to engine) Set of rules to determine output based on input values
Fuzzy Logic Example
Fuzzy Logic Example Rules IF speed is TOO SLOW and acceleration is DECELERATING, THEN INCREASE POWER GREATLY IF speed is SLOW and acceleration is DECREASING, THEN INCREASE POWER SLIGHTLY IF distance is CLOSE, THEN DECREASE POWER SLIGHTLY. . .
Fuzzy Logic Example Output Determination Degree of membership in an output fuzzy set now represents each fuzzy action. Fuzzy actions are combined to form a system output.
Steps by Step Approach • Step One • Define the control objectives and criteria. • Consider question like • • What is trying to be controlled? What has to be done to control the system? What kind of response is needed? What are the possible (probable) system failure modes? • Step Two • Determine input and output relationships • Determine the least number of variables for inputs to the fuzzy logic system
Steps by Step Approach • Step Three • Break down the control problem into a series of IF X AND Y, THEN Z rules based on the fuzzy logic rules. • These IF X AND Y, THEN Z rules should define the desired system output response for the given systems input conditions. • Step Four • Create a fuzzy logic membership function that defines the meaning or values of the input and output terms used in the rules
Steps by Step Approach • Step Five • After the membership functions are created, program everything then into the fuzzy logic system • Step Six • Finally, test the system, evaluate results and make the necessary adjustments until a desired result is obtain
Steps by Step Approach • The above steps are summarized into three main stages • Fuzzification • Membership functions used to graphically describe a situation • Evaluation of Rules • Application of the fuzzy logic rules • Deffuzification • Obtaining the crisp results
Steps by Step Approach
Inverted Pendulum • Task: • To balance a pole on a mobile platform that can move in only two directions, either to the left or to the right.
Inverted Pendulum • The input and output relationships of the variables of the fuzzy system are then determined. • Inputs: • Angle between the platform and the pendulum • Angular velocity of this angle. • Outputs: • Speed of platform
Inverted Pendulum • Use membership functions to graphically describe the situation (Fuzzification) • The output which is speed can be high speed, medium speed, low speed, etc. These different levels of output of the platform are defined by specifying the membership functions for the fuzzy-sets
Inverted Pendulum
Inverted Pendulum • Define Fuzzy Rules • Examples • • If angle is zero and angular velocity is zero, then speed is also zero If angle is zero and angular velocity is negative low, the speed is negative low If angle is positive low and angular velocity is zero, then speed is positive low If angle is positive low and angular velocity is negative low, then speed is zero
Inverted Pendulum
Inverted Pendulum • Finally, the Defuzzification stage is implemented. • Two ways of defuzzification is by • Finding the center of Gravity and • Finding the average mean.
INTRODUCTION § What is Fuzzy Logic? § Problem-solving control system methodology § Linguistic or "fuzzy" variables § Example: IF (process is too hot) AND (process is heating rapidly) THEN (cool the process quickly)
INTRODUCTION (Contd. ) § Advantages § Mimicks human control logic § Uses imprecise language § Inherently robust § Fails safely § Modified and tweaked easily
INTRODUCTION (Contd. ) § Disadvantages § Operator's experience required § System complexity
DEMOS Fuzzy Logic Anti-sway Crane Controller
DEMOS (Contd. ) Control of a Flexible Robot
DEMOS (Contd. ) Anti-Swing Control of an Overhead Crane
DEMOS (Contd. ) Robot Skating
DEMOS (Contd. ) § Fuzzy Shower § § Fuzzy Controller for an Inverted Pendulum § § http: //ai. iit. nrc. ca/IR_public/fuzzy. Shower. html http: //www. aptronix. com/fuzzynet/java/pendjava. htm Prevention of Load Sway by a Fuzzy Controller § http: //people. clarkson. edu/~esazonov/neural_fuzzy/loadsway/Load. Sway. ht m
What Is Fuzzy Logic? • Theory of fuzzy sets – Membership is a matter of degree. – Fuzzy sets VS classical set theory. • Basic foundations of fuzzy sets – Fuzzy sets (Zadeh, 1965) , Fuzzy Logic (Zadeh, 1973) • Fuzzy – Reflect how people think – Attempts to model our sense of words decision making, and common sense. – Mathematical principles for knowledge representation based on degrees of membership rather than on crisp membership of classical binary logic.
Fuzzy sets • • Accept that things can be partly true and partly false to any degree at the same time. Crisp and fuzzy sets of ‘tall men’
Membership function • Crisp set representation – Characteristic function • Fuzzy set representation – Membership function
Well known Membership Functions Triangular Gaussian Trapezoidal Bell
Fuzzy Vs Probability • Fuzzy ≠ Probability => μA(x) ≠ p. A(x) • Both map x to a value in [0, 1]. • PA(x) measures our knowledge or ignorance of the truth of the event that x belongs to the set A. – Probability deals with uncertainty and likelihood. • μA(x) measures the degree of belongingness of x to set A and there is no interest regarding the uncertainty behind the outcome of the event x. Event x has occurred and we are interested in only making observations regarding the degree to which x belongs to A. – Fuzzy logic deals with ambiguity and vagueness.
Example • A bottle of water • 50% probability of being poisonous means 50% chance. – 50% water is clean. – 50% water is poisonous. • 50% fuzzy membership of poisonous means that the water has poison. – Water is half poisonous.
Fuzzy Set Theory In traditional set theory, an element either belongs to a set, or it does not. Membership functions classify elements in the range [0, 1], with 0 and 1 being no and full inclusion, the other values being partial membership
Where did Fuzzy Logic come from People generally do not divide things into clean categories, yet still make solid, adaptive decisions Dr. Zadeh felt that having controllers to accept 'noisy' data might make them easier to create, and more effective
Simple example of Fuzzy Logic Controlling a fan: Conventional model – if temperature > X, run fan else, stop fan Fuzzy System if temperature = hot, run fan at full speed if temperature = warm, run fan at moderate speed if temperature = comfortable, maintain fan speed if temperature = cool, slow fan if temperature = cold, stop fan http: //www. duke. edu/vertices/update/win 94/fuzlogic. html
Some Fuzzy Logic applications MASSIVE Created to help create the large-scale battle scenes in the Lord of the Rings films, MASSIVE is program for generating crowd-related visual effects
Applications of Fuzzy Logic Vehicle Control A number of subway systems, particularly in Japan and Europe, are using fuzzy systems to control braking and speed. One example is the Tokyo Monorail
Applications of Fuzzy Logic Appliance control systems Fuzzy logic is starting to be used to help control appliances ranging from rice cookers to small-scale microchips (such as the Freescale 68 HC 12)
TYPES AND MODELING OF UNCERTAINTY
• Height of a person is 5 ‘ 6” (168 cm) short /tall? • For Men short • For women tall • Make statement: “Ravi is short” and give a value of 0. 70 • If this value is probability value then it means 70% chances that Ravi is short. (dilemma may be he is tall) • In fuzzy “His degree of membership in the set of short people is 0. 70”, means if all the short people are considered and lined up , Ravi is positioned 70% of the way to the shortest.
FUZZY vs PROBABILITY Ø Fuzzy ≠ Probability Ø Probability deals with uncertainty an likelihood Ø Fuzzy logic deals with ambiguity an vagueness
NEED OF FUZZY LOGIC Ø Based on intuition and judgment. Ø No need for a mathematical model. Ø Provides a smooth transition between members and nonmembers. Ø Relatively simple, fast and adaptive. Ø Less sensitive to system fluctuations. Ø Can implement design objectives, difficult to express mathematically, in linguistic or descriptive rules.
• Fuzzy Probability • Example #1 • Billy has ten toes. The probability Billy has nine toes is zero. The fuzzy membership of Billy in the set of people with nine toes, however, is nonzero. 54
Example #2 #1 • A bottle of liquid has a probability of ½ of being rat poison and ½ of being pure water. • A second bottle’s contents, in the fuzzy set of liquids containing lots of rat poison, is ½. • The meaning of ½ for the two bottles clearly differs significantly and would impact your choice should you be dying of thirst. #2 55
Example #3 • Fuzzy is said to measure “possibility” rather than “probability”. • Difference • All things possible are not probable. • All things probable are possible. • Contrapositive • All things impossible are improbable • Not all things improbable are impossible 56
• The probability that a fair die will show six is 1/6. This is a crisp probability. All credible mathematicians will agree on this exact number. • The weatherman's forecast of a probability of rain tomorrow being 70% is also a fuzzy probability. Using the same meteorological data, another weatherman will typically announce a different probability. 57
Crisp Sets • Everything is either true or false • No uncertainty is allowed • An item either is o o entirely within a set, or entirely not in a set o o X must be either in set A or in set not-A no middle ground is allowed • The Law of the Excluded Middle
Fuzzy Sets • Items can belong to a fuzzy set to different degrees of membership • Completely within a set is a membership degree of 1 • Completely outside a set is a membership degree of 0
OPERATIONS ON CRISP SETS Ø UNION: Ø INTERSECTION: Ø COMPLEMENT: Ø DIFFERENCE:
PROPERTIES OF CRISP SETS The various properties of crisp sets are as follows:
FUZZY SETS
OPERATIONS ON FUZZY SETS
PROPERTIES OF FUZZY SETS
Fuzzification • The process of determining the degree to which a value belongs in a fuzzy set • The value returned by a fuzzy MF • Most variables in a fuzzy system have multiple MF attached to them • Fuzzifying that variable involves passing the crisp value through each MF attached to that value
Fuzzy Logic • Same operations and function as in crisp logic • Must deal with degrees of truth rather than absolute truths • Fuzzy logic is a superset of crisp (Boolean) logic
Fuzzy Logic • AND, OR, NOT • Crisp logical functions o o o AND true is both parameters are true OR true if either parameter is true NOT reverses truth of argument
Fuzzy Logic • AND function - crisp version
Fuzzy Logic • AND function - fuzzy version o take the minimum of the two arguments
Fuzzy Logic • OR function - crisp version
Fuzzy Logic • OR function - fuzzy version o take the maximum of the two arguments
Fuzzy Logic • NOT function - crisp version
Fuzzy Logic • NOT function - fuzzy version o subtract the truth value from one
Fuzzy Logic • Output of fuzzy logical functions are the same as crisp functions o o just calculated differently handle degrees of truth, rather than absolute truths • The basis of fuzzy rule based systems
Fuzzy Sets • Degrees of membership must sum to 1 • An item can be both A and not-A to different degrees o e. g. A to a degree of 0. 8, not-A 0. 2 • Degrees of membership are expressed with membership functions • Range of values a variable can take is called the universe of discourse
Membership Functions • A membership function describes the degree of membership of a value in a fuzzy set • Referred to as MF o Also § where x is the value being fuzzified
Singleton MF
Singleton MF
Rectangular MF
Triangular MF • A family of MF • Constantly tend towards zero and one • Three in the family o o o Left-shouldered Triangular Right-shouldered
Triangular MF
Triangular MF
Gaussian MF
Gaussian MF • c is the centre of the MF • sigma is the width of the MF • exp is the exponential function
Gaussian MF • S function
Gaussian MF • L is the left hand ‘breakpoint’ of the MF • r is the right hand ‘breakpoint’ of the MF • c is the centre of the MF
Gaussian MF • Z function is symmetrical to S function
FEATURES OF THE MEMBERSHIP FUNCTION
Membership Functions • MF can also be represented by a set of ordered pairs • Pairs are crisp-fuzzy values A={(0, 1. 0), (1, 1. 0), (2, 0. 75), (3, 0. 5), (4, 0. 25), (5, 0. 0), (6, 0. 0), (7, 0. 0), (8, 0. 0), (9, 0. 0), (10, 0. 0)} o B={(0, 0. 0), (1, 0. 2), (2, 0. 4), (3, 0. 6), (4, 0. 8), (5, 1. 0), (6, 0. 8), (7, 0. 6), (8, 0. 4), (9, 0. 2), (10, 0. 0)} o C={(0, 0. 0), (1, 0. 0), (2, 0. 0), (3, 0. 0), (4, 0. 0), (5, 0. 0)(6, 0. 25), (7, 0. 5), (8, 0. 75), (9, 1. 0), (10, 1. 0)} o
Summary • • Fuzzy logic deals with uncertainty Allows degrees of truth Allows partial membership in sets Fuzzy membership functions describe degrees of membership in fuzzy sets • Many different types of MF exist • Fuzzification = determining degree of membership o uses fuzzy MF to do so o the basis of fuzzy rules • Fuzzy logic extends Boolean operators to handle partial truths
• Consider two given fuzzy sets • A={1/2+0. 3/4+0. 5/6+0. 2/8} • B={0. 5/2+0. 4/4+0. 1/6+1/8} • Perform Union, intersection, difference and complement over fuzzy sets A and B.
• AUB={1/2+0. 4/4+0. 5/6+1/8} ~ ~ • A∩B={0. 5/2+0. 3/4+0. 1/6+0. 2/8} ~ ~
A={0/2+0. 7/4+0. 5/6+0. 8/8} B={0. 5/2+0. 6/4+0. 9/6+0/8} Difference: _ Or A ∩B={0. 5/2+0. 3/4+0. 5/6+0/8} ~ ~
CRISP MEMBERSHIP FUCNTIONS Ø Ø Crisp membership functions ( ) are either one or zero. Consider the example: Numbers greater than 10. The membership curve for the set A is given by
REPRESENTING A DOMAIN IN FUZZY LOGIC
FUZZY MEMBERSHIP FUCNTIONS
RELATIONS Ø Relations represent mappings between sets and connectives in logic. Ø A classical binary relation represents the presence or absence of a connection or interaction or association between the elements of two sets. Ø Fuzzy binary relations are a generalization of crisp binary relations, and they allow various degrees of relationship (association) between elements.
CRISP CARTESIAN PRODUCT
CRISP RELATIONS
CLASSICAL EQUIVALENCE RELATION
t-norm
t-conorm
The basic t-norms and conorms
Linguistic Variables A numerical variables takes numerical values: Age = 65 A linguistic variables takes linguistic values: Age is old A linguistic values is a fuzzy set. All linguistic values form a term set: T(age) = {young, not young, very young, . . . middle aged, not middle aged, . . . old, not old, very old, more or less old, . . . not very yound and not very old, . . . }
Fuzzy Rules and Fuzzy Reasoning What is a fuzzy rule? A fuzzy rule can be defined as a conditional statement in the form: IF x is A THEN y is B where x and y are linguistic variables; and A and B are linguistic values determined by fuzzy sets on the universe of discourses X and Y, respectively. 127
Fuzzy Rules and Fuzzy Reasoning Linguistic variables n n n 128 At the root of fuzzy set theory lies the idea of linguistic variables. A linguistic variable is a fuzzy variable. For example, the statement “John is tall” implies that the linguistic variable John takes the linguistic value tall. The range of possible values of a linguistic variable represents the universe of discourse of that variable. For example, the universe of discourse of the linguistic variable speed might have the range between 0 and 220 km/h and may include such fuzzy subsets as very slow, medium, fast, and very fast. 128
Fuzzy Rules and Fuzzy Reasoning n Hedges are terms that modify the shape of fuzzy sets. They include adverbs such as very, somewhat, quite, more or less and slightly. IF height is very tall THEN weight is very heavy IF speed is very slow THEN stopping_distance is very short 129
Fuzzy Rules and Fuzzy Reasoning Linguistic Values (Terms) 130 complv. m
Fuzzy Rules and Fuzzy Reasoning What is the difference between classical and fuzzy rules? A classical IF-THEN rule uses binary logic, for Rule: 1 IF speed is > 100 THEN Min_stopping_Dist = 300 Rule: 2 IF speed is < 40 THEN Max_stopping_distance = 40 The variable speed can have any numerical value between 0 and 220 km/h, and stopping_distance can take either value 300 or 40. In other words, classical rules are expressed in the black-and-white language of Boolean logic. 131
Fuzzy Rules and Fuzzy Reasoning We can also represent the stopping distance rules in a fuzzy form: Rule: 2 Rule: 1 IF speed is slow IF speed is fast THEN stopping_distance is long THEN stopping_distance is short In fuzzy rules, the linguistic variable speed also has the range (the universe of discourse) between 0 and 220 km/h, but this range includes fuzzy sets, such as slow, medium and fast. The universe of discourse of the linguistic variable stopping_distance can be between 0 and 300 m and may include such fuzzy sets as short, medium and long. 132
Fuzzy Rules and Fuzzy Reasoning A fuzzy rule can have multiple antecedents, for example: IF AND THEN project_duration is long project_staffing is large project_funding is inadequate risk is high IF service is excellent OR food is delicious THEN tip is generous 133
Fuzzy Rules and Fuzzy Reasoning OR Multiple Consequents IF THEN 134 temperature is hot_water is reduced; cold_water is increased 134
Fuzzy Rules and Fuzzy Reasoning 135
Fuzzy Rules and Fuzzy Reasoning 136
- Slides: 136