15
Questions & Answers on Genetic Algor ithm: 1. Explain the cycle of Genetic Algorithm. 2. Illustrate with an example to solve the Traveling Salesman Problem b y using Genetic  Algorithm. 3. State and prove the schema theorem for Genetic Algorithm. 4. Discuss on various selection strategies of Genetic Algorithm . 5. Discuss on different types of crossover method applied in Genetic Al gorithm . 6. Discuss on different types of mutation operation of Genetic Algorithm. 7. Discuss on the genetic parameters: Population Size, Crossover Rate, and Mutation Rate.   Cycle of Genetic Algor ithm: Professor John Holland in 1975 proposed an attractive class of computational models, called Genetic Algorithms (GA), that mimic the biological evolution process for solving problems in a wide domain. The mechanisms under GA have been analyzed and explained later by Goldberg, De Jong, Davis, Muehlenbein, Chakraborti, Fogel, Vose and many others. Genetic Algorithms has three major applications, namely, intelligent search, optimization and machine learning. A Genetic Algorithm operates through a simple cycle of stages:  Creation of a “population” of strings  Evaluation of each string,  Selection of best strings  Apply genetic manipulation like crossover and mutation to create new population of strings. Each cycle in Genetic Algorithms produces a new generation of possible solutions for a given  problem. In the first phase, an initial population, describing representatives of the potential solution, is created to initiate the search process. The elements of the population are encoded into  bit-strings, called chromosomes. The performance of the strings, often called fitness, is then evaluated with the help of some functions, representing the constraints of the problem. Depending on the fitness of the chromosomes, they are selected for a subsequent genetic manipulation process. The cycle of a Genetic Algorithms is presented b elow

GeneticAlgorithmQA

Embed Size (px)

Citation preview

Page 1: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 1/15

Questions & Answers on Genetic Algorithm:

1. Explain the cycle of Genetic Algorithm .

2.

Illustrate with an example to solve the Traveling Salesman Problem by using Genetic Algorithm . 3. State and prove the schema theorem for Genetic Algorithm . 4. Discuss on various selection strategies of Genetic Algorithm . 5. Discuss on different types of crossover method applied in Genetic Algorithm . 6. Discuss on different types of mutation operation of Genetic Algorithm . 7. Discuss on the genetic parameters: Population Size, Crossover Rate, and Mutation Rate.

• Cycle of Genetic Algorithm:Professor John Holland in 1975 proposed an attractive class of computational models, calledGenetic Algorithms (GA), that mimic the biological evolution process for solving problems in awide domain. The mechanisms under GA have been analyzed and explained later by Goldberg,De Jong, Davis, Muehlenbein, Chakraborti, Fogel, Vose and many others. Genetic Algorithmshas three major applications, namely, intelligent search, optimization and machine learning.

A Genetic Algorithm operates through a simple cycle of stages:

Creation of a “population” of strings Evaluation of each string, Selection of best strings Apply genetic manipulation like crossover and mutation to create new population of

strings.

Each cycle in Genetic Algorithms produces a new generation of possible solutions for a given problem. In the first phase, an initial population, describing representatives of the potentialsolution, is created to initiate the search process. The elements of the population are encoded into

bit-strings, called chromosomes. The performance of the strings, often called fitness, is thenevaluated with the help of some functions, representing the constraints of the problem.Depending on the fitness of the chromosomes, they are selected for a subsequent genetic

manipulation process.

The cycle of a Genetic Algorithms is presented below

Page 2: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 2/15

Here, we shall present a very simple genetic algorithms working with a fixed number of binarystrings of fixed length. For this purpose, let us assume that the strings we consider are all fromthe set S = {0, 1} n, where n is obviously the length of the strings. The population size will bedenoted with m in the following. Therefore, the generation at time t is a list of m strings whichwe will denote with Bt = (b 1, t , b2, t, . . . b m,t).

Selection:

Selection means to extract a subset of genes from an existing (in the first step, from the initial population) population, according to any kind of a quality measurement that relates thecorresponding solution’s degree of accuracy i.e. Selection is carried out with proportional to

fitness . Each gene has a related fitness i.e. f(b j,t ) which denotes fitness of j-th solution at t-thgeneration.. The higher the value of the fitness, the better is the probability of selection.

where Probability[b j,t is selected] =

Page 3: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 3/15

Mating/Crossover:

The next step in creating a new population is Crossover . P C percent of the individual of the new population will be selected randomly and mated in pairs.

1. A crossover point (see fig.1) will be chosen for each pair 2. The information after the crossover-point will be exchanged between the two individual

of each pair.

Single Point Crossover Algorithm:

pos := Random{1, . . . , n − 1};FOR i := 1 TO pos DOBEGINChild1[i] := Parent1[i];

Child2[i] := Parent2[i]ENDFOR i := pos + 1 TO n DOBEGINChild1[i] := Parent2[i];Child2[i] := Parent1[i]END

Mutation:

The last step is the Mutation where e ach bit in every gene has a defined probability P M to getinverted.

Page 4: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 4/15

Algorithm for Mutation:

FOR i := 1 TO n DOIF Random[0, 1] < P M THENinvert s[i];

Overall Genetic Algorithm

Page 5: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 5/15

• Illustration of Genetic Algorithm in solving the TravelingSalesman Problem:

Given a finite set of vertices/cities {v1, . . . , vN}. For every pair of cities (vi, vj), the distanceDi,j is known (i.e. we have a symmetric K × K distance matrix). What we want to find is a

permutation (p1, . . . , pN) such that the total way i.e. the sum of distances is minimal:

It seems promising to encode a permutation as a string of integer numbers where entry no. i refers to the i-th city which is visited.

City 1 2 3 4

1 0 4 5 62 5 0 3 5

3 6 13 0 4

4 8 8 9 0

Fig. The Distance Matrix and the Graph

1 2

43

Page 6: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 6/15

Selection:

The selection method aims at choosing a permutation of cities based on its fitness. The fitnessvalue may be taken as the inverse of the sum of distances.

Crossover:

The conventional crossover is not purely applicable for TSP since it may produce incorrect permutation as a crossover operation. We may apply partially mapped crossover to avoidconflicting permutation positions yielded in conventional crossover operation. Partially mappedcrossover aims at keeping as many positions from the parents as possible. To achieve this goal, asubstring is swapped like in two-point crossover and the values are kept in all other non-conflicting positions. The conflicting positions are replaced by the values which were swapped tothe other offspring. An example:

p1 = (1 2 4 3) p2 = (4 1 3 2)

Assume that positions 2 through 3 are selected for swapping. Then the two offspring are given asfollows if we omit the conflicting positions marked by *:o1 = (* | 1 3 | *)o2 = (* | 2 4 | *)

Now we take the conflicting positions and try to fill in according to what has already beenswapped to the other offspring and we need to continue the swap operation until no conflictingcase results in. For instance, 1 and 2 were swapped. Therefore, we have to replace the conflicting1 in the first position of o1 by 2, and so on:o1 = (2 1 3 4)o2 = (3 2 4 1)

Mutation:

For mutation we may randomly select a junction/edge connecting two cities with probability Pmand swap the cities in the permutation to keep up the validity of the resulting permutation. For instance, p1= (1 2 4 3) may be mutated to o1= (1 4 2 3) if the edge 2—4 gets selectedfor mutation point.

String No. Initial Population Fitness

1 1 2 4 3 1/(4+5+9+6)=1/24

2 4 1 3 2 1/(8+5+13+5)=1/31

3 2 1 3 4 1/(5+5+4+8)=1/22

4 3 2 4 1 1/(13+5+8+5)=1/31

5 2 4 3 1 1/(5+9+6+4)=1/24

Page 7: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 7/15

String No. 2nd Population Fitness

1 2 1 3 4 1/(5+5+4+8)=1/22

2 1 2 4 3 1/(4+5+9+6)=1/24

3 2 1 4 3 1/(5+6+9+13)=1/33

4 1 2 3 4 1/(4+3+4+8)=1/19

5 2 3 4 1 1/(3+4+8+4)=1/19

Selection operation from the Initial Population results in choosing the permutation (2 1 3 4)and (1 2 4 3) for the next mating pool. These two permutations are highly probable for selection due to their high fitness value.

Crossover operation on the permutation (2 1 3 4) and (1 2 4 3 ) results in (2 1 43) and (1 2 3 4 ) on selection of crossover points 3 through 4. Luckily no conflicting

position results for such crossover point.

Mutation operation on the permutation (2 4 3 1) results in (2 3 4 1) due to selection of edge (4—3) as mutation point.

String No. 3rd Population Fitness

1 1 2 3 4 1/(4+3+4+8)=1/19

2 2 3 4 1 1/(3+4+8+4)=1/19

3 1 3 4 2 1/(5+4+8+5)=1/22

4 4 2 3 1 1/(8+3+6+6)=1/23

5 2 1 3 4 1/(5+5+4+8)=1/22

Selection operation from the 2nd Population results in choosing the permutation (1 2 3 4)and (2 3 4 1) for the next mating pool. These two permutations are highly probable for selection due to their high fitness value.

Page 8: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 8/15

Page 9: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 9/15

The number of individuals which fulfill H at time step t are denoted as

The expression refers to the observed average fitness at time t:

The term stands for the observed average fitness of schema H in time step t:

Theorem: Assuming we consider a genetic algorithm with proportional selection, the followinginequality holds for every schema H:

Proof:The probability that we select an individual fulfilling H with fitness proportional selection is

…………………………….(1)

This probability does not change throughout the execution of the selection loop. Moreover, eachof the m individuals is selected completely independently from the others. Hence, the number of selected individuals, which fulfill H, is binomially distributed with sample amount m and the

probability in (1). We obtain, therefore, that the expected number of selected individualsfulfilling H is

If two individuals are crossed, which both fulfill H, the two offspring again fulfill H. The number of strings fulfilling H can only decrease if one string, which fulfills H, is crossed with a string

which does not fulfill H, but, obviously, only in the case that the cross site is chosen somewherein between the specifications of H. The probability that the cross site is chosen within thedefining length of H is

Hence the survival probability p S of H, i.e. the probability that a string fulfilling H produces anoffspring also fulfilling H, can be estimated as follows (crossover is only done with probability

pC):

Page 10: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 10/15

Selection and crossover are carried out independently, so we may compute the expected number of strings fulfilling H after crossover simply as

After crossover, the number of strings fulfilling H can only decrease if a string fulfilling H isaltered by mutation at a specification of H with probability p m. The probability that allspecifications of H remain untouched by mutation is obviously

Therefore, under selection, crossover and mutation, the expected sample size of schema H in generation(t + 1) can be formulated as

• Various selection strategies of Genetic Algorithm:

Selection is a genetic operator that chooses a chromosome from the current generation’s population for inclusion in the next generation’s population.

Roulette : The idea behind the roulette wheel selection parent selection technique is that eachindividual is given a chance to become a parent in proportion to its fitness evaluation. It is calledroulette wheel selection as the chances of selecting a parent can be seen as spinning a roulettewheel with the size of the slot for each parent being proportional to its fitness. Obviously thosewith the largest fitness (and slot sizes) have more chance of being chosen. Usually a proportionof the wheel is assigned to each of the possible selection based on their fitness value. This could

be achieved by dividing the fitness of a selection by the total fitness of all the selections, therebynormalizing them to 1. Then a random selection is made similar to how the roulette wheel isrotated.

Page 11: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 11/15

Algorithm:

for all members of populationsum += fitness of this individual

end for

for all members of populationprobability = sum of probabilities + (fitness / sum)sum of probabilities += probability

end for

loop until new population is fulldo this twice

number = Random between 0 and 1for all members of population

if number > probability but less than next probabilitythen you have been selected

end forendcreate offspring

end loop

Tournament : Tournament selection is a method of selecting an individual from a population of individuals in a genetic algorithm. Tournament selection involves running several "tournaments"among a few individuals chosen at random from the population. The winner of each tournament(the one with the best fitness) is selected.

Top Percent: Top Percent is a method of randomly selecting a chromosome from the top N percent of the population as specified by the user.

Best : A selection operator which selects the best chromosome (as determined by fitness). If thereare two or more chromosomes with the same best fitness, one of them is chosen randomly.

Page 12: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 12/15

• Different types of crossover method applied in GeneticAlgorithm:

Crossover is a genetic operator that combines (mates) two chromosomes (parents) to produce anew chromosome (offspring). The idea behind crossover is that the new chromosome may be

better than both of the parents if it takes the best characteristics from each of the parents.Crossover occurs during evolution according to a user-definable crossover probability.

One Point Crossover:A crossover operator that randomly selects a crossover point within a chromosome theninterchanges the two parent chromosomes at this point to produce two new offspring.

Consider the following 2 parents which have been selected for crossover. The “|” symbol

indicates the randomly chosen crossover point.

Parent 1: 11001|010Parent 2: 00100|111

After interchanging the parent chromosomes at the crossover point, the following offspring are produced:

Offspring1: 11001|111Offspring2: 00100|010

Two Point Crossover:

A crossover operator that randomly selects two crossover points within a chromosome theninterchanges the two parent chromosomes between these points to produce two new offspring.

Consider the following 2 parents which have been selected for crossover. The “|” symbolsindicate the randomly chosen crossover points.

Parent 1: 110|010|10

Parent 2: 001|001|11

After interchanging the parent chromosomes between the crossover points, the followingoffspring are produced:

Offspring1: 110|001|10Offspring2: 001|010|11

Page 13: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 13/15

Page 14: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 14/15

• Various Types of Mutation operation of Genetic Algorithm:

Mutation is the process of random modification of the value of a string with small probability. Itis not a primary operator but it ensures that the probability of searching any region in the

problem space is never zero and prevents complete loss of genetic material through reproductionand crossover. Mutation is an important part of the genetic search as help helps to prevent the

population from stagnating at any local optima. Mutation occurs during evolution according to auser-definable mutation probability. This probability should usually be set fairly low (0.01 is agood first choice). If it is set to high, the search will turn into a primitive random search.

Flip Bit : A mutation operator that simply inverts the value of the chosen gene (0 goes to 1 and 1goes to 0). This mutation operator can only be used for binary genes.

Boundary : A mutation operator that replaces the value of the chosen gene with either the upper or lower bound for that gene (chosen randomly). This mutation operator can only be used for integer and float genes.

Non-Uniform : A mutation operator that increases the probability that the amount of themutation will be close to 0 as the generation number increases. This mutation operator keeps the

population from stagnating in the early stages of the evolution then allows the genetic algorithmto fine-tune the solution in the later stages of evolution. This mutation operator can only be usedfor integer and float genes.

Uniform : A mutation operator that replaces the value of the chosen gene with a uniform randomvalue selected between the user-specified upper and lower bounds for that gene. This mutationoperator can only be used for integer and float genes.

Gaussian : A mutation operator that adds a unit Gaussian distributed random value to the chosengene. The new gene value is clipped if it falls outside of the user-specified lower or upper boundsfor that gene. This mutation operator can only be used for integer and float genes.

Page 15: GeneticAlgorithmQA

8/6/2019 GeneticAlgorithmQA

http://slidepdf.com/reader/full/geneticalgorithmqa 15/15

• Genetic parameters: Population Size, Crossover Rate, andMutation Rate:

Population Size: Population size affects the efficiency of the algorithm. If we have smaller population, it would only cover a small search space and may results in poor performance. Alarger population would cover more space and prevent premature convergence to local solutions.At the same time, a large population needs more evaluation per generations and may slow downthe convergence rate.

As a general observation of previous works on GA, increase in complexity of the algorithm leadsto a need for larger population size.

Probability of Crossover: Probability of crossover or crossover rate is the parameter that affectsthe rate at which the crossover operator is applied. A higher crossover rate introduces new stringsmore quickly into the population. For uniform crossover, a higher probability of contributingones parents’ allele lowers the rate of disruption. If the crossover rate is too high, high

performance strings are eliminated faster that selection can produce improvements. A lowcrossover rate may cause stagnation due to the lower exploration rate.

Probability of Mutation: Probability of mutation or mutation rate is the probability with whicheach bit position of each string in the new population undergoes a random change after aselection process. A low mutation rate helps to prevent any bit positions from getting stuck to asingle value, where as a high mutation rate results in essentially random search.