Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP305. Part II. Genetic Algorithms. Genetic Algorithms.

Similar presentations


Presentation on theme: "COMP305. Part II. Genetic Algorithms. Genetic Algorithms."— Presentation transcript:

1 COMP Part II. Genetic Algorithms. Genetic Algorithms

2 Topic 6. Schema Theorem. Genetic Algorithms

3 GAs by John Holland. 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

4 Basic Structure of a Genetic Algorithm.
Randomly generate initial population of n strings (“chromosomes”) Evaluate the fitness of each string in the population 3. Repeat the following steps until next generation of n individual strings produced 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

5 Example of a Genetic Algorithm.
2. Evaluate the fitness of each string in the population Chromosome Chromosome Fitness = number of ones index string in the string f8 = 5 f12 = 4 f13 = 6 f14 = 6 f Average fitness f = ( )/4 = 5.25 The average fitness in the population of possible solutions increases with every generation. Generation № Generation 3 0.5 0.3 0.1 Genetic Algorithms

6 Why Genetic Algorithms work?
It might be seen that similar “looking” chromosomes do have similar fitness values, and therefore are taken for reproduction equally often. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 1 Generation 0 Genetic Algorithms

7 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. Chromosome Chromosome Fitness index string f8 = 5 f12 = 6 f13 = 4 f14 = 6 Generation 3 Genetic Algorithms

8 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

9 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: **0 is a building block of the chromosome 111100 Genetic Algorithms

10 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 2l 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 = 2l different building blocks in the chromosome. l times Genetic Algorithms

11 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 2l 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 2bit (l=2) chromosome has 22=4 building blocks 1) *1 , 2) * , 3) ** , and 4) Genetic Algorithms

12 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

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. 10*00* outermost non-* symbols 3 positions between the outermost non-* symbols Genetic Algorithms

14 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

15 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

16 How it works? Consider the familiar
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. Consider the familiar example from the previous lectures: Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 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. Generation 0 Genetic Algorithms

17 How it works? 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. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 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. Generation 0 Genetic Algorithms

18 How it works? 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. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 1 The schema *****11* is present in the 1st and 2nd 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*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. Generation 0 Genetic Algorithms

19 How it works? 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. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 1 The schema *****11* is present in the 1st and 2nd 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 the probability of crossover pc. Generation 0 Genetic Algorithms

20 How it works? 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. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 1 The schema *****11* is present in the 1st and 2nd 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*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* . Generation 0 Genetic Algorithms

21 How it works? 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. Chromosome Chromosome Fitness Times to be selected index string for reproduction f1 = N1 = 1 f2 = N2 = 2 f3 = N3 = 0 n = f4 = N4 = 1 The schema *****11* is present in the 1st and 2nd 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*111* . Though these chances are still much smaller than the ones due to crossover, as mutation probability pm << pc the probability of crossover . Generation 0 Genetic Algorithms

22 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


Download ppt "COMP305. Part II. Genetic Algorithms. Genetic Algorithms."

Similar presentations


Ads by Google