2.5 Fuzzy Logic
2.5.1 Fuzzy sets and Crispy sets: general concepts
Starczewski, (2013) proposed an enlightening mathematical description of fuzzy logic and, in this section, the definitions are extracted from his book while the examples are original.
There are five steps to use the fuzzy logic (Sivanandam, Sumathi, and Deepa,2006, page 121):
1. fuzzify the inputs; 2. identify the fuzzy rules;
3. combine the inputs and the rules to calculate the truth degree of each rule;
4. identify an output distribution;
5. defuzzify the output distribution to obtain a crisp value (optional). In figure 2.10, a classical block-schema of fuzzy logic is reported. The input fuzzification is performed by the fuzzifier, the rule-based knowledge storage consists of the rule base, the inference engine com- bines fuzzified input and identifies the output distribution, while the defuzzifier produces a synthetic crisp output.
FIGURE 2.10: Fuzzy logic system, adapted from (Star-
czewski,2013), page 138
These aspects will be discussed with a rigorous mathematical ap- proach in this section and better explained with a numeric example in sectionA.
Membership Degree and fuzzification
Definition: “Let X be a non-empty set. A fuzzy set A in X is charac- terised by its membership function” (Starczewski, (2013), page 1)
This means that, for each element of A, there is a membership func- tion that defines its degree of membership µ to the classes, also called linguistic variables (equation2.7).
µ ∈ [0 : 1]
µ = 0,the element does not belongs to the class µ = 1,the element entirely belongs to the class 0 < µ < 1,the element partially belongs to the class
(2.7)
For example, let’s assume 2 fuzzy sets: ’Young’ and ’Old’. A new- born belongs to the class ’Young’ with µ = 1, and he belongs to the class ’Old’ with µ = 0. A 80-year-old man belongs to the class ’Young’ with µ = 0, and to the class ’Old’ with µ = 1. A 35-years old man belongs partially to the class ’Young’ and partially to the class ’Old’ (for example
µY oung = 0.65and µOld = 0.35). The attribution of the membership val-
ues depends on the membership function definition. Figure2.11shows an example of membership function in which there are 2 classes (Young and Old) and the age (on the x-axes) enables , for each class, the cal- culation of the corresponding value of the membership factor (on the y-axis).
Definition: “A kernel of A, being a fuzzy subset of X, denoted by ker (A), is the ordinary subset of X whose all elements have membership grades equal to unity in A” (Starczewski, (2013),page 2).
ker(A) = {x ∈ X|µA(x) = 1} (2.8)
In the example of figure 2.11, the kernel of the class Young corre- sponds to the region between 0 and 10 years of age. In this region of age, the individuals are 100% belonging to the class ’Young’.
0 20 40 60 80 0.0 0.2 0.4 0.6 0.8 1.0 Age Membership f actor Young Old
FIGURE2.11: Membership function: example. There are
2 classes(Young and Old) and the age (on the x-axes) en- ables , for each class, the calculation of the corresponding
value of the membership factor (on the y-axis).
by support (A), is the ordinary subset of X whose all elements have positive membership grades in A” (Starczewski, (2013), pag.2).
support(A) = {x ∈ X|µA(x) > 0} (2.9)
In figure2.11, the support of the class ’Young’ corresponds to a range of age between 0 and 70 years. In this range, the class ’Young’ is still represented even if, when approaching the age of 70 years, the values of the membership factor are close to 0.
An input can be transformed in pairs of linguistic variables and membership factors. So for example, the age 35 could be read in fuzzy logic as (’Young’,µ = 0.65) or (’Old’,µ = 0.35). This transformation pro- cess of the input (in the example the age) in fuzzy language is called fuzzification.
In conclusion, the use of membership degree enables the represen- tation of sets affected by vagueness and uncertainty with continuous functions, without increasing the number of classes. Zadeh,1988 pro- posed a mathematical approach to process fuzzy information using the membership degree. This approach will be presented in the following
subsections.
Rule base
The fuzzy algorithms require human-language-like rules to process the information at the input. A rule is composed by an IF/THEN structure with one or more input variables , and one variable at the output. For example, a set of fuzzy rules1 could assume this form:
IFcar_ageISnewANDmotorIShigh_powerTHENpriceIShigh
IFcar_ageISnewANDmotorISlow_powerTHENpriceISmedium
IFcar_ageISoldANDmotorIShigh_powerTHENpriceISmedium
IFcar_ageISoldANDmotorISlow_powerTHENpriceISlow (2.10) In this case, there are two inputs (car age and motor typology) and one output (car price). In order to use the fuzzy rules, the input needs to be fuzzified as explained in the section Memebership Degree and fuzzi- fication.
Rule implication: calculation of rule truth degree
The rules are based on a set of logic operators that connect the fuzzified input: AND, OR,NOT. Table 2.8 reports some common alternatives to define AND and OR logical operators with the probabilistic and the Zahed’ approach. In fuzzy algorithms, this choice is customizable. The operator NOT, not reported in table2.8is always defined as:
(µA(x)) = 1 − µA(x)
The use of fuzzy operators to analyse a rule is generally called im- plication. With this operation, a truth degree is conferred to each rule. This truth degree expresses how much, according to the given inputs, the rule represents the condition of the system under analysis.
1The set of rules (2.10) is invented by the author of this thesis for the numerical
TABLE2.8: Operator in fuzzy sets -extract from (Dernon-
court,2013)
Name AND-Intersection OR-Union
Zahed Operator µA∩B(x) = min(µA(x), µB(x)) µA(x)∪B(x)= max(µA(x), µB(x))
Probabilistic µA∩B(x) = µA(x) ∗ µB(x) µA(x)∪B(x)= µA(x) + µB(x) − (µA(x) ∗ µB(x))
Identification of rule consequence
The rule consequence is the part of the rule after the ’THEN’ logical op- erator. For example, in the system of fuzzy rules (2.10), ’price IS high’ is the consequence of the first rule. The fuzzy logic algorithm needs a mathematical definition of the consequence. This is generally per- formed with two alternative approaches (Sivanandam, Sumathi, and Deepa,2006, pag.119):
• Mamdani’s fuzzy inference method
• Takagi–Sugeno–Kang inference method (often referred as Sugeno) In the Mamdani method, as for the input, the rule consequence is a fuzzy set. Figure2.12shows an example of the fuzzy output for the car price of the set of rules in equation2.10).
In the Mamdani method, the output result is the result of a linear equation depending on the input variables.
In the case of Sugeno approach, the rules are a bit different. For example, the first rule of the example2.10could assume this form:
IFcar_ageISnewANDmotorIShigh_powerTHENpriceISf(car_age,motor) The element f(car_age,motor) is a function depending on car age and
motor type, for example, like in equation2.112, in which ’motor’ is the
motor engine power expressed in hp and the car age is expressed in years.
P rice = f (car_age, motor) = 100 ∗ motor − car_age ∗ 2000 (2.11)
5000 10000 15000 20000 0.0 0.2 0.4 0.6 0.8 1.0 Price membership f actor Low Medium High
FIGURE2.12: Example: Mamdani method for the defini-
tion of rule consequences
Defuzzification
When a degree of truth is defined for each rule, it is necessary to aggre- gate these results to have an overall representative value of the output. This process, called defuzzification, can be performed through two al- gorithms:
• mean of maxima (MeOM), generally associated only with the Mam- dani approach;
• method of centre of gravity (COG).
The output, calculated as mean of maximum MeOM, is the result of equation2.12, in which z values are the values of the output for which the truth degree of the rules is maximum and ’l’ is the number of the rule(s) with higher membership factor. In the simplest case, there is just one dominant rule and l=1.
M eOM = Pl
j=1zj
The COG is calculated as weighted average between the outputs of the rules weighted on their truth degrees. In equation2.13, zj is the j-value
of the output and tj(zj)is the truth degree of the rules associated to zj.
In the equation2.13, ’j’ represent the j-equation.
COG = PN j=1zj∗ tj(zj) PN j=1tj(zj) (2.13)