Fuzzy If-Then Rules Adnan Yazıcı Dept. of Computer Engineering, Middle East Technical University Ankara/Turkey Fuzzy If-Then Rules There are two different kinds of fuzzy rules: Fuzzy mapping rules and Fuzzy implication rules. A fuzzy mapping rule describes an association; therefore, its fuzzy relation is constructed from the Cartesian product of its antecedent fuzzy condition and its consequent fuzzy condition. A fuzzy implication rule, however, describes a generalized two-valued logic implication; therefore, its fuzzy relation needs to be constructed from the semantics of a generalization to implication in multi-valued logic. 1
Fuzzy If-Then Rules The difference between the semantics of fuzzy mapping rules and fuzzy implication rules can be seen from the difference in their inference behavior. Even though these two types of rules behave the same when their antecedents are satisfied, they behave differently when their antecedents are not satisfied. Example: Implication rule, Mapping rule (logic representation) (procedural representation) Given:x [1,3] y [7,8], Stm: Ifx [1,3], Then y [7,8] Input: x=5 Variable value: x = 5 Infer: y is unkown (y [0,10]) Execution result: no action Fuzzy Mapping Rules The needs to approximate a function of interest is often due to one or more of the following reasons: 1) The mathematical structure of the function is not precisely known at al. 2) The function is so complex that finding its precise mathematical form is practically infeasible due to its high cost. 3) Even if finding the precise function is not impractical, implementing the function in its precise mathematical form in a product or service may be too costly. This is particularly important for low cost high volume products (e.g., automobiles, cameras, and many other consumer products). 2
Fuzzy Mapping Rules Fuzzy rule-based function approximation is a partition-based technique. The partition-based approximation techniques approximate a function by partitioning the input space of the function and approximate the function in each partitioned region separately (e.g., piecewise linear approximation). Fuzzy Mapping Rules Because each fuzzy rule approximates a small segment of the function, the entire function is approximated by asetof fuzzy mapping rules. Werefertosuchacollectionoffuzzymappingrulesas fuzzy rule-based models or simply fuzzy models A fuzzy model describes a (approximate) mapping (i.e., function) from a set of input variables to a set of output variables. Examples: A fuzzy model of the stock market canbeusedtopredictfuture changes of the IMKB average. A fuzzy control model of a petrochemical process canbeusedto predict the future state of the process. 3
Fuzzy Mapping Rules A fuzzy model can be defined as a model that is obtained by fusing multiple local models that are associated with fuzzy subspaces of the given input space. The result of fusing multiple local models is usually a fuzzy conclusion, which is usually converted to a crisp final output through a defuzzification process. The main difference between fuzzy and nonfuzzy rules for function approximation lies in their interpolative reasoning capability, which allows the output of multiple fuzzy rules to be fused for agiven input. Interpolation is the approximation of a complicated function by a simpler function. Suppose we know the function but it is too complex to evaluate efficiently. Then we could pick a number of known data points from the complicated function and interpolate those data points to construct a simpler function. Fuzzy Mapping Rules The four major concepts in fuzzy rule-based models thus are as follows: 1. Fuzzy partition, 2. Mapping of fuzzy subregion to local models, 3. Fusion of multiple local models, 4. Defuzzification. 4
1- Fuzzy partition A fuzzy partition of a space is a collection of fuzzy subspaces whose boundaries partially overlap and whose union is the entire space. Formally, a fuzzy partition of a space as a collection of fuzzy subspace A i of S that satisfies the following condition: μ Ai (x) = 1, x S. That is, for any element x of the space A i, its membership degree in all subspaces always adds up to 1. 1- Fuzzy partition We call a collection of fuzzy subspaces A i of S a weak fuzzy partition of S iff it satisfies the following condition: 0< μ Ai (x) 1, x S. The greater than 0 condition requires each element in the space S to be covered by at least one fuzzy subspace in the partition. The sum to 1 condition of a fuzzy partition can be relaxed to the sum to less or equal to 1 condition because the interpolative reasoning of fuzzy models includes a normalization step. Research Note: It has been shown that μ Ai (x) = 1 is a desirable property in a framework for analyzing the stability of fuzzy logic controllers. 5
2- Mapping a Fuzzy Subspace to a Local Model y large small x small medium large Fuzzy mapping 2- Mapping a Fuzzy Subspace to a Local Model A local model for a subspace of the entire input space describes the system s s inputoutput mapping relationship in (the smaller) subspace. In contrast, a global model for an input space describes the system s input-output relationship for the entire input space. Because the scope of the local model is smaller than that of a global model, it is usually easier to develop a local model. 6
Mapping a Fuzzy Subspace to a Local Model In particular, a nonlinear global model (i.e., whose inputoutput mapping function is not linear) can often be approximated by a set of linear local models. Thiscanbe understood by remembering the well-known approximation technique called piecewise linear approximation, which approximates an arbitrary nonlinear function using segments of lines. The following figure shows such an approximation technique, where the line indicates the function being approximated. y x Mapping a Fuzzy Subspace to a Local Model Piecewise linear approximation has two major components: 1. Partitioning the input space to crisp regions 2. Mapping each partitioned region to a linear local model. The main difference between fuzzy modeling and piecewise linear approximation is that, in fuzzy modeling, the transition from one local subregion to a neighboring one is gradual rather than abrupt. Generally, the mapping from a fuzzy subspace to a local model is represented as a fuzzy if-then rule in the form of: If xisinfs i Then y j =LM i (x) where x andy j denote the vector of input variables and output variable, respectively, FS i and LM i denote i th fuzzy subspace and the corresponding local model, respectively. 7
Mapping a Fuzzy Subspace to a Local Model The local model can be one of four different types: 1. Crisp constant: This type of local model is simply pyacrisp (nonvisual) constant. For example; If x i is Small Then y = 4.5 2. Fuzzy constant: A local model that is a fuzzy constant (e.g., Small) belong to this type. For example; If x i is Small Then y is Medium 3. Linear Model: this describes the output as a linear function of the input variables, such as: If x 1 is Small And x 2 is Large Then y = 2x 1 +5x 2 +3. 4. Non-Linear Model: Theoretically, a local model can be more complex than a linear model. In practice, however, there is rarely such a need. These models have been introduced in a hybrid neuro-fuzzy system that uses neural networks to represent nonlinear local models associated with the rule. Fusion of local models through interpolative reasoning Fuzzy models use interpolative reasoning to fuse multiple local models into a global model. The basic idea behind interpolative reasoning is analogous to drawing a conclusion from a panel of experts, each of whom is specialized in a subarea of the entire problem. Each expert s opinion is associated with a weight, which h reflects the degree to which h the current situation is in the expert s specialized area. These weighted opinions are combined to form an overall opinion. 8
Fusion of local models through interpolative reasoning In this analogy, an expert corresponds to a fuzzy if-then rule, the specialized ili subarea of the expert corresponds to the fuzzy subspace associated with the if-part of the rule. The weight of an expert s opinion is determined by the degree to which the current situation (input data) belongs to the expert s specialized area (input subspace). Defuzzification We may interpret a possibility distribution either through linguistic approximation, or through defuzzification. The former gives a qualitative interpretation, while the latter gives a quantitative summary and is more commonly used in fuzzy logic applications, i.e., industrial applications. Given a possibility distribution of a fuzzy model s output, defuzzification amounts to selecting a single representative value that captures the essential meaning of the given distribution. 9
Defuzzification Therearethreecommondefuzzification techniques: mean of maximum, center of area, and height. Mean of Maximum (MOM): This calculates l the average of those output values that have the highest possibility degrees. Suppose y is A is a fuzzy conclusion to be fuzzified. We can express the MOM defuzzification method using the following formula: MOM (A) = y* P y* / P Where P is the set of output values y with highest possibility degree in A. If P is an interval, the result of MOM defuzzification is obviously the midpoint in that interval. This technique does not take into account the overall shape of the possibility distribution. Defuzzification Center of Area (COA): This method (also referred to as the center-of-gravity, or centroid method) is the most popular df defuzzification i technique. hi Unlike MOM, the COA method takes into account the entire possibility distribution in calculating its representative point. This method is similar to the formula for calculating the center of gravity in physics, if we view μ A (x) as the density of mass at x. If x is discrete, the fuzzification result of A is: COA(A) = x μ A (x)*x/ x μ A (x). The main disadvantage of the COA method is its high computational cost. However, the calculation can be simplified for some fuzzy models. 10
Defuzzification The Height Method: This method can be viewed as a two step procedure. First we convert the consequent membership function c i into crisp consequent y = c i where c i is the center of gravity of c i. The centroid defuzzification is then applied to the rules with crisp consequents with the following formula: y= M i=1 w i *c i / M i=1 w i where w i is the degree to which i th rule matches the input data. This method reduces the computation cost and facilitates the application of neural networks learning to fuzzy systems; hence, many well-known neuro-fuzzy models use this type of defuzzification method. The main disadvantage of this method is that it is not well justified and is often considered an approximation to the centroid defuzzification. An example for a Fuzzy Model 11
Types of Fuzzy Rule-Based Models short long Types of Fuzzy Rule-Based Models low high 12
Types of Fuzzy Rule-Based Models maintain speed increase speed decrease speed Types of Fuzzy Rule-Based Models 13
Types of Fuzzy Rule-Based Models Types of Fuzzy Rule-Based Models 14
Types of Fuzzy Rule-Based Models Types of Fuzzy Rule-Based Models 15
Inference Mechanism Water Tank Example Inference Mechanism Water Tank Example 16
Inference Mechanism Water Tank Example Inference Mechanism Water Tank Example 17
Rudimentary Flow Mixing Controller R1: IF the target temperature T is Low THEN set the voltage to V (i.e., turn on the cold flow). R2: IF the target temperature T is High THEN set the voltage to V (i.e., turn on the hot flow). Membership functions of the taget temperature are; μ μ 1 High 1 Low T T Rudimentary Flow Mixing Controller 18
Washing Machine Example Inference Mechanism 19
Inference Mechanism Inference Mechanism 20
21