A Mamdani Type Fuzzy Logic Controller

The database of a rule-based systemmay contain imprecisionswhich appear in the description of the rules given by the expert. Because such an inference can not be made by the methods which use classical two valued logic or many valued logic, Zadeh in (Zadeh, 1975) and Mamdani in (Mamdani, 1977) suggested an inference rule called "compositional rule of inference". Using this inference rule, several methods for fuzzy reasoning were proposed. Zadeh (Zadeh, 1979) extends the traditional Modus Ponens rule in order to work with fuzzy sets, obtaining the Generalized Modus Ponens (GMP) rule.


Introduction
The database of a rule-based system may contain imprecisions which appear in the description of the rules given by the expert.Because such an inference can not be made by the methods which use classical two valued logic or many valued logic, Zadeh in (Zadeh, 1975) and Mamdani in (Mamdani, 1977) suggested an inference rule called "compositional rule of inference".Using this inference rule, several methods for fuzzy reasoning were proposed.Zadeh (Zadeh, 1979) extends the traditional Modus Ponens rule in order to work with fuzzy sets, obtaining the Generalized Modus Ponens (GMP) rule.
An important part of fuzzy reasoning is represented by Fuzzy Logic Control (FLC), derived from control theory based on mathematical models of the open-loop process to be controlled.Fuzzy Logic Control has been successfully applied to a wide variety of practical problems: control of warm water, robot, heat exchange, traffic junction, cement kiln, automobile speed, automotive engineering, model car parking and turning, power system and nuclear reactor, on-line shopping, washing machines, etc.
It points out that fuzzy control has been effectively used in the context of complex ill-defined processes, especially those that can be controlled by a skilled human operator without the knowledge of their underlying dynamics.In this sense, neural and adaptive fuzzy systems has been compared to classical control methods by B. Kosko in (Kosko, 1992).There, it is remarked that they are model-free estimators, i.e., they estimate a function without requiring a mathematical description of how the output functionally depends on the input; they learn from samples.However, some people criticized fuzzy control because the very fundamental question "Why does a fuzzy rule-based system have such good performance for a wide variety of practical problems?"remained unanswered.A first approach to answer this fundamental question in a quantitative way was presented by Wang in (Wang, 1992) where he proved that a particular class of FLC systems are universal approximators: they are capable of approximating any real continuous function on a compact set to arbitrary accuracy.This class is characterized by: 1) Gaussian membership functions, 2) Product fuzzy conjunction, 3) Product fuzzy implication, 4) Center of area defuzzification.
Other approaches are due to Buckley (Buckley, 1992;1993).He has proved that a modification of Sugeno type fuzzy controllers gives universal approximators.Although both results are very important, many real fuzzy logic controllers do not belong to these classes, because other membership functions are used, other inference mechanisms are applied or other type of rules are used.The question "What other types of fuzzy logic controllers are universal approximators?" still remained unanswered.This problem were solved by Castro in (Castro, 1995) where he proved that a large number of classes of FLC systems are also universal approximators.
The most popular FLC systems are: Mamdani, Tsukamoto, Sugeno and Larsen which work with crisp data as inputs.An extension of the Mamdani model in order to work with interval inputs is presented in (Liu et al., 2005) , where the fuzzy sets are represented by triangular fuzzy numbers and the firing level of the conclusion is computed as the product of firing levels from the antecedent.Other extensions and applications of the standard FLC systems were proposed in (Iancu, 2009a;b;Iancu, Colhon & Dupac, 2010;Iancu, Constantinescu & Colhon, 2010;Iancu & Popirlan, 2010).
The necessity to extend the fuzzy controllers to work with intervals or linguistic values as inputs is given by many applications where precise values of the input data no interest or are difficult to estimate.For example, in shopping applications the buyer is interested, rather, in a product that is priced within certain limits or does not exceed a given value (Liu et al., 2005).In other cases, the input values are much easier to express in fuzzy manner, for example, in the problem of controlling the washing time using fuzzy logic control the degree of dirt for the object to be washed is easily expressed by a linguistic value (Agarwal, 2007).These examples will be used to show the working of the model proposed in order to expand the Mamdani fuzzy logic controller.In this paper a FLC system with the following characteristics is presented: • the linguistic terms (or values) are represented by trapezoidal fuzzy numbers • various implication operators are used to represent the rules • the crisp control action of a rule is computed using Middle-of-Maxima method • the overall crisp control action of an implication is computed by discrete Center-of-Gravity • the overall crisp control action of the system is computed using an OWA (Ordered Weighted Averaging) operator.

Preliminaries
Let U be a collection of objects denoted generically by {u}, which could be discrete or continuous.U is called the universe of discourse and u represents the generic element of U.
Definition 1.A fuzzy set F in the universe of discourse U is characterized by its membership function Because the majority of practical applications work with trapezoidal or triangular distributions and these representations are still a subject of various recent papers ( (Grzegorzewski & Mrowka, 2007), (Nasseri, 2008), for instance) we will work with membership functions represented by trapezoidal fuzzy numbers.Such a number N = (m, m, α, β) is defined as Will be used fuzzy sets to represent linguistic variables.A linguistic variable can be regarded either as a variable whose value is a fuzzy number or as a variable whose values are defined in linguistic terms.
Definition 3. A linguistic variable V is characterized by: its name x, an universe U, a term set T(x), a syntactic rule G for generating names of values of x, and a set of semantic rule M for associating with each value its meaning.
For example, if speed of a car is interpreted as a linguistic variable, then its term set could be T(x)={slow, moderate, f ast, very slow, more or less f ast} where each term is characterized by a fuzzy set in an universe of discourse U =[ 0, 100].We might interpret: slow as "a speed below about 40 mph", moderate as "speed close to 55 mph", fast as "a speed about 70 mph".
The most important t-norms are: • Minimum: T m (x, y)=min{x, y} • Probabilistic (or Product): T P (x, y)=xy The t-norms are used to compute the firing levels of the rules or as aggregation operators and the t-conorms are used as aggregation operators.The rules are represented by fuzzy implications.Let X and Y be two variables whose domains are U and V, respectively.A causal link from X to Y is represented as a conditional possibility distribution ( (Zadeh, 1979), (Zadeh, 1978)) π Y/X which restricts the possible values of Y for a given value of X.For the rule IFXisATHENYisB where → is an implication operator and µ A and µ B are the membership functions of the fuzzy sets A and B, respectively.Definition 6.An implication is a function I : [0, 1] 2 → [0, 1] satisfying the following conditions for all x, y, z ∈ [0, 1] : The following properties could be important in some applications: Brouwer-Gödel:

r w i s e
Goguen: Definition 8.If R and S are fuzzy relations in U × V and V × W, respectively, then the sup-star composition of R and S is a fuzzy relation denoted by R • S and defined by where * can be any operator in the class of t-norms.
Fuzzy implication inference is based on the compositional rule of inference for approximate reasoning suggested by Zadeh in (Zadeh, 1973).Definition 9.If R is a fuzzy relation on U × V and x is a fuzzy set in U then the "sup-star compositional rule of inference" asserts that the fuzzy set y in V induced by x is given by (Zadeh, 1971) y = x • R where x • R is the sup-star composition of x and R.
If the star represents the minimum operator then this definition reduces to Zadeh's compositional rule of inference (Zadeh, 1973).
The process of information aggregation appears in many applications related to the development of intelligent systems: fuzzy logic controllers, neural networks, vision systems, expert systems, multi-criteria decision aids.In (Yager, 1988) Yager introduced an aggregation technique based on OWA operators.Definition 10.An OWA operator of dimension n is a mapping F : R n → R that has an associated n vector w =(w 1 , w 2 , ...., w n ) t such as

The aggregation operator of the values {a
where b j is the j-th largest element from {a 1 , a 2 , ..., a n }.
It is sufficiently to work with rules with a single conclusion because a rule with multiple consequent can be treated as a set of such rules.

Structure of a fuzzy logic controller
The seminal work by L.A. Zadeh (Zadeh, 1973) on fuzzy algorithms introduced the idea of formulating the control algorithm by logical rules.An FLC consists of a set of rules of the form Since the antecedents and the consequents of these IF-THEN rules are associated with fuzzy concepts (linguistic terms), they are often called fuzzy conditional statements.In FLC terminology, a fuzzy control rule is a fuzzy conditional statement in which the antecedent is a condition in its application domain and the consequent is a control action for the system under control.The inputs of fuzzy rule-based systems should be given by fuzzy sets, and therefore, we have to fuzzify the crisp inputs.Furthermore, the output of a fuzzy system is always a fuzzy set, and therefore to get crisp value we have to defuzzify it.Fuzzy logic control systems usually consist of four major parts: Fuzzification interface, Fuzzy rule base, Fuzzy inference engine and Defuzzification interface, as is presented in the Figure 1.A fuzzification operator has the effect of transforming crisp data into fuzzy sets.In most of the cases fuzzy singletons are used as fuzzifiers (according to Figure 2).

Fig. 2. Fuzzy singleton as fuzzifier
In other words, f uzzi f ier(x 0 )=x 0 , where x 0 is a crisp input value from a process.
The procedure used by Fuzzy Inference Engine in order to obtain a fuzzy output consists of the following steps: 1. find the firing level of each rule, 2. find the output of each rule, 3. aggregate the individual rules outputs in order to obtain the overall system output.
The fuzzy control action C inferred from the fuzzy control system is transformed into a crisp control action: where de f uzzi f ier is a defuzzification operator.The most used defuzzification operators, for a discrete fuzzy set C having the universe of discourse V,are: • Center-of-Gravity: • Middle-of-Maxima: the defuzzified value is defined as mean of all values of the universe of discourse, having maximal membership grades • Max-Criterion: this method chooses an arbitrary value, from the set of maximizing elements of C,i.e. z 0 ∈{z/µ C (z)=max where Z = {z 1 , ..., z N } is a set of elements from the universe V.
Because several linguistic variables are involved in the antecedents and the conclusions of a rule, the fuzzy system is of the type multi-input-multi-output.Further, the working with a FLC for the case of a two-input-single-output system is explained.Such a system consists of a set of rules where x and y are the process state variables, z is the control variable, A i , B i and C i are linguistic values of the linguistic variables x, y and z in the universes of discourse U, V and W, respectively.Our task is to find a crisp control action z 0 from the fuzzy rule base and from the actual crisp inputs x 0 and y 0 .A fuzzy control rule is implemented by a fuzzy implication I i and is defined as where T is a t-norm used to model the logical connective AND.To infer the consequence "zi sC " from the set of rules and the facts, usually the compositional rule of inference is applied; it gives That is Taking into account that µ x0 (u)=0 for u = x 0 and µ ȳ0 (v)=0 for v = y 0 , the membership function of C is given by for all w ∈ W.
The procedure used for obtaining the fuzzy output from a FLC system is • the firing level of the i-th rule is determined by • the overall system output, C, is obtained from the individual rule outputs, by aggregation operation:

Mamdani fuzzy logic controller
The most commonly used fuzzy inference technique is the so-called Mamdani method (Mamdani & Assilian, 1975) which was proposed, by Mamdani and Assilian, as the very first attempt to control a steam engine and boiler combination by synthesizing a set of linguistic control rules obtained from experienced human operators.Their work was inspired by an equally influential publication by Zadeh (Zadeh, 1973).Interest in fuzzy control has continued ever since, and the literature on the subject has grown rapidly.A survey of the field with fairly extensive references may be found in (Lee, 1990) or, more recently, in (Sala et al., 2005).In Mamdani's model the fuzzy implication is modeled by Mamdani's minimum operator, the conjunction operator is min, the t-norm from compositional rule is min and for the aggregation of the rules the max operator is used.In order to explain the working with this model of FLC will be considered the example from (Rakic, 2010) where a simple two-input one-output problem that includes three rules is examined: Step 1: Fuzzification The first step is to take the crisp inputs, x 0 and y 0 , and determine the degree to which these inputs belong to each of the appropriate fuzzy sets.According to Fig 3(a) one obtains

333
A Mamdani Type Fuzzy Logic Controller www.intechopen.com Step 2: Rules evaluation The fuzzified inputs are applied to the antecedents of the fuzzy rules.If a given fuzzy rule has multiple antecedents, the fuzzy operator (AND or OR) is used to obtain a single number that represents the result of the antecedent evaluation.To evaluate the disjunction of the rule antecedents, one uses the OR fuzzy operation.Typically, the classical fuzzy operation union is used : Similarly, in order to evaluate the conjunction of the rule antecedents, the AND fuzzy operation intersection is applied: The result is given in the Figure 3(b).
Now the result of the antecedent evaluation can be applied to the membership function of the consequent.The most common method is to cut the consequent membership function at the level of the antecedent truth; this method is called clipping.Because top of the membership function is sliced, the clipped fuzzy set loses some information.However, clipping is preferred because it involves less complex and generates an aggregated output surface that is easier to defuzzify.Another method, named scaling, offers a better approach for preserving the original shape of the fuzzy set: the original membership function of the rule consequent is adjusted by multiplying all its membership degrees by the truth value of the rule antecedent (see Fig.

3(c)).
Step 3: Aggregation of the rule outputs The membership functions of all rule consequents previously clipped or scaled are combined into a single fuzzy set (see Fig. 4(a)). Step

Universal approximators
Using the Stone-Weierstrass theorem, Wang in (Wang, 1992) showed that fuzzy logic control systems of the form where x 0 is the position of the peak relative to the universe and σ is the standard deviation • Larsen (fuzzy product) implication where c i is the center of C i , are universal approximators, i.e. they can approximate any continuous function on a compact set to an arbitrary accuracy.

336
Fuzzy Logic -Controls, Concepts, Theories and Applications

www.intechopen.com
More generally, Wang proved the following theorem Theorem 1.For a given real-valued continuous function g on the compact set U and arbitrary ǫ > 0, there exists a fuzzy logic control system with output function f such that Castro in (Castro, 1995) showed that Mamdani fuzzy logic controllers • Minimum norm fuzzy conjunction where c i is the center of C i , are universal approximators.
More generally, Castro (Castro, 1995) studied the following problem: Given a type of FLC, (i.e. a fuzzification method, a fuzzy inference method, a defuzzification method, and a class of fuzzy rules, are fixed), an arbitrary continuous real valued function f on a compact U ⊂ R n , and a certain ǫ > 0 , is it possible to find a set of fuzzy rules such that the associated fuzzy controller approximates f to level ǫ?
The main result obtained by Castro is that the approximation is possible for almost any type of fuzzy logic controller.

337
A Mamdani Type Fuzzy Logic Controller www.intechopen.com

Mamdani FLC with different inputs and implications
Further, the standard Mamdani FLC system will be extended to work as inputs with crisp data, intervals and linguistic terms and with various implications to represent the rules.A rule is characterized by • a set of linguistic variables A, having as domain an interval

.., A n A for each linguistic variable A
• the membership function for each value A i , denoted as µ 0 A i (x) where i ∈{1, 2, ..., n A } and x ∈ I A .
The fuzzy inference process is performed in the steps presented in the following subsections.

Fuzzification
A fuzzification operator transforms a crisp data or an interval into a fuzzy set.For instance, x 0 ∈ U is fuzzified into x 0 according with the relation:

Firing levels
The firing level of a linguistic variable A i , which appears in the premise of a rule, depends of the input data.
• For a crisp value x 0 it is µ 0 A i (x 0 ).
If the input is an interval or a linguistic term then the firing level can be computed in various forms.
A) based on "intersection" • for an input interval [a, b] it is given by: • for a linguistic input value A ′ i it is

B) based on "areas ratio"
338 Fuzzy Logic -Controls, Concepts, Theories and Applications www.intechopen.com • for an input interval [a, b] it is given by the area defined by intersection µ 0 i it is computed as in the previous case dx It is obvious that, any t-norm T can be used instead of min and its dual t-conorm S instead of max in the previous formulas.

Fuzzy inference
The fuzzy control rules are of the form i AND ... AND X r is A r i THENYisC i where the variables X j , j ∈{ 1, 2, ..., r}, and Y have the domains U j and V, respectively.The firing levels of the rules, denoted by {α i }, are computed by where T is a t-norm and α j i is the firing level for A j i , j ∈{ 1, 2, ..., r}.The causal link from X 1 , ..., X r to Y is represented using an implication operator I.It results that the conclusion gives the following results, depending on the implication I:

Defuzzification
The fuzzy output C ′ i of the rule R i is transformed into a crisp output z i using the Middle-of-Maxima operator.The crisp value z 0 associated to a conclusion C ′ inferred from a rule having the firing level α and the conclusion C represented by the fuzzy number In the last case, in order to remain inside the support of C, one can choose a value according to Max-Criterion; for instance The overall crisp control action is computed by the discrete Center-of-Gravity method as follows.If the number of fired rules is N then the final control action is: where α i is the firing level and z i is the crisp output of the i-th rule, i = 1, N.
Finally, the results obtained with various implication operators are combined in order to obtain the overall output of the system.For this reason, the "strength" λ(I) of an implication I is used: where N(I) is the number of properties (from the list I1t oI13) verified by the implication I (Iancu, 2009a).If the implications are considered in the order presented in the previous section, then according with the Definition 10, one obtains and the overall crisp action of the system is computed as where b j is the j-th largest element of {z 0 (I W ), z 0 (I M ),...,z 0 (I F ), z 0 (I R )}.

341
A Mamdani Type Fuzzy Logic Controller www.intechopen.com

Applications
In order to show how the proposed system works, two examples will be presented.First example (Iancu, 2009b) is inspired from (Liu et al., 2005).A person is interested to buy a computer using on-line shopping.For this, the customer can make selections on the price and quality of computers.For the price of computers, different intervals are given for customers to choose from, for example, 0-200 EUR, 400-600 EUR, etc.For the quality of computers, five options are offered to the customers, namely Poor, Below Average, Average, Above Average, and Good.After customers make those selections, the satisfaction score for that selected computer is computed based on the fuzzy inference system described in the following.If customers are not satisfied with the satisfaction score, they can go back and make selections again.Therefore, this system will help customers to make decisions.In the next example the system works with two inputs and one output.Because λ(I R )=11/13 and λ(I L )=1, the overall crisp action given by system is z 0 = 5.4615 The standard Mamdani model applied for this example gives the following results: • the firing levels are: α 5 = 2/3, α 6 = 0.5, α 8 = 2/3, α 9 = 0.5 • the crisp rules outputs are: z 5 = 5, z 6 = 5.25/2, z 8 = 23/3, z 9 = 5 • the overall crisp action is: z 0 = 23/3 = 7.66 If the Center-of-Gravity method (instead of maximum operator) is used to compute the overall crisp action then z 0 = 5.253 One observes an important difference between these two results and also between these results and those given by our method.An explanation consists in the small value of the "strength" of Mamdani's implication in comparison with the values associated with Reichenbach and Lukasiewicz implications; the strength of an implication is a measure of its quality.From different implications, different results will be obtained if separately implications will be used.The proposed system offers a possibility to avoid this difficulty, by aggregation operation which achieves a "mediation" between the results given by various implications.
Another application that uses this type of controller is presented in (Iancu, 2009b) concerning washing machines (Agarwal, 2007).When one uses a washing machine, the person generally select the length of washing time based on the amount of clothes he/she wish to wash and the type and degree of dirt cloths have.To automate this process, one uses sensors to detect these parameters and the washing time is then determined from this data.Unfortunately, there is no easy way to formulate a precise mathematical relationship between volume of clothes and dirt and the length of washing time required.Because the input/output relationship is not clear, the design of a washing machine controller can be made using fuzzy logic.A fuzzy logic controller gives the correct washing time even though a precise model of the input/output relationship is not available.
The problem analyzed in this example has been simplified by using only two inputs and one output.The input variables are degree-of-dirt (DD) and type-of-dirt (TD); the output variable is washing-time (WT).The fuzzy rule-base consist of: The fired rules and their firing levels, computed with t-norm Product, are: R 1 with firing level α 1 = 0.0277, R 2 with firing level α 2 = 0.0625, R 4 with firing level α 4 = 0.0026 and R 5 with firing level α 5 = 0.0058.
Working with I L implication, the fired rules give the following crisp values as output: The overall crisp action given by system is computed using the technique OWA with w 1 = 13/24, w 2 = 11/24, a 1 = 45.152, a 2 = 44.975; it results z 0 = 45.079

Conclusion
This paper presents fuzzy logic controllers of Mamdani type.After the standard Mamdani FLC is explained, an its extension is prezented.Because it can work not only with crisp data as inputs but, also, with intervals and/or linguistic terms its area of applications is very large.As it is mentioned in (Liu et al., 2005), a very important domain of its application is WEB shopping.Web users may use convenient interval inputs for online shopping as in the previous example.The working with various implications in the same time and, moreover, the possibility to aggregate the results given by these implications offer a strong base for more accurate results of our system.
The system can be improved by adding new implications, by using other fuzzy matching techniques or by other aggregate operators in order to obtain a overall crisp action from those given, separately, by every implication.

Fig. 1 .
Fig. 1.Fuzzy Logic ControllerThe four components of a FLC are explained in the following(Lee, 1990).The fuzzification interface involves the functions: a) measures the values of inputs variables, b) performs a scale mappings that transfers the range of values of inputs variables into corresponding universes of discourse, c) performs the function of fuzzyfication that converts input data into suitable linguistic values which may be viewed as label of fuzzy sets.The rule base comprises a knowledge of the application domain and the attendant control goals.It consists of a "data base" and a "linguistic (fuzzy) control rule base": a) the data base provides necessary definitions which are used to define linguistic control rules and fuzzy data manipulation in a FLC 4: Defuzzification The most popular defuzzification method is the centroid technique.It finds a point representing the center of gravity (COG) of the aggregated fuzzy set A, on the interval [a, b].A reasonable estimate can be obtained by calculating it over a sample of points.According to Fig. 4(b), in our case results COG = (0 + 10 + 20) × 0.1 +(30 + 40 + 50 + 60) × 0.2 +(70 + 80 + 90 + 100) × 0.5 0.1 + 0.1 + 0.1 + 0.2 + 0.2 + 0.2 + 0.2 + 0.5 + 0.5 + 0.5 + 0.5 = 67.4 Fig. 3. Mamdani fuzzy logic controller Fig. 5. Conclusions obtained with different implications The universes of discourse are [0, 800] for price and [0, 10] for quality.The membership functions corresponding to the linguistic values are represented by the following trapezoidal fuzzy numbers: Controls, Concepts, Theories and Applications www.intechopen.com(a) The membership function of the variable price (b) The membership function of the variable quality (c) The membership function of the variable satisfaction score

Fig. 6 .
Fig. 6.Membership functions for the input and output variables

R 1 :Fig. 7 .
Fig. 7. Membership functions for the input and output variables

z 1 =
50.138, z 2 = 44.843,z 4 = 44.993,z 5 = 25 and the overall crisp control action for I L is z 0 (I L )=45.152 Working with I R implication, the fired rules give the following crisp values as output: z 1 = 55, z 2 = 42.5, z 4 = 42.5, z 5 = 25 and its overall crisp control action is z 0 (I R )=44.975 The input variables are quality (Q) and price (P); the output variable is satis f action score (S).The fuzzy rule base consist ofR 1 : IF Q is Poor AND P is Low THEN S is Middle R 2 : IF Q is Poor AND P is Middle THEN S is Low R 3 : IF Q is Poor AND P is High THEN S is Very Low R 4 : IF Q is Average AND P is Low THEN S is High R 5 : IF Q is Average AND P is Middle THEN S is Middle R 6 : IF Q is Average AND P is High THEN S is Low R 7 : IF Q is Good AND P is Low THEN S is Very High R 8 : IF Q is Good AND P is Middle THEN S is High R 9 : IF Qis Good AND P is High THEN S is MiddleThere are three linguistic values for the variable price: {Low, Middle, High} and five linguistic values for the variable quality: {Poor, Below Average, Average, Above Average, Good}.