Transcription of Fuzzy Logic Notes - Trinity College Dublin
1 Fuzzy Logic NotesCourse:Khurshid Ahmad 2010 Typset:Cathal OrmondApril 25, 2011 Contents1 Computers .. Problems .. Example: motion Detection .. Solution ..32 Introduction to Fuzzy Fuzzy Sets .. Fuzzy Logic ..43 Fuzzy Introduction .. Definitions on Fuzzy Sets .. Operations on Fuzzy Sets .. Membership Functions .. Fuzzy Relationships .. Rules and Patches ..94 Knowledge Knowledge-Based Systems .. Linguistic Variable .. Defuzzification Techniques .. 145 Fuzzy Conventional Control .. Fuzzy Controller .. 181 Chapter ComputersComputers aid us with many areas of life from astronomy to banking to rocket science. However,they have their drawbacks. Computer systems cannot satisfactorily manage information flowingacross a hospital, for example.
2 The introduction of computer systems for public administration hasinvariably generated chaos. Computer systems have been found responsible for disasters like flooddamage, fire control and so ProblemsSo why can t the computers do what we want them to? Problems in engineering software: specification, design, and testing. Algorithms (the basis of computer programs) cannot deal with partial information, with un-certainty. Much of human information processing relies significantly on approximate Example: motion DetectionSuppose we create a robot that will react to certain situations, displaying emotions. We will dealwith the motion of intruders relative to the robot. We wish it to have the following basic emotions:PerceptionEmotionIf the intruder is far awaythere is no fearIf the intruder is nearthere is no surpriseIf the intruder is stationarythere is no fearIf the intruder is moving fastthere is no angerThis is perhaps better expressed as follows:2 StationaryFastNearVery angry, not surprised, no fearNot angry, not surprised, very fearfulFarVery angry, not surprised, no fearNot angry, very surprised, no fearHowever, near and far are quite relative terms, as is fast.
3 We ll consider a more accurate set ofemotions:StationarySlowFastVery NearVA, NS, NFA, NS, FNA, NS, VFNearA, NS, NFNA, NS, FNA, S, FFarVA, NS, NFA, S, NFNA, VS, NFwhere V means very, N means not, A means angry, S means surprised and F means fearful. We canmake the terms of speed and distance more specific still, and this will give us different combinationsof SolutionThe solution to the above problem of computers issoft computing:Soft computing differs from conventional (hard) computing in that, unlike hardcomputing, it is tolerant of imprecision, uncertainty, partial truth, and effect, the role model for soft computing is the human mind. The guiding principleof soft computing is: Exploit the tolerance for imprecision, uncertainty, partial truth,and approximation to achieve tractability, robustness and low solution computing is used as an umbrella term for sub-disciplines of computing, including Fuzzy logicand Fuzzy control, neural networks based computing and machine learning, and genetic algorithms,together with chaos theory in 2 Introduction to Fuzzy LogicFuzzy Logic is being developed as a discipline to meet two objectives: As a professional subject dedicated to the building of systems of high utility - for examplefuzzy control.
4 As a theoretical subject - Fuzzy Logic is symbolic Logic with a comparative notion of truthdeveloped fully in the spirit of classical Logic . It is a branch of many-valued Logic based onthe paradigm of inference under vagueness. Fuzzy SetsAFuzzy setis a set whose elements have degrees of membership. Fuzzy sets are an extensionof the classical notion of set (known as aCrisp Set). More mathematically, a Fuzzy set is a pair(A, A) whereAis a set and A:A [0,1]. For allx A, A(x) is called the grade of A(x) = 1, we say thatxisFully Includedin (A, A), and if A(x) = 0, we say thatxisNot Includedin (A, A). If there exists somex Asuch that A(x) = 1, we say that (A, A)isNormal. Otherwise, we say that (A, A) Fuzzy LogicFuzzy Logicis a form of multi-valued Logic derived from Fuzzy set theory to deal with reasoningthat is approximate rather than precise.
5 Fuzzy Logic is not a vague Logic system, but a system oflogic for dealing with vague in Fuzzy set theory the set membership values can range (inclusively) between 0 and 1, infuzzy Logic the degree of truth of a statement can range between 0 and 1 and is not constrained tothe two truth values true/false as in classic predicate Examples of Fuzzy LogicIn a Fuzzy Logic washing machine, Fuzzy Logic detects the type and amount of laundry in thedrum and allows only as much water to enter the machine as is really needed for the loaded , less water will heat up quicker - which means less energy consumption. Additional properties: Foam detection: Too much foam is compensated by an additional rinse cycle. Imbalance compensation: In the event of imbalance calculate the maximum possible speed,sets this speed and starts spinning.
6 Water level adjustment: Fuzzy automatic water level adjustment adapts water and en-ergy consumption to the individual requirements of each wash programme, depending on theamount of laundry and type of Other ExamplesOther examples of uses of Fuzzy Logic are: Food cookers Taking blood pressure Determination of socio-economic class Cars5 Chapter 3 Fuzzy IntroductionAFuzzy Systemcan be contrasted with a conventional (crisp) system in three main ways: ALinguistic Variableis defined as a variable whose values are sentences in a natural orartificial language. Thus, if tall , not tall , very tall , very very tall , etc. are values ofheight, thenheightis a linguistic variable. Fuzzy Conditional Statementsare expressions of the form If A THEN B , where Aand B have Fuzzy meaning, If x is small THEN y is large , where small and large areviewed as labels of Fuzzy sets.
7 AFuzzy Algorithmis an ordered sequence of instructions which may contain Fuzzy assign-ment and conditional statements, , x = very small, IF x is small THEN y is large . Theexecution of such instructions is governed by the compositional rule of inference and the ruleof the preponderant Return to Fuzzy SetsFor the sake of convenience, usually a Fuzzy set is denoted as:A= A(x1)/x1+ + A(xn)/xnthat belongs to a finite universe of discourse:A {x1,x2,..,xn}=Xwhere A(xi)/xi(a singleton) is a pair grade of membership element . ExampleConsiderX={1,2,..,10}. Suppose a child is asked which of the numbers inXare large relative to the others. The child might come up with the following:6 NumberCommentDegree10 Definitely19 Definitely18 Quite , 4, 3, 2, 1 Definitely Not0 From this, we can define some new terms using different membership functions:Small B= 1 AVery Large C= ( A)2 Large-ish D= Definitions on Fuzzy SetsWe have the following definitions for two Fuzzy sets (A, A) and (B, B), whereA,B X: Equality:A=Biff A(x) = B(x) for allx X Inclusion:A Biff A(x) B(x) for allx X Cardinality:|A|=n i=1 A(xi) Empty Set:Ais empty iff A(x) = 0 for allx X.
8 -Cut: Given [0,1], the -cut ofAis defined byA ={x X| A(x) } Operations on Fuzzy SetsLet (A, A),(B, B) be a Fuzzy sets. Complementation: ( A, A), where A= 1 A Height:h(A) = maxx X A(x) Support: supp(A) ={x X| A(x)>0} Core:C(A) ={x X| A(x) = 1} Intersection:C=A B, where C= minx X{ A, B} Union:C=A B, where C= maxx X{ A, B} Bounded Sum:C=A+B, where C(x) = min{1, A(x) + B(x)} Bounded Difference:C=A B, where C(x) = max{0, A(x) B(x)}7 Exponentiation:C=A where C= ( A) for >0 Level Set:C= Awhere C= Afor [0,1] Concentration:C=A where >1 Dilation:C=A where <1 Note thatA Ais not necessarily the empty set, as would be the case with classical set , ifAis crisp, thenA =Afor all . We will define the Cartesian productA Bto be thesame asA Membership FunctionsWe will usually consider one of the following membership functions: Triangular: tri(x;a,b,c) = max{min{x ab a,c xc b},0} Trapezoidal: trap(x;a,b,c,d) = max{min{x ab a,d xd c,1},0} Gaussian: gauss(x;c, ) = exp[ 12(x c )2] Generalised Bell: gbell(x;a,b) =11 + x ba Fuzzy RelationshipsIn order to understand how two Fuzzy subsets are mapped onto each other to obtain a cross product,consider the example of an air-conditioning system.
9 Air-conditioning involves the delivery of airwhich can be warmed or cooled and have its humidity raised or air-conditioner is an apparatus for controlling, especially lowering, the temperature and hu-midity of an enclosed space. An air-conditioner typically has a fan which blows/cools/circulatesfresh air and has cooler and the cooler is under thermostatic control. Generally, the amount of airbeing compressed is proportional to the ambient an air-conditioner which has five control switches: cold, cool, pleasant, warm and corresponding speeds of the motor controlling the fan on the air-conditioner has the gradua-tions: minimal, slow, medium, fast, blast. The rules governing the air-conditioner are as follows:8 RuleTemperatureSpeed1 IFColdTHENM inimal2 CoolSlow3 PleasantMedium4 WarmFast5 HotBlastHence, we can regard our rules as the cross product of temperature and Rules and PatchesAFuzzy Patchis defined by a Fuzzy rule: a patch is a mapping of two membership functions, itis a product of two geometrical objects, line segments, triangles, squares a Fuzzy controller, a rule in the rule set of the controller can be visualized as a device forgenerating the product of the input/output Fuzzy a patch is an area that represents the causal association between the cause (theinputs) and the effect (the outputs).
10 The size of the patch indicates the vagueness implicit in therule as expressed through the membership functions of the inputs and total area occupied by a patch is an indication of the vagueness of a given rule that canbe used to generate the a one-input-one output rule: if the input is crisp and the output is Fuzzy then the patchbecomes a line. And, if both are crisp sets then the patch is vanishingly small - a 4 Knowledge RepresentationOnce we have found that the knowledge of a specialism can be expressed through linguistic variablesand rules of thumb, that involve imprecise antecedents and consequents, then we have a basis ofa knowledge-base. In this knowledge-base facts are represented through linguistic variables andthe rules follow Fuzzy Logic . In traditional expert systems facts are stated crisply and rules followclassical propositional problem is that in the real world some of our knowledge of facts is derived from the use ofsensors:quantity of heatmeasured in degrees Centigrade,lengthmeasured in meters,weight(thequantity of matter) measured in grams, etc.