Crisp and Fuzzy Logic
Crisp and Fuzzy Logic
of
a grade of membership
are together a subset of the universal base set
by its
of a fuzzy set
of
Fuzzy Logic
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
304
(3)
is used. Each fuzzy set is completely and uniquely defined by one particular membership
function. Consequently symbols of membership functions are also used as labels of the
associated fuzzy sets. That is, each fuzzy set and the associated membership function are denoted
by the same capital letter. Since crisp sets and the associated characteristic functions may be
viewed, respectively, as special cases of fuzzy sets and membership functions, the same notation
is used for crisp sets as well, see Figure 1
The base set
is introduced first above as a universal set. In practical applications, physical or
similar quantities are considered that are defined in some interval. When such quantities are
described by sets, a base sets can be generalized seamless to a crisp base set
that exists in a defined interval. This is a generalization of fuzzy sets.
Base sets are not always crisp sets. Another generalisation is that the base set is itself a fuzzy set.
This is necessary for multi-dimensional fuzzy sets, which are discussed later in this chapter.
3. Membership functions
The membership function
of the base
set
a large class of functions can be taken.
Reasonable functions are often piecewise linear functions, such as triangular or trapezoidal
functions.
The
grade of membership
describes for the special
element
. This value is in the unit
interval
, such
that
. This case is shown in Figure
3.
in the fuzzy set
characterizes the grade of membership of
. Of course,
Figure 2: Membership functions of a crisp set
, to which grade it belongs to the fuzzy set
, whereby for
can simultaneously belong to another fuzzy set
describes the membership of the elements
of a membership function
and a fuzzy set
to
In the following, a set of important properties and characteristics of fuzzy sets will be described.
• Having two fuzzy sets
Fuzzy Logic
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
305
that have
nonzero membership grades in
, and it
is subnormal when
.
• The support of a fuzzy set
(7)
An illustration is shown in Figure 4. Figure 3: Membership grades of
if their membership
functions are equal, i.e.
(4)
• The universal set
is defined as
(5)
• The height of a fuzzy set
is the largest membership grade obtained by any element in that
set, i.e.
(6)
• A fuzzy set
Figure 4: Some characteristics of a membership function
is called normal when
in the sets
is the crisp set that contains all the elements of
and
based on
, i.e.
and
:
, then both are equal
and
Fuzzy Logic
(11)
• This set is called a singleton .
The type of representation of the membership function depends on the base set. If this set
consists of many values, or is the base set a continuum, then a parametric representation is
appropriate. For that functions are used that can be adapted by changing the parameters.
Piecewise linear membership functions are preferred, because of their simplicity and efficiency
with respect to computability. Mostly these are trapezoidal or triangular functions, which are
defined by four and three parameters, respectively. Figure 4
shows a
trapezoidal function formally described by
(12)
which migrates for the case
into a triangular membership function. For some
applications the modelling requires continuously differentiable curves and therefore smooth
transitions, which the trapezoids do not have. Here, for example, three of these functions are
mentioned, which are shown in Figure 5.
Figure 5: Membership functions with smooth transitions (Eqs.(13) to (15))
These are
• The normalised Gaussian function (Figure 5a)
(8)
• The boundary is the crisp set that contains all the elements of
(9)
• Having two fuzzy sets
(10)
• If the support of a normal fuzzy set consists of a single element
that have the
membership grades of
, which has the property
that have the membership grades of one in
and
if based on
and
is the crisp set that contains all the elements of
in
, i.e.
, then both are similar
, i.e.
of
Fuzzy Logic
and
(fuzzy AND connective) can be represented as the algebraic
product of two fuzzy sets
, which is defined as the multiplication of
their membership functions:
(fuzzy OR connective) can be represented as the algebraic sum of
two fuzzy sets
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
307
with the
membership function
(fuzzy AND connective) applied to two fuzzy
sets
(19)
• The fuzzy union operator
is
(16)
• The fuzzy union operator
is
(17)
• The fuzzy complement (fuzzy NOT operation) applied to the fuzzy set
(13)
• The difference of two
sigmoidal functions (Figure 5b)
(14)
• And the generalised
bell function (Figure 5c)
(15)
4. Elementary operators for fuzzy sets
The basic connective operations in classical set theory are those of intersection, union and
complement. These operations on characteristic functions can be generalized to fuzzy sets in
more than one way. However, one particular generalization, which results in operations that are
usually referred to us as standard fuzzy set operations, has a special significance in fuzzy set
theory. In the following, only the standard operations are introduced. The following operations
can be defined:
• The fuzzy intersection operator
is
(18)
Whilst the operations according to Eqs. (16) and (17) are based on min/max operations, the
complement is an algebraic one. Union and intersection can also be defined in an algebraic
manner but giving different results as:
• The fuzzy intersection operator
(20)
The standard connective operations for fuzzy sets are now defined. As one can easily see, these
operations perform precisely as the corresponding operations for crisp sets when the
and
with the membership functions
with the membership functions
(fuzzy OR connective) applied to two fuzzy sets
and
, which is defined as:
and
and
and
Fuzzy Logic
and
The success of this controller is due to the combination of the properties, that it is simple, robust
and does not require a complex process model. The model is: when the heat is on, the
temperature rises slowly, and when the heat is off, the temperature falls slowly. The two
IF-THEN clauses above can also be formally rewritten as
IF
In the thermostat example there is only one input variable (linguistic variable), the temperature.
In the general case, there are several input variables, so, in addition to the logical connective
IF-THEN, another logical connective is needed, AND. Then the IF- THEN clauses are
IF is AND is ... AND is THEN is .
Here,
are words from natural language
(linguistic terms), like ``below set point'', ``on'', ``small'', ``large'', ``approximately 1.5'', etc. If
the standard mathematical notation for IF-THEN and AND is used, the above rules can be
re-formulated as follows:
(21)
where
. The set of rules is usually called a rule base. The left-hand side of a rule is
called premise, the right-hand side conclusion and the rule itself implication. . The set of rules is
usually called a rule base. The left-hand side of a rule is called premise, the right- hand side
conclusion and the rule itself implication.
The general idea is to represent the rule base in a computer. It has a clear structure. A rule base
consists of rules and each rule, in its turn, is obtained from properties expressed by linguistic
variables and terms and using logical connectives. In view of this structure, it is reasonable to
represent the rule base by first representing the basic elements of the rule base, premises and
conclusions, and then by extending this representation to the rule base as a whole. It makes sense
to use the following steps in the methodology:
1. Representation of the basic properties
. 2. Representation of the logical
connectives. 3. The representation of the basic properties and of the logical connectives is used
to
get the representations of all the rules. 4. Combination of the representations of different
rules into a representation of a rule
base.
As a result of these four steps, one obtains an expert system that can give advise for a specialist,
who has to make a decision. In control, a system to automatically make a decision based on its
own conclusions is wanted. Therefore, for control situations, a fifth follow-up step is needed.
Based on facts for and on the rule base a reasoning procedure makes a decision.
Fuzzy Logic
is
THEN
is
and
and
for
Fuzzy Logic
6. Fuzzy relations
First, relations are explained by a simple example from daily life using discrete fuzzy sets.
Let us describe the relationship between the colour of a fruit and characterise thelinguistic
variable colour by a crisp set
with three linguistic terms as
green
And similarly the grade of maturity as
verdant
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
red 0 0.2 1
where there are now real numbers in
. This table represents a fuzzy relation and models
the connectives in a fuzzy rule base. It is a two-dimensional fuzzy set and the question now is,
how can this set be determined from its elements.
In order to do this, the elements are generalized. In the above example, the linguistic terms where
treated as crisp terms. For example, when one represents the colours on a colour spectrum scale,
the colours would be described by their spectral distribution curves that can be interpreted as
membership functions and then a particular colour is a fuzzy term. Treating also the grades of
maturity as fuzzy terms, the above relation is a two-dimensional fuzzy set over two fuzzy sets.
For example, taking from the fruit example the relation between the linguistic terms red and
mature , and represent them by the membership functions as shown in Figure 6a, a fruit can be
characterized by the
Figure 6: Relation between two fuzzy sets: (a) membership functions, (b) 3-D view of the membership
functions, (c) membership function of the relation after applying the
operation to (b)
property red AND mature . This expression can be re-written in mathematical form using
elementary connective operators (see Eqs. (16) or (19)) for the membership functions by
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
311
or
(23)
(22)
Fuzzy Logic
Figure 6b shows a 3-dimensional view of these two fuzzy terms and Figure 6c the result of the
connective operation according to Eq.(22). This result combines the two fuzzy sets by an
operation that is a Cartesian product
(24)
From this example it is obvious that the connective operation in a rule for the
operation is
simply performed by a fuzzy intersection in two dimensions. For this, both intersection operators
from Eqs. (16) or (19) can be used.
Combining rules into a
rule base the example from above may help when it is rewritten as (1)
IF the colour is green THEN the fruit is verdant OR
(2)
IF the colour is yellow THEN the fruit is half-mature OR (3) IF the colour is red THEN the
fruit is mature
Which describes in a linguistic way a union of three rules. For the complete rule base
one can combine the relations formed for each individual rule with a fuzzy union operator,
which is the fuzzy OR according to Eqs. (17) or (22).
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
312
(25)
Where
th rule. This representation is the standard
max/min representation of a
rule base that will be later used for fuzzy controllers. Instead of the
max/min representation a so called max-prod representation is also usual, where the algebraic
product
(26)
is used to build the relation between the premise and the conclusion.
7. Fuzzy composition
Explaining reasoning by the fruit example, it is assumed that one has a crisp fact: a green fruit.
The decision from the rule base is obvious: the fruit is verdant, and this is similar for the other
facts: yellow and red. But if one has a fact like: the fruit is orange, one does not know how to
determine which rule fires the decision and what the decision is. In the following, a new fuzzy
operation type is introduced, that allows to operate with a given fact and a fuzzy relation to
produce an output that represents the decision in a fuzzy way. This operation is called fuzzy
reasoning, which is a special case of the more general operation called fuzzy composition .
Two relations of the form given in Eq. (24)
is the premise of the
Fuzzy Logic
a maturity-taste relation
is now interpreted as a rule base and the fuzzy set
Fuzzy Logic
is obtained. The result is obvious from the first rule of the rule base
. When a different
colour is taken than included in the rule base entries, say orange as
then there is no problem to obtain the value for the maturity
by applying the composition formula. The reasoning process is now solved. In the same manner
as relations can be composed, the one-dimensional facts can be composed with the
rule base to realise the reasoning operation. This can now be precisely
re-formulated for the general case of a rule base. If for the
rule base
its membership function is described by Eq. (25) or (26) and if there is a fact described by the
fuzzy set
and its membership function
of the fuzzy reasoning is represented by the membership function
(28)
8. Fuzzy Systems
The idea of a fuzzy system is introduced here. Its main components are described and discussed
in detail using examples. The results from the fuzzification module drives the rule base. The
fuzzy inference machine is developed which solves the reasoning. The methods to transform the
fuzzy results of the reasoning process to crisp data is shown in detail. The mainstream in the
fuzzy system of this module is the Mamdani approach which needs the defuzzification step, but
the Takagi-Sugeno-type of fuzzy system is also introduced which avoids defuzzification.
In the previous section, elementary fuzzy terms and fuzzy logic operations have been introduced.
In this section, the application to the treatment of rule-based knowledge follows. For this a
rule-based fuzzy system is needed, containing a rule base and a
reasoning algorithm, which is used to process crisp or fuzzy input values
to
a crisp or fuzzy output value
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
314
Figure 10:
Fuzzy inference example: (a) inference with rule 1, (b) with rule 2, and (c) final fuzzy
set
with rule 1 cuts the membership function
by this line (yellow area). The rule 2 is
evaluated analogously, as shown in Figure 10b. Figure 10c shows the final result from the union
operation over all yellow areas from the inferences obtained with the individual rules.
rule The inference shown above is based on the max/min representation of a
base from Eq.
(25). Taking alternatively the max-prod representation from Eq. (26)
is obtained for the max-prod inference. The difference between the max/min and max-prod
inference is that in the first case the membership function of the conclusion is cut and in the
second case scaled. Figure 11 illustrates this.
Figure 11:
Example:
the
inference of the two fuzzy rules
should be evaluated. The linguistic term S stands for ``small'', M for ``medium'', L for ``large'', N
for ``negative'' and P for ``positive''.
Each rule contains two premises, which are differently connected. In rule 1 the connective
operation is the intersection, which can be performed by the
operation according to
Eq. (18) for
, and in rule 2 the premise is a union of the two
premises
operation according
to Eq. (19) for
. In the first case the degree of relevance
is
. The membership functions of the
conclusion of each rule will be determined using the degree of relevance of the corresponding
rule by applying either the max/min inference method according to Eq. (29) or the max-prod
inference method according to Eq. (30). The reasoning process using both inference methods is
visualised in Figure 12.
Figure 12: Example of the application with two premises with (a) max/min inference and (b) max- prod
inference
Fuzzy Logic
Membership function of a conclusion using (a) max/min and (b) max-prod inference
For a fuzzy system with the two inputs
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
319
N) and
and in the second case
and
and
S), which can be performed by the
and
and the output
Fuzzy Logic
11. Defuzzification
As a result of applying the previous steps, one obtains a fuzzy set
from the
reasoning process that describes, for each possible value
, how reasonable it is to use this
particular value. In other words, for every possible value
, one gets a grade of
membership that describes to what extent this value
is reasonable to use. Using a fuzzy
system as a controller, one wants to transform this fuzzy information into a single value
that will actually be applied. This transformation from a fuzzy set to a crisp number is called a
defuzzification . It is not a unique operation as different approaches are possible. The most
important ones for control are described in the following.
(i) Centre of gravity method (COG)
This approach has its origin in the idea to select a value
that, on average, would lead to the
smallest error in the sense of a criterion. If
, then
the error is
the least squares method can be used. As weights
for each square
is a
reasonable value. As a result one has to find
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
320
(31)
Differentiating with respect to the unknown
and equating the derivative to zero, the formula
(32)
is obtained, which determines the value of the abscissa of the centre of gravity of the area
below the membership function
.
(ii) Centre of singleton method (COS)
The defuzzification can be strongly simplified if the membership functions
of the
conclusions are singly defuzzified for each rule such that each function is reduced to
a singleton that has the position
of the individual membership function's centre of gravity.
The centre of singletons is calculated by using the degree of relevance as follows:
(16.6)
The simplification consists in that the singletons can be determined already during the
design of the fuzzy system and that the membership function
with its complicated
geometry is no longer needed. The defuzzification using this formula is an approximation of the
defuzzification by Eq. (32). Experiences from control show that there are slight differences
between both approaches, which can be in most cases neglected.
. Thus, to determine
, one can take the grade of membership
is chosen, and the best value is
with which
(iii) Maximum methods
This class of methods determines
by selecting the membership function with the maximum
value. If the maximum is a range, either the lower, upper or the middle value is taken for
depending on the method. Using these methods, the rule with the maximum activity
always determines the value, and therefore they show discontinuous and step output on
continuous input. This is the reason why these types of method are not attractive for use in
controllers.
(iv) Margin properties of the centroid methods
As the centre of gravity of the area below the membership functions cannot reach the margins of
, the membership functions, which are at the margins, must be symmetrically
expanded when obtaining the centre of gravity. This is necessary in order to have the full range
of
available. This is shown in Figure 13. The same expansion is also necessary for the
COS method.
Figure 13: Margin of
Fuzzy Logic
Winter School on "Data Mining Techniques and Tools for Knowledge Discovery in Agricultural Datasets”
321