COMP 305 Part II Genetic Algorithms 1 Topic






















- Slides: 22
COMP 305. Part II. Genetic Algorithms 1
Topic 6. Schema Theorem. Genetic Algorithms 2
GAs by John Holland introduced a “population” of binary strings which he called “chromosomes”. The “population” evolves using kind of “natural selection” together with the genetics-inspired operators of crossover, mutation, and inversion. Bits in a “chromosome” represent genes, and each “gene” is an instance of a particular “allele”, 0 or 1. The selection operator chooses those chromosomes in the population that will be allowed to reproduce, and on average the fitter chromosomes produce more offspring than the less fit ones. Crossover exchange subparts of two chromosomes Mutation randomly changes the allele values of some locations in the chromosome. Inversion reverses the order of a contiguous section of the chromosome rearranging the genes order. Genetic Algorithms 3
Basic Structure of a Genetic Algorithm. 1. Randomly generate initial population of n strings (“chromosomes”) 2. 3. Evaluate the fitness of each string in the population Repeat the following steps until next generation of produced n individual strings a. Select pair of parent chromosomes from current population according to their fitness, i. e. chromosomes with higher fitness are selected more often b. Apply crossover (with probability) c. Apply mutation (with probability of occurrence) 4. Apply generational replacement 5. Go to 2 or terminate if termination condition met Genetic Algorithms 4
Example of a Genetic Algorithm. 2. Evaluate the fitness of each string in the population Generation 3 Chromosome index Chromosome string 8 12 13 14 11100110 00101110 11011110 01111110 f Average fitness Fitness = number of ones in the string f 8 = 5 f 12 = 4 f 13 = 6 f 14 = 6 f = (5+4+6+6)/4 = 5. 25 The average fitness in the population of possible solutions increases with every generation. 0 1 2 3 Generation № Genetic Algorithms 5
Why Genetic Algorithms work? Generation 0 It might be seen that a) similar “looking” chromosomes do have similar fitness values, and therefore b) are taken for reproduction equally often. Chromosome index Chromosome string Fitness 1 00000110 f 1 = 2 N 1 = 1 2 1110 f 2 = 6 N 2 = 2 3 00100000 f 3 = 1 N 3 = 0 n= 4 00110010 f 4 = 3 N 4 = 1 Genetic Algorithms Times to be selected for reproduction 6
Similarities in GAs chromosomes. Similarities among highly fit strings guide the search. Holland introduced a similarity template = schema = building block to describe subset of strings with similarities at certain positions. Generation 3 Chromosome index 8 12 13 14 Chromosome string 11100110 11011110 00101110 01111110 Genetic Algorithms Fitness f 8 = 5 f 12 = 6 f 13 = 4 f 14 = 6 7
Similarity Template = Schema. Definition: A schema (plural, schemata) is a similarity template describing a subset of strings with similarities at certain string positions. Other name for a schema is a building block of a chromosome. Genetic Algorithms 8
Similarity Template = Schema. To describe building blocks of binary chromosomes, the following three letter alphabet is used: 0, 1, and * called a do not care symbol. A 1 or 0 at any position of a building block means that the chromosome must have the same bit at that position for it to contain the building block. The “do not care” - “*” symbol at any position in the building block means that the value of the chromosome bit at this position is irrelevant to determining whether or not the chromosome contains the building block. Example: 111**0 is a building block of the chromosome 111100 Genetic Algorithms 9
Similarity Template = Schema. Question: How many building blocks there are in a particular chromosome of a fixed length? Answer: In a binary chromosome of a length l there are 2 l building blocks. To match a particular chromosome of a fixed length the schema must a) be of the same length as the chromosome, b) have the same symbol as the chromosome does or a “*”, i. e. the “do not care” symbol at a corresponding locus As a symbol at a particular locus in the chromosome must correspond either to the same or the do not care symbol in the corresponding locus in the schema, there might be 2× 2× …. × 2 = 2 l different building blocks in the chromosome. l times Genetic Algorithms 10
Similarity Template = Schema. How many building blocks there are in a particular chromosome of a fixed length? Answer: in a binary chromosome of a length l there are 2 l building blocks, as a symbol at a particular locus in the chromosome must correspond to the same or the do not care symbol in the corresponding locus in the schema. Example 3: The 2 bit (l=2) chromosome 1) 2) 3) 4) 11 has 22=4 building blocks *1 , 1* , ** , and 11 Genetic Algorithms 11
Similarity Template = Schema. Definition: The ORDER of a schema is the number of non-* symbols it contains. Example 5: Order of the schema 10*00*** is 4. Example 6: Order of the schema *** is 0. One might say that the order of the schema *** is lower than the one of the schema 10*00***. Genetic Algorithms 12
Similarity Template = Schema. Definition: The DEFINING LENGTH of a schema is the distance, i. e. the number of positions, between the outermost non-* symbols. Example 7: The defining length of the schema 10*00* is 3. 3 positions between the outermost non-* symbols 10*00* outermost non-* symbols Genetic Algorithms 13
Similarity Template = Schema. Definition: The DEFINING LENGTH of a schema is the distance, i. e. the number of positions, between the outermost non-* symbols. Example 7: The defining length of the schema 10*00* is 3. Example 8: The defining length of the schema *11*** is 0. One might say that the defining length of the schema *11*** is shorter than the one of the schema 10*00* Genetic Algorithms 14
Schema Theorem. Highly fit, short defining length, low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Genetic Algorithms 15
Schema Theorem. Highly fit, short defining length, How it works? low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Generation 0 Consider the familiar example from the previous lectures: Chromosome index Chromosome string Fitness Times to be selected for reproduction 1 2 3 n=4 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 It might be seen that the *****11* building block is present in the first and the second strings. This schema represents a subset of chromosomes with the fitness not less than 2. Genetic Algorithms 16
Schema Theorem. Highly fit, short defining length, Generation 0 How it works? low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Chromosome index Chromosome string Fitness Times to be selected for reproduction 1 2 3 n=4 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 The schema 111* is present in the second string, and it represents a subset of chromosomes with the fitness no less than 6. Thus, every schema represents a subset of chromosomes with a particular average fitness, and selection more often chooses for reproduction chromosomes containing highly fit schemata, so these schemata tend to stay and reproduce in the population from generation to generation. Genetic Algorithms 17
Schema Theorem. Highly fit, short defining length, Generation 0 How it works? • low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Chromosome index Chromosome string Fitness Times to be selected for reproduction 1 2 3 n=4 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 The schema *****11* is present in the 1 st and 2 nd strings. It has a defining length 0 and represents chromosomes with the fitness ≥ 2. The schema 111* is present in the second string. It has a defining length 5 and represents chromosomes with the fitness ≥ 6. Although the schema 111* has higher fitness, due to the long defining length it has more chances to be destroyed by crossover than the schema *****11* with shorter defining length. Genetic Algorithms 18
Schema Theorem. Highly fit, short defining length, How it works? Generation 0 Chromosome index • 1 2 3 n=4 low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Chromosome string Fitness 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 Times to be selected for reproduction N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 The schema *****11* is present in the 1 st and 2 nd strings. It has a defining length 0 and represents chromosomes with the fitness ≥ 2. The schema 111* is present in the second string. It has a defining length 5 and represents chromosomes with the fitness ≥ 6. Irrelevant to the defining length, chances to be destroyed by mutation will rather depand on the number of non-* symbols in the schema, i. e. the order of the schema, although these chances are much smaller compare to the ones due to crossover, as the mutation probability pm is usually much smaller than 19 the probability of crossover. Genetic pc. Algorithms
Schema Theorem. Highly fit, short defining length, Generation 0 How it works? • low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Chromosome index Chromosome string Fitness Times to be selected for reproduction 1 2 3 n=4 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 The schema *****11* is present in the 1 st and 2 nd strings. It has an order = 2 and represents chromosomes with the fitness ≥ 2. The schema 111* is present in the second string. It has an order = 6 and represents chromosomes with the fitness ≥ 6. Although the schema 111* has higher fitness, due to the high order it might also have longer defining length, and therefore more chances to be destroyed by crossover than the lower order schema *****11*. Genetic Algorithms 20
Schema Theorem. Highly fit, short defining length, How it works? Generation 0 Chromosome index • 1 2 3 n=4 low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Chromosome string Fitness 00000110 1110 00100000 00110010 f 1 = 2 f 2 = 6 f 3 = 1 f 4 = 3 Times to be selected for reproduction N 1 = 1 N 2 = 2 N 3 = 0 N 4 = 1 The schema *****11* is present in the 1 st and 2 nd strings. It has an order = 2 and represents chromosomes with the fitness ≥ 2. The schema 111* is present in the second string. It has an order = 6 and represents chromosomes with the fitness ≥ 6. Chances to be destroyed by mutation are equal to Dm=order×pm. Thus, chances to be destroyed by mutation will be higher for the high order schema 111*. Though these chances are still much smaller than the ones due to crossover, as mutation probability pm << pc the probability of crossover. Genetic Algorithms 21
Schema Theorem. In Genetic Algorithms, Highly fit, short defining length, low order schemas propagate from generation to generation and give exponential increase of samples to the observed best. Genetic Algorithms 22






















