Soft Computing Unit-4 by Arun Pratap Singh

123
UNIT : IV SOFT COMPUTING II SEMESTER (MCSE 205) PREPARED BY ARUN PRATAP SINGH

description

8878061993 OIST BhopalMTech -CSE II Semester RGPV Bhopal

Transcript of Soft Computing Unit-4 by Arun Pratap Singh

Page 1: Soft Computing Unit-4 by Arun Pratap Singh

UNIT : IV SOFT COMPUTING II SEMESTER (MCSE 205)

PREPARED BY ARUN PRATAP SINGH

Page 2: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 1

1

FUZZY SYSTEM :

UNIT : IV

Page 3: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 2

2

Page 4: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 3

3

Page 5: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 4

4

Page 6: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 5

5

Page 7: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 6

6

Page 8: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 7

7

Page 9: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 8

8

Page 10: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 9

9

Page 11: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 10

10

Page 12: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 11

11

Page 13: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 12

12

Page 14: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 13

13

Page 15: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 14

14

Page 16: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 15

15

Page 17: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 16

16

UNION :

INTERSECTION :

Page 18: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 17

17

COMPLEMENT :

DIFFERENCE :

Page 19: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 18

18

Page 20: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 19

19

Page 21: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 20

20

Page 22: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 21

21

Page 23: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 22

22

Page 24: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 23

23

Page 25: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 24

24

FUZZY SETS :

Page 26: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 25

25

Page 27: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 26

26

Page 28: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 27

27

Page 29: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 28

28

Page 30: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 29

29

Page 31: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 30

30

CRISP RELATION AND FUZZY RELATION :

• The notion of relation is the basic idea behind numerous operations on sets such as

Cartesian products, composition of relations , difference of relations and intersections of

relations and equivalence properties

• In all engineering , science and mathematically based fields, relations is very important

• Similarities can be described with relations.

• In this sense, relations is a very important notion to many different technologies like

graph theory, data manipulation.

Graph theory

Page 32: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 31

31

Data manipulations

• In classical relations (crisp relations),

Relationships between elements of the sets are

only in two degrees; “completely related” and

“not related”.

• Fuzzy relations take on an infinitive number of degrees of relationships between the

extremes of “ completely related” and “ not related”

Page 33: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 32

32

Page 34: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 33

33

Page 35: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 34

34

Page 36: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 35

35

Page 37: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 36

36

Page 38: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 37

37

Page 39: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 38

38

Page 40: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 39

39

Page 41: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 40

40

Page 42: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 41

41

Page 43: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 42

42

Page 44: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 43

43

Page 45: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 44

44

Page 46: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 45

45

Page 47: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 46

46

Page 48: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 47

47

Page 49: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 48

48

MEMBERSHIP FUNCTIONS :

Definition: a membership function for a fuzzy set A on the universe of discourse X is defined as µA:X → [0,1], where each element of X is mapped to a value between 0 and 1. This value, called membership value or degree of membership, quantifies the grade of membership of the element in X to the fuzzy set A.

Membership functions allow us to graphically represent a fuzzy set. The x axis represents the universe of discourse, whereas the y axis represents the degrees of membership in the [0,1] interval.

Simple functions are used to build membership functions. Because we are defining fuzzy concepts, using more complex functions does not add more precision.

• One of the key issues in all fuzzy sets is how to determine fuzzy membership functions

• The membership function fully defines the fuzzy set

• A membership function provides a measure of the degree of similarity of an element to a

fuzzy set

• Membership functions can take any form, but there are some common examples that

appear in real applications

Page 50: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 49

49

Membership function of a fuzzy set

• Membership functions can

• either be chosen by the user arbitrarily, based on the user’s experience (MF

chosen by two users could be different depending upon their experiences,

perspectives, etc.)

• Or be designed using machine learning methods (e.g., artificial neural

networks, genetic algorithms, etc.)

• There are different shapes of membership functions; triangular, trapezoidal,

piecewise-linear, Gaussian, bell-shaped, etc.

Page 51: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 50

50

Page 52: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 51

51

Page 53: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 52

52

Trapezoidal function: defined by a lower limit a, an upper limit d, a lower support limit b, and an upper support limit c, where a < b < c < d.

There are two special cases of a trapezoidal function, which are called R-functions and L-functions:

R-functions: with parameters a = b = - ∞

L-Functions: with parameters c = d = + ∞

Page 54: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 53

53

The Introduction to Fuzzy Logic Tutorial (in Spanish) contains a tool you can use to draw trapezoidal functions with different parameters.

FUZZY RULE-BASED SYSTEMS :

Page 55: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 54

54

Fuzzy rules are linguistic IF-THEN- constructions that have the general form "IF A THEN B" where

A and B are (collections of) propositions containing linguistic variables. A is called the premise and

B is the consequence of the rule. In effect, the use of linguistic variables and fuzzy IF-THEN- rules

exploits the tolerance for imprecision and uncertainty. In this respect, fuzzy logic mimics the

crucial ability of the human mind to summarize data and focus on decision-relevant information.

In a more explicit form, if there are I rules each with K premises in a system, the ith rule has the

following form.

In the above equation a represents the crisp inputs to the rule and A and B are linguistic variables.

The operator 1 can be AND or OR or XOR.

Example: If a HIGH flood is expected and the reservoir level is MEDIUM, then water release is

HIGH.

Several rules constitute a fuzzy rule-based system.

Another example comes from Kosko (1993). Figures below are adapted from this book and

illustrate the notion of a simple fuzzy rule with one input and one output applied to the problem of

an air motor speed controller for air conditioning. Rules are given. Let us say the temperature is

22 degrees. This temperature is "right" to a degree of 0.6 and "warm" to a degree of 0.2 and it

belongs to all others to a degree of zero. This activates two of the rules shown in Figure 1. The

rule responses are combined to give those shown in Figure 2 (thick lines).

Page 56: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 55

55

Figure 1. Air motor speed controller. Temperature (input) and spedd (output) are fuzzy variables

used in the set of rules.

Page 57: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 56

56

Figure 2. Temperature of 22 deg. "fires" two fuzzy rules. The resulting fuzzy value for air motor

speed is "defuzzified" – abscissa of the centroid of area gives the "crisp" valu

AFUZ - fuzzy rule-based system tool

A Windows based fuzzy rule-based tool AFUZ allows modelling an input – output relationship

(function of several variables) of any nature. Training of a set of fuzzy rules is performed on the

basis of a given set of "examples" of input – output data. Being trained, the resulting system allows

for accurate reproduction of output variable, given values of input variables.

Applications

Page 58: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 57

57

FRBS methodology has been successfully applied to a problem of representing the spatial

precipitation pattern at rain gauge stations in Italy using rules generated from historical data. The

number of rules has been found to be the key parameter in overcoming problems of over-fitting

and generalization arising from uncertainties due to incomplete or non-representative data. For

this particular case study, the performance indices have shown its best performance compared

to two other possible methods of solution – a traditional normal ratio method and artificial neural

network (ANN) solution.

Another area of application is the use of FRBS (along with ANNs) in the problems of reproducing

the behaviour of a control system responsible for regulating water levels in a water system.

FUZZY PROPOSITIONS :

Fundamental difference between classical propositions and fuzzy propositions is in the

range of their truth values.

Four types of simple fuzzy propositions

1. Unconditional and unqualified propositions

2. Unconditional and qualified propositions

3. Conditional and unqualified propositions

4. Conditional and qualified propositions

-----------

– Unconditional and unqualified propositions

• “The temperature is high”

– Unconditional and qualified propositions

• “The temperature is high is very true”

– Conditional and unqualified propositions

• “If the temperature is high, then it is hot”

– Conditional and qualified propositions

• “If the temperature is high, then it is hot is true”

1. Unconditional and unqualified propositions:

• The canonical form of this type is “x is A”, where x X and A is a fuzzy set on X

• For example, temperature is high, tina is young, john is tall etc.

• Answer to such statements i.e., degree of truth is obtained as shown in earlier

examples.

Page 59: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 58

58

2. Unconditional and qualified propositions

• The canonical form of this type is “x is A is S “, where S is a fuzzy truth qualifier

• For example, if age(tina) = 25, tina is young is very true, tina is young is fairly false etc.

3. Conditional and unqualified propositions

• The canonical form of this type is “if x is A, then y is B”

where x X, y Y and A is fuzzy set on X, B is fuzzy set on Y

• For example, If sun is bright, then day is hot.

4. Conditional and qualified propositions

• The canonical form of this type is “if x is A, then y is B is S”

• For example, If sun is bright then day is cold is very false.

Fuzzy propositions are assigned to fuzzy sets. Suppose a fuzzy proposition 'P' is assigned to

a fuzzy set 'A', then the truth value of the proposition is proposed by T (P) = μA(x) where 0 ≤

μA(x) ≤ 1

Therefore truthness of a proposition P is membership value of x in fuzzy set A.

The logical connectives like disjunction, conjunction, negation and implication are also defined

on fuzzy propositions.

Let, a fuzzy proposition 'P' is defined on a fuzzy set A

Q is defined on fuzzy set B

Conjunction

P /\ Q : x is A and B

T( P /\ Q) = Min [ T(P), T(Q)]

Negation

T(Pc) = 1 - T(P)

Disjunction

P V Q : x in A or B

T (P V Q) = Max [ T(P), T(Q) ]

Implication

P → Q : x is A then x is B

Page 60: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 59

59

T( P → Q ) = T (Pc V Q) = Max [ T(Pc, T(Q)]

If P is a proposition defined on set A on universe of discourse X and

Q is another proposition defined on set B on universe of discourse Y,

then the implication P → Q can be represented by the relation R

R = ( A X B) U (Ac X Y) = If A then B

If x ∈ A, where x ∈ X and A ⊂ X

then y ∈ B, where y ∈ Y and B ⊂ Y

Page 61: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 60

60

Page 62: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 61

61

Page 63: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 62

62

Page 64: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 63

63

Page 65: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 64

64

Page 66: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 65

65

Page 67: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 66

66

Page 68: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 67

67

Page 69: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 68

68

Page 70: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 69

69

Page 71: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 70

70

LINGUISTIC VARIABLES :

• A major reason behind using fuzzy logic is the use of linguistic expressions.

• A linguistic variable consists of:

– the name of the variable (u),

– the term set of the variable (T(u)),

– its universe of discourse (U) in which the fuzzy sets are defined,

– a syntactic rule for generating the names of values of u, and

– a semantic rule for associating with each value its meaning.

• For example:

• if u is temperature,

• then its term set T(temperature) could be:

– T(temperature)={cold, cool, warm, hot} over a universe of discourse

U=[0,300].

Page 72: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 71

71

DECOMPOSITION OF FUZZY RULES :

A collection of various simple rules when combined together form a compound rule.

Compound rule structure may be decomposed or reduced to many simple canonical rule forms

which are normally based on natural language representations. The methods used for

decomposition of compound linguistic rules into simple Canonical rules are as follows –

Temperature

Cold Cool Warm Hot

linguistic

variable

term set

fuzzy set representation

Page 73: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 72

72

Page 74: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 73

73

AGGREGATION OF FUZZY RULES :

The process of obtaining the overall consequents from the individual consequents provided by

each rule is called the aggregation of rules. Methods that helps in determining the aggregation of

fuzzy rules are as follows :-

Page 75: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 74

74

FUZZY REASONING :

Page 76: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 75

75

Page 77: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 76

76

Page 78: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 77

77

Page 79: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 78

78

FUZZY INFERENCE SYSTEM :

Definition-

A Fuzzy Inference System (FIS) is a way of mapping an input space to an output space using fuzzy logic. A FIS tries to formalize the reasoning process of human language by means of fuzzy logic (that is, by building fuzzy IF-THEN rules). For instance:

“If the service is good, even if the food is not excellent, the tip will be generous”

FIS are used to solve decision problems, i.e. to make a decision and act accordingly.

Structure of a fuzzy inference system

In general, a fuzzy inference system consists of four modules:

Fuzzification module: transforms the system inputs, which are crisp numbers, into fuzzy sets. This is done by applying a fuzzification function.

Knowledge base: stores IF-THEN rules provided by experts. Inference engine: simulates the human reasoning process by making fuzzy inference on

the inputs and IF-THEN rules. Defuzzification module: transforms the fuzzy set obtained by the inference engine into

a crisp value.

Why should we use Fuzzy Inference Systems?

Fuzzy logic does not solve new problems. It uses new methods to solve everyday problems.

Mathematical concepts within fuzzy reasoning are very simple. Fuzzy logic is flexible: it is easy to modify a FIS just by adding or deleting rules. There is

no need to create a new FIS from scratch.

Page 80: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 79

79

Fuzzy logic allows imprecise data (it does NOT work with uncertainty): it handles elements in a fuzzy set, i.e. membership values. For instance, fuzzy logic works with 'He is tall to the degree 0.8' instead of 'He is 180cm tall'.

Fuzzy logic is built on top of the knowledge of experts: it relies on the know-how of the ones who understand the system.

Fuzzy logic can be blended with other classic control techniques.

When shouldn't we use fuzzy logic?

Fuzzy logic is based on natural language. It is the codification of common sense. Thus, we shall not use it when our common sense tells us not to do so.

Fuzzy IF-THEN rules

In its simplest form, a fuzzy “if-then” rule follows the pattern:

“If x is A then y is B"

A and B are linguistic values defined by fuzzy sets in the universes of discourse X and Y. x is the input variable and y is the output variable. The meaning of is is different in the antecedent and in the consequent of the rule. This is

because the antecedent is an interpretation that returns a value between 0 and 1, and the consequent assigns a fuzzy set B to the variable y

The input to the rule is a crisp value given to the input variable x of the antecedent (this value belongs to the universe of discourse of A).

The output to the rule is a fuzzy set assigned to the output variable y of the consequent. The rule is executed applying a fuzzy implication operator, whose arguments are the

antecedent's value and the consequent's fuzzy set values. The implication results in a fuzzy set that will be the output of the rule.

Classification of fuzzy inference methods

Fuzzy inference methods are classified in direct methods and indirect methods. Direct methods, such as Mamdani's and Sugeno's, are the most commonly used (these two methods only differ in how they obtain the outputs). Indirect methods are more complex.

Page 81: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 80

80

Page 82: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 81

81

MAMDANI'S METHOD :

Mamdani's method is the most commonly used in applications, due to its simple structure of 'min-max' operations. We will go through each one of the steps of the method with the help of the example shown in the Motivation section.

Step 1: Evaluate the antecedent for each rule.

Step 2: Obtain each rule's conclusion.

Step 3: Aggregate conclusions.

Step 4: Defuzzification.

Page 83: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 82

82

Step 1. Evaluate the antecedent for each rule

Given the inputs (crisp values) we obtain their membership values. This process is called 'input fuzzification'. If the antecedent of the rule has more than one part, a fuzzy operator (t-norm or t-conorm) is applied to obtain a single membership value. Let's take a look at the example:

When fuzzifying the first part of the antecedent (service is excellent) we obtain the degree to which the service is excellent if we rate it as a 3. As we can see, a 3 rating stands for a poor service, that is why we obtain the membership value 0. When fuzzifying the second part of the antecedent (food is delicious) we obtain the degree to which the food is delicious if we rate it as an 8. Naturally, an 8 rating stands for a quite delicious food, that is why we obtain the membership value 0.7.

Lastly, as the two parts of the antecedent are joined by a disjunction (service is excellent or food is delicious), we apply an OR operation, the maximum, to both membership values to obtain the membership value 0.7. Let's suppose both parts of the antecedent were joined by a conjunction ('and'). In this case we would have to apply an AND operation, the minimum for instance.

Step 2. Obtain each rule's conclusion

Given the cosequent of each rule (a fuzzy set) and the antecedent value obtained in step 1, we apply a fuzzy implication operator to obtain a new fuzzy set.

Two of the most commonly used implication methods are the minimum, which truncates the consequent's membership function, and the product, which scales it. In the example below, the minimum operator is used:

Page 84: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 83

83

Step 3. Aggregate conclusions

In this step we combine the outputs obtained for each rule in step 2 (obtain conclusion) into a single fuzzy set, using a fuzzy aggregation operator.

Some of the most commonly used aggregation operators are the maximum, the sum and the probabilistic sum. In the example below the maximum is used:

Page 85: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 84

84

Step 4. Defuzzification

When we try to solve a decision problem, we want the output to be a number (crisp value) and not a fuzzy set. For the tipping problem for instance, we do not want the system to tell us to give a generous tip. What we want to know is how much tip we should give. So, we need to transform the fuzzy set we obtained in step 3 into a single numerical value. One of the most popular defuzzification methods is the centroid, which returns the center of the area under the fuzzy set obtained in step 3. The calculations are shown below:

Page 86: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 85

85

FUZZY DECISION MAKING :

Individual decision making-

Decision situation :

Page 87: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 86

86

Example 12.1

Page 88: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 87

87

Page 89: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 88

88

Page 90: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 89

89

Multiperson decision making :

Example 12.3

Page 91: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 90

90

Page 92: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 91

91

Page 93: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 92

92

Multicriteria decision making :

Multistage decision making :

Page 94: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 93

93

Page 95: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 94

94

FUZZY LOGIC APPLICATIONS :

Almost any control system can be replaced with a fuzzy logic based control system. This may be overkill in many places however it simplifies the design of many more complicated cases. So fuzzy logic is not the answer to everything, it must be used when appropriate to provide better control. If a simple closed loop or PID controller works fine then there is no need for a fuzzy controller. There are many cases when tuning a PID controller or designing a control system for a complicated system is overwhelming, this is where fuzzy logic gets its chance to shine.

One of the most famous applications of fuzzy logic is that of the Sendai Subway system in Sendai, Japan. This control of the Nanboku line, developed by Hitachi, used a fuzzy controller to

Page 96: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 95

95

run the train all day long. This made the line one of the smoothest running subway systems in the world and increased efficiency as well as stopping time. This is also an example of the earlier acceptance of fuzzy logic in the east since the subway went into operation in 1988.

The most tangible applications of fuzzy logic control have appeared commercial appliances. Specifically, but not limited to heating ventilation and air conditioning (HVAC) systems. These systems use fuzzy logic thermostats to control the heating and cooling, this saves energy by making the system more efficient. It also keeps the temperature more steady than a traditional thermostat.

Another significant area of application of fuzzy control is in industrial automation. Fuzzy logic based PLCs have been developed by companies like Moeller. These PLCs, as well as other implementations of fuzzy logic, can be used to control any number of industrial processes.

Fuzzy logic also finds applications in many other systems. For example, the MASSIVE3D animation system for generating crowds uses fuzzy logic for artificial intelligence. This program was used extensively in the making of the Lord of the Rings trilogy as well as The Lion, The Witch and the Wardrobe films.

As a final example of fuzzy logic, it can be used in areas other than simply control. Fuzzy logic can be used in any decision making process such as signal processing or data analysis. An example of this is a fuzzy logic system that analyzes a power system and diagnoses any harmonic disturbance issues. The system analyzes the fundamental voltage, as well as third, fifth and seventh harmonics as well as the temperature to determine if there is cause for concern in the operation of the system.

Page 97: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 96

96

FUZZIFICATION :

Page 98: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 97

97

Page 99: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 98

98

Page 100: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 99

99

DEFUZZIFICATION :

Defuzzification is the process of producing a quantifiable result in fuzzy logic, given fuzzy sets

and corresponding membership degrees. It is typically needed in fuzzy controlsystems. These will

have a number of rules that transform a number of variables into a fuzzy result, that is, the result

is described in terms of membership in fuzzy sets. For example, rules designed to decide how

much pressure to apply might result in "Decrease Pressure (15%), Maintain Pressure (34%),

Increase Pressure (72%)". Defuzzification is interpreting the membership degrees of the fuzzy

sets into a specific decision or real value.

The simplest but least useful defuzzification method is to choose the set with the highest

membership, in this case, "Increase Pressure" since it has a 72% membership, and ignore the

others, and convert this 72% to some number. The problem with this approach is that it loses

information. The rules that called for decreasing or maintaining pressure might as well have not

been there in this case.

A common and useful defuzzification technique is center of gravity. First, the results of the rules

must be added together in some way. The most typical fuzzy set membership function has the

graph of a triangle. Now, if this triangle were to be cut in a straight horizontal line somewhere

between the top and the bottom, and the top portion were to be removed, the remaining portion

forms a trapezoid. The first step of defuzzification typically "chops off" parts of the graphs to form

trapezoids (or other shapes if the initial shapes were not triangles). For example, if the output has

"Decrease Pressure (15%)", then this triangle will be cut 15% the way up from the bottom. In the

most common technique, all of these trapezoids are then superimposed one upon another,

forming a single geometric shape. Then, the centroid of this shape, called the fuzzy centroid, is

calculated. The x coordinate of the centroid is the defuzzified value.

Page 101: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 100

100

Page 102: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 101

101

Page 103: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 102

102

METHOD 2 :

Page 104: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 103

103

METHOD 3 :

Page 105: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 104

104

METHOD 4 :

METHOD 5 :

Page 106: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 105

105

METHOD : 6

Page 107: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 106

106

FUZZY ASSOCIATIVE MEMORY :

Page 108: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 107

107

Page 109: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 108

108

Page 110: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 109

109

Page 111: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 110

110

Page 112: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 111

111

MODELING AND CONTROL SYSTEMS :

The goal of this note is to demonstrate how Fuzzy Logic can be used for modeling. We plan to

show how fuzzy sets can be used to represent a real system or process. In this demonstration,

we use modeling data from a paper in which the authors investigate the effects of using various

fuzzy operators for constructing models [Stachowicz and Kochanska, 1987]. We only look at

one example from the paper, but it may be instructive to try to duplicate some of the other

models with different operators.

To demonstrate fuzzy modeling, we use many functions from Fuzzy Logic, along with standard

Mathematica functions. Fuzzy Logic contains numerous functions for working with fuzzy sets

and fuzzy logic.

Representing the Model Input

The Process

In this notebook, we will be modeling a theoretical relationship between a set of input and a set

of output. We scaled the input and output numbers used in the original paper by 100, so if their

output was 400, ours will be 4.

We start with a list of the input-output pairs for the process. The first number in each pair

represents the input to the system, and the second item is the system output. It is this input-

Page 113: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 112

112

output relationship that we intend to model. In this example, we start with a list of specific points,

but for fuzzy modeling, exact points are not required. Instead of the first input being exactly {1,

20}, it could be thought of in the following way: if the input is approximately one then the output

is around twenty.

In[2]:=

Dividing the Input Range

One of the first things to consider when designing a model is the range for the input variables.

From the original data, we see that the input ranges from 1 to 11; we use this range as the

universal space for our input variable. Once we have a reasonable range, we can consider how

to divide that range into descriptive linguistic terms. For this model, we are using 6 membership

functions to divide up the input universal space. We will repeat that using

the CreateFuzzySets function. The following command divides the universal space into six even

triangular fuzzy sets. Notice how we assign linguistically significant names to the six

membership functions.

In[3]:=

Viewing the Membership Functions

We can take a look at our membership functions with the FuzzyPlot command. Notice in this

example how we use one of Mathematica's standard plotting options, PlotLabel, with our fuzzy

plotting function. Remember, all of Mathematica's standard plotting options can be used with

the FuzzyPlot function, so you can customize the look of your plots.

In[4]:=

Page 114: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 113

113

Representing the Model Output

Dividing the Output Range

Like the input, the range of the output variable must be divided up into various membership

functions. Looking at our original data, we see that the output ranges from 4 to 20 over the input

range; we use this as our universal space. For this example, the authors of the original paper

chose to use five fuzzy sets to represent the output. We will do the same thing by again using

the CreateFuzzySets function. Notice how we give the five fuzzy sets linguistically significant

names from NZero to NSuperbig. It is important when naming membership functions to use

distinct names.

In[5]:=

Viewing the Membership Functions

We plot the output membership functions using the FuzzyPlot function.

In[6]:=

2.4.4 Creating Linguistic Control Rules

With our inputs and outputs defined, we need only specify a set of rules to create a model. In

this package, rules are organized as a list of ordered pairs. The first item in the pair represents

the input condition or the if part of the implication. The second item in the pair represents the

output condition or the then part of the implication. For example, looking at the list of rules that

follow, we see that the first pair in the list is {Inull,NSuperbig}. This rule would be equivalent to

the verbal statement:

If the input is Inull then the output is NSuperbig.

You see that this type of modeling is intuitively easy. The specified rules may be based on test

data or simply on observations. By examining our original data, we can see the basis for the first

Page 115: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 114

114

rule. The first data point is {1, 20}, which corresponds to a very small input (Inull) and a very

large output (NSuperbig). Here is the complete list of rules that were used in the paper

[Stachowicz and Kochanska, 1987]. Note that there is a rule associated with each of the input

membership functions.

In[7]:=

Viewing the Linguistic Rules

We plot the linguistic rules using the FuzzyGraph function.

In[8]:=

2.4.5 Building the Model

With all the necessary ingredients defined, we can create our model. To do that, we

call BuildModel with our list of rules. The BuildModelfunction creates a fuzzy relation from each

of the rules we specified using the SetsToRelation function. It then combines all of the fuzzy

relations using the Union operator. It is possible to use other operators to combine the rules,

and that is the subject of the paper we are following [Stachowicz and Kochanska, 1987]. The

end result of the BuildModel function is a single fuzzy relation, which should give a good

representation of the process we are modeling.

Creating the Model Fuzzy Relation

This statement creates a fuzzy relation that will model our process.

In[9]:=

Displaying the Model Fuzzy Relation

We look at the fuzzy relation that will serve as the model for our process using

the FuzzySurfacePlot function.

Page 116: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 115

115

Using the Model

Inferencing

To use our model to evaluate inputs, we use the CompositionBasedInference function. It takes

as arguments a fuzzy set, which represents the input, and a fuzzy relation, which is our model. It

performs a MaxMin type Composition with them to come up with fuzzy output. In this example,

we use a MeanOfMax defuzzification to get a crisp value.

We use a singleton fuzzy set as input to the inferencing function. Here we set up a function that

calls the inferencing function with the proper input. We need only provide this function an integer

in the range 1 to 11, and MyModeler will provide the crisp output of the model.

In[11]:=

Model Results

Table of Results

To see what kind of results the model provides, we make a table of input-output pairs for the entire

range of inputs. We accomplish this withMathematica's Table function, and we will look at the

results in TableForm.

In[12]:=

In[13]:=

Out[13]//TableForm=

Graph of Results

We plot these results to see how well our model performs. We do this with the ListPlot function.

Page 117: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 116

116

In[14]:=

2.4.7 Evaluating the Model

To see how well our model performed, we compare the original data with the results from our

model. We can compare the results in table form and with a graph.

Table Comparison

Here we create a table showing input, original output, model output, and absolute error.

In[15]:=

In[16]:=

Out[16]//TableForm=

Graphical Comparison

We again use ListPlot to show the results. This function will plot the original process data as large

blue dots and our model data as smaller red dots. You can see that the model performs quite well

for its simple design. It is possible to create entirely different models by changing operators,

Page 118: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 117

117

defuzzification strategies, rules, or membership functions. Feel free to create a different model

and compare your results to this one.

In[17]:=

FUZZY CONTROL SYSTEM :

A fuzzy control system is a control system based on fuzzy logic—a mathematical system that analyzes analog input values in terms of logical variables that take on continuous values between 0 and 1, in contrast to classical or digital logic, which operates on discrete values of either 1 or 0 (true or false, respectively).

Fuzzy logic is widely used in machine control. The term "fuzzy" refers to the fact that the logic involved can deal with concepts that cannot be expressed as "true" or "false" but rather as "partially true". Although alternative approaches such as genetic algorithms and neural networks can perform just as well as fuzzy logic in many cases, fuzzy logic has the advantage that the solution to the problem can be cast in terms that human operators can understand, so that their experience can be used in the design of the controller. This makes it easier to mechanize tasks that are already successfully performed by humans.

Fuzzy controllers are very simple conceptually. They consist of an input stage, a processing

stage, and an output stage. The input stage maps sensor or other inputs, such as switches,

thumbwheels, and so on, to the appropriate membership functions and truth values. The

processing stage invokes each appropriate rule and generates a result for each, then combines

the results of the rules. Finally, the output stage converts the combined result back into a specific

control output value.

Page 119: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 118

118

The most common shape of membership functions is triangular, although trapezoidal and bell

curves are also used, but the shape is generally less important than the number of curves and

their placement. From three to seven curves are generally appropriate to cover the required range

of an input value, or the "universe of discourse" in fuzzy jargon.

As discussed earlier, the processing stage is based on a collection of logic rules in the form of IF-

THEN statements, where the IF part is called the "antecedent" and the THEN part is called the

"consequent". Typical fuzzy control systems have dozens of rules.

Consider a rule for a thermostat:

IF (temperature is "cold") THEN (heater is "high")

This rule uses the truth value of the "temperature" input, which is some truth value of "cold", to

generate a result in the fuzzy set for the "heater" output, which is some value of "high". This result

is used with the results of other rules to finally generate the crisp composite output. Obviously,

the greater the truth value of "cold", the higher the truth value of "high", though this does not

necessarily mean that the output itself will be set to "high" since this is only one rule among many.

In some cases, the membership functions can be modified by "hedges" that are equivalent to

adjectives. Common hedges include "about", "near", "close to", "approximately", "very", "slightly",

"too", "extremely", and "somewhat". These operations may have precise definitions, though the

definitions can vary considerably between different implementations. "Very", for one example,

squares membership functions; since the membership values are always less than 1, this narrows

the membership function. "Extremely" cubes the values to give greater narrowing, while

"somewhat" broadens the function by taking the square root.

In practice, the fuzzy rule sets usually have several antecedents that are combined using fuzzy

operators, such as AND, OR, and NOT, though again the definitions tend to vary: AND, in one

popular definition, simply uses the minimum weight of all the antecedents, while OR uses the

maximum value. There is also a NOT operator that subtracts a membership function from 1 to

give the "complementary" function.

There are several ways to define the result of a rule, but one of the most common and simplest

is the "max-min" inference method, in which the output membership function is given the truth

value generated by the premise.

Rules can be solved in parallel in hardware, or sequentially in software. The results of all the rules

that have fired are "defuzzified" to a crisp value by one of several methods. There are dozens, in

theory, each with various advantages or drawbacks.

The "centroid" method is very popular, in which the "center of mass" of the result provides the

crisp value. Another approach is the "height" method, which takes the value of the biggest

Page 120: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 119

119

contributor. The centroid method favors the rule with the output of greatest area, while the height

method obviously favors the rule with the greatest output value.

The diagram below demonstrates max-min inferencing and centroid defuzzification for a system

with input variables "x", "y", and "z" and an output variable "n". Note that "mu" is standard fuzzy-

logic nomenclature for "truth value":

Notice how each rule provides a result as a truth value of a particular membership function for the

output variable. In centroid defuzzification the values are OR'd, that is, the maximum value is used

and values are not added, and the results are then combined using a centroid calculation.

Fuzzy control system design is based on empirical methods, basically a methodical approach

to trial-and-error. The general process is as follows:

Document the system's operational specifications and inputs and outputs.

Document the fuzzy sets for the inputs.

Document the rule set.

Page 121: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 120

120

Determine the defuzzification method.

Run through test suite to validate system, adjust details as required.

Complete document and release to production.

As a general example, consider the design of a fuzzy controller for a steam turbine. The block

diagram of this control system appears as follows:

The input and output variables map into the following fuzzy set:

—where:

N3: Large negative.

N2: Medium negative.

N1: Small negative.

Page 122: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 121

121

Z: Zero.

P1: Small positive.

P2: Medium positive.

P3: Large positive.

The rule set includes such rules as:

rule 1: IF temperature IS cool AND pressure IS weak,

THEN throttle is P3.

rule 2: IF temperature IS cool AND pressure IS low,

THEN throttle is P2.

rule 3: IF temperature IS cool AND pressure IS ok,

THEN throttle is Z.

rule 4: IF temperature IS cool AND pressure IS strong,

THEN throttle is N2.

In practice, the controller accepts the inputs and maps them into their membership functions and

truth values. These mappings are then fed into the rules. If the rule specifies an AND relationship

between the mappings of the two input variables, as the examples above do, the minimum of the

two is used as the combined truth value; if an OR is specified, the maximum is used. The

appropriate output state is selected and assigned a membership value at the truth level of the

premise. The truth values are then defuzzified. For an example, assume the temperature is in the

"cool" state, and the pressure is in the "low" and "ok" states. The pressure values ensure that only

rules 2 and 3 fire:

Page 123: Soft Computing Unit-4 by Arun Pratap Singh

PREPARED BY ARUN PRATAP SINGH 122

122

Building a fuzzy controller :

Consider implementing with a microcontroller chip a simple feedback controller: