Genetic Algorithm
This algorithm uses the concept of Darwin's theory of evolution. Darwin's theory mostly stressed the fact that the existence of each living things is based upon the rule of "survival of the fittest". Also Darwin postulated that new classes or breeds of living things come into existence via the process of reproduction, crossover, and mutation in between existing organisms. The benefit of genetic technique is that, this searches for a solution from a broad spectrum of possible solutions, quite than restrict the search to a narrow domain here the results would be usually expected. Genetic algorithms try to perform an intelligent search for a solution from a nearly infinite number of possible solutions.
Genetic algorithms can be utilized to compute membership functions. Given several functional mapping for a system, several membership functions and their shapes are assumed for the different fuzzy variables explained for a problem. These membership functions are then coded as bit strings that are linked or connected. An evaluation function is utilized to evaluate the fitness of each set of membership functions. This procedure is demonstrated for a simple problem in the next illustration.
Suppose that we have a single input as x  single output as y system with inputoutput values as shown in given table 2. Table 3 shows a functional mapping for this system in between input as x and the output as y. In Table 3 we see that each of the variables x and y makes use of two fuzzy classes as: [x uses S (small) and L (large); y uses L (large) and VL (very large)]. The functional mapping describes us that a small x maps to a small y, and a large x maps to a very large y. We suppose that the range of the variable x is [0, 5] and that of y is [0, 25]. We suppose that all membership function has the shape of right triangle, as displayed in following diagram.
Table no.2 of: Data for a Single Input  Signal Output System
x

1

2

3

4

5

y

1

4

9

16

25

Table no.3 of: Functional Mapping for the System
The membership function on the right side of following diagram is constrained to have the right angle wedge at the upper limit or boundary of the range of the fuzzy variable. The membership function on the left side is constrained to contain the right angle wedge on the lower limit or boundary of the range of the fuzzy variable. This is intuitively obvious that under the forgoing constraints merely thing needed to explain the shape and position of the membership function totally is the length of the base of the right angle membership functions. We employ this fact in encoding the membership functions as bit strings.
Diagram of: Membership Functions for the Input Variables are assumed to be Right Triangle
The unknown variables in such problem are the lengths of the bases of the four membership functions (x (S, L) and y (S, VL)). We employ sixbit binary string to explain the base of each of the membership functions. These strings are then concatenated to provide us a 24bit (6*4) string. Displayed as in table 4, column we start along with an initial population of four strings. These are decoded to the binary values of the variables as displayed in Table 4, as column 2, 3, 4, and 5. The binary values are mapped to decimal values for the fuzzy variables by using given Equation.
String
Number

(1) String

(2)

(3)

(4)

(5)

(6)

(7)

(8)

Base
1

Base
2

Base
3

Base
4

Base
1

Base
2

Base
3

(bin.)

(bin.
)

(bin.)

(bin.)




1.

000111

010100

010110

110011

7

20

22

51

0.56

1.59

8.73

2.

010010

001100

101100

100110

18

12

44

38

1.43

0.95

17.46

3.

010101

101010

001101

101000

21

42

13

40

1.67

3.33

5.16

4.

100100

001001

101100

100011

36

9

44

35

2.86

0.71

17.46

(9)

(10)

(11)

(12)

(13)

(14)

(15)

(16)

(17)

Base 4

y' (x = 1)

y' (x = 2)

y' (x =3)

y' (x = 4)

y' (x = 5)

Σ Error

Expected
Count = f/favg

Actual
Count

20.24

0

0

0

7.49

25

829.58

1.18

1

15.08

12.22

0

0

0

25

521.11

0.74

0

15.87

3.1

10.72

15.48

20.24

25

890.46

1.27

2

13.89

6.98

12.22

0

0

25

559.67

0.80

1




Sum

2800.82


Average

700.20

Maximum

890.46























Table no. 4 of: First Iteration using a Genetic Algorithm for Determining Optimal Membership Functions
C_{i} = C_{min} + [(b/2^{L} 1)(C_{maxi}  C_{mini} )...............................Eqn(7)
For fuzzy variable x (range x = 0.5) we employ C_{min} = 0 and C_{max} = 5 for both the membership functions S (Small) and L (Large). For fuzzy variable y we employ C_{min} = 0 and C_{max} = 25.
The physical representation of the first string is shown in above diagram. In this diagram the base values are acquired from Table 4, column 6, 7, 8, and 9. So, for illustration, the base values for the variable x for string number 1 are 0.56 and 5  1.59 = 3.14, and the base values for the variables y are 8.73, and 25  20.24 = 4.76. To calculate the fitness of the combination of membership functions in all of the strings, we want a measure of the square of the errors that are produced in estimating the values of the output y, specified the inputs x from Table 2. Above diagram shows how the value of the output y, can be computed graphically for the membership functions for string number 1 in Table 4. For illustration, for x = 4 we observe that the membership of x in the fuzzy class large is 0.37. Referring to the rules in Table 3, this can be seen that if x is Large then y is very large. Therefore, we seem for the value in the fuzzy class very Large or VL of fuzzy variable y that has a membership of 0.37. We find out this to be Equal to 12.25. The equivalent actual value for y is 16. The squared error therefore is (16  12.25)^{2} = 14.06. Columns 10, 11, 12, 13, 14 of Table 4 show the values computed for y using the respective membership functions. Table 4 column 15 displays the total of the squared errors subtracted from 1000 as this is done to convert the fitness function from a minimization problem to a maximization problem. Table 4, column 15 thus displays the fitness values for the four strings. We determine the sum of all the fitness values in the generation and the average fitness of the generation. The average fitness of the generation is utilized to find the relative fitness of the strings in the generation, as look in Table 4, in column 16. These relative fitness values are utilized to determine which strings are to be eliminated and which string gets how many copies to make the next generation of strings. In this problem a cutoff value of 0.75 has been utilized for the acceptability of a string propagating into the next generation. Table 4, column 17 displays the number of copies of all of the four strings that would be utilized to create the next generation of the strings.
The process of evaluating and generating strings is continued till we get a convergence to the solution inside a generation that is we get the membership functions with the best fitness value.