genetic algorithm

33
GENETIC ALGORITHM

Upload: rachel

Post on 19-Jan-2016

52 views

Category:

Documents


0 download

DESCRIPTION

GENETIC ALGORITHM. General Introduction to GAs. Genetic algorithms (GAs) are a technique to solve problems which need optimization. GAs are a subclass of Evolutionary Computing and are random search algorithms. GAs are based on Darwin’s theory of evolution. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: GENETIC  ALGORITHM

GENETIC ALGORITHM

Page 2: GENETIC  ALGORITHM

General Introduction to GAs

Genetic algorithms (GAs) are a technique to solve problems which need optimization.

GAs are a subclass of Evolutionary Computing and are random search algorithms.

GAs are based on Darwin’s theory of evolution. i.e fundamental principle of natural selection(Which states “Survival of Fittest”).

History of GAs:• Evolutionary computing evolved in the 1960s.• GAs were created by John Holland in the mid-1970s.

Page 3: GENETIC  ALGORITHM

Biological Background (1) – The Cell

Every cell is a complex of many small “factories”

working together.

The center of this all is the cell nucleus.

The nucleus contains the genetic information.

Page 4: GENETIC  ALGORITHM

Biological Background (2) – Chromosomes

Genetic information is stored in the chromosomes.

Each chromosome is build of DNA(Deoxyribonucleic acid, a self-replicating material present in nearly all living organisms as the main constituent of chromosomes).

Chromosomes in humans form pairs.

There are 23 pairs.

The chromosome is divided in parts: genes.

Genes code for properties.

The posibilities of the genes for one property is called: allele.

Every gene has an unique position on the chromosome: locus.

Page 5: GENETIC  ALGORITHM

Biological Background (3) – Genetics

The entire combination of genes is called genotype. A genotype develops into a phenotype. Dominant genes will always express from the genotype to

the fenotype. Recessive genes can survive in the population for many

generations without being expressed.

Page 6: GENETIC  ALGORITHM

Biological Background (4) – Reproduction

Reproduction of genetical information:

• Mitosis,• Meiosis.

Mitosis is copying the same genetic information to new offspring: there is no exchange of information.

Mitosis is the normal way of growing of multicell structures, like organs.

Page 7: GENETIC  ALGORITHM

Meiosis is the basis of reproduction.

After meiotic division 2 gametes appear in the process.

In reproduction two gametes conjugate to a zygote wich will become the new individual.

Hence genetic information is shared between the parents in order to create new offspring.

Biological Background (5) – Reproduction

Page 8: GENETIC  ALGORITHM

Biological Background (6) – Natural Selection The origin of species: “Preservation of favorable

variations and rejection of unfavorable variations.”

There are more individuals born than can survive, so there is a continuous struggle for life.

Individuals with an advantage have a greater chance for survive: survival of the fittest. For example, Giraffes with long necks.

Genetic variations due to crossover and mutation.

Page 9: GENETIC  ALGORITHM

Genetic Algorithm (1) – Search Space

Most often one is looking for the best solution in a specific subset of solutions.

This subset is called the search space (or state space).

Every point in the search space is a possible solution.

Therefore every point has a fitness value, depending on the problem definition.

GAs are used to search the search space for the best solution, e.g. a minimum.

Difficulties are the local minima and the starting point of the search.

0 100 200 300 400 500 600 700 800 900 10000

0.5

1

1.5

2

2.5

Page 10: GENETIC  ALGORITHM

Genetic Algorithm (2) – Basic Algorithm

Starting with a subset of n randomly chosen solutions from the search space (i.e. chromosomes). This is the population.

This population is used to produce a next generation of individuals by reproduction.

Individuals with a higher fitness have more chance to reproduce (i.e. natural selection).

Page 11: GENETIC  ALGORITHM

Comparison of Natural and GA Terminology

Natural Genetic Algorithm

ChromosomeGeneAlleleLocus

GenotypePhenotype

StringFeature or character

Feature valueString position

StructureParameter set, a decoded

structure

Page 12: GENETIC  ALGORITHM

Genetic Algorithm (3) – Basic Algorithm

Outline of the basic algorithm

0 START : Create random population of n chromosomes1 FITNESS : Evaluate fitness f(x) of each chromosome in the population 2 NEW POPULATION

1 REPRODUCTION/SELECTION : Based on f(x)2 CROSS OVER : Cross-over chromosomes3 MUTATION : Mutate chromosomes

3 REPLACE : Replace old with new population: the new generation4 TEST : Test problem criterium5 LOOP : Continue step 1 – 4 untill criterium is satisfied

Page 13: GENETIC  ALGORITHM

Flowchart of GA

• All individuals in population

evaluated by fitness function.

• Individuals allowed to

reproduce (selection),

crossover, mutate.

Page 14: GENETIC  ALGORITHM
Page 15: GENETIC  ALGORITHM

Genetic Algorithm – Reproduction Cycle

1. Select parents for the mating pool (size of mating pool = population size).

2. Shuffle the mating pool.

3. For each consecutive pair apply crossover.

4. For each offspring apply mutation (bit-flip independently for each bit).

5. Replace the whole population with the resulting offspring.

Page 16: GENETIC  ALGORITHM

Genetic Algorithm – Encoding

Encoding is the process of representing individual genes.

The process can be performed using bits,numbers,trees,

arrays.

Encoding depends on solving the problem.

Types of Encoding:1. Binary Encoding

The most common way of encoding is a binary string.

Each chromosome encodes a binary (bit) string.

Each bit in the string can represent some characterstics of

the solution.

Every bit string is the solution but not necessarily the best

solution.

Page 17: GENETIC  ALGORITHM

Binary Encoding

2. Octal Encoding

This encoding uses the string made up of octal numbers (0-7).

3. Hexadecimal Encoding

This encoding uses the string made up of hexadecimal numbers(0-9,A-F)

Chromosome 1 110100011010

Chromosome 2 011111111100

Chromosome 1 03467216

Chromosome 2 15723314

Chromosome 1 9CE7

Chromosome 2 3DBA

Page 18: GENETIC  ALGORITHM

4. Permutation Encoding(Real Numer Encoding)

Every chromosome is a string of numbers represented in a sequence.

5. Value Encoding

Every chromosome is a atring of values and the values can be anything connected to the problem.

Chromosome A 153264798

Chromosome B 856723149

Chromosome A 1.2324 5.3243 .4556 2.3293

Chromosome B ABDGIFEFLKJAHSLKJDHAS

Chromosome C (back), (back), (right), (forward)

Page 19: GENETIC  ALGORITHM

Genetic Algorithm – Selection

Picks out individual based on their fitness relative to other individuals

Picks out individual based on their rank within the population

Page 20: GENETIC  ALGORITHM

Genetic Algorithm – Selection Selection has to be balanced with variation from crossover and mutation.

Too strong selection means fit individuals will take over the population.

Too weak selection will result in too slow evolution.

The various selection method are discussed:

Roulette Wheel Selection.

Random selection-Randomly selects parent from population.

Rank Selection

Tournament Selection.

Boltzman selection

Page 21: GENETIC  ALGORITHM

Roulette Wheel Selection. The principle of roulett wheel is a linear search through a

roulett wheel with the slots in the wheel weighted in

proportion to the individual fitness value.

A target value is set , the population is stepped through

untill the target value is achieved.

The wheel spuns N times where n is the number of

individual in the population .

On each spin the individual under the wheels marker is

selected to be in the pool of parents for the next

generation.

Page 22: GENETIC  ALGORITHM

Rank Selection.

Rank selection ranks the population and every chromosome

recieves fitness from the ranking.

The worst has fitness 1 and the best has fitness N.

Tournament Selection.

The best individual from the tournament is the one with the

highest fitness , who is the winner of competition among Nu

individuals.

The are then inserted into the mating pool .

The tournament is repeated untill the mating pool for

generating new offspring is filled.

The mating pool comprising tournament winner has higher

average population fitness

Page 23: GENETIC  ALGORITHM

Genetic Algorithm – Crossover (Single Point) Crossover is the process of taking two parent solution and

producing from them a child.

After the selection population is enriched with better

individuals.

Crossover operator applied over mating pool with the

hope that it creates better offspring.

It proceeds in three steps:

The reproduction operator selects at

random a pair of two individual string.

A cross site is selected.

Finally position value are swapped between

the two string following the cross site.

Page 24: GENETIC  ALGORITHM

Genetic Algorithm – Crossover (Single Point) In a single point crossover cross site is selected at

random and bit next to cross sites are exchanged.

Choose a random point on the two parents.

Split parents at this crossover point.

Create children by exchanging tails.

Parent 1 10110 010

Parent 2 10101 111

child 1 10110 111

Child 2 10101 010

Page 25: GENETIC  ALGORITHM

Genetic Algorithm – Crossover (Two Point)

In two point crossover two cross over points are chosen and the content between these points are exchanged between two mated parents.

Parent 1 10 110 010

Parent 2 10 101 111

child 1 10 101 111

Child 2 10 110 010

Page 26: GENETIC  ALGORITHM

Genetic Algorithm – Uniform Crossover

A random generated binary crossover mask of the same length as the chromosome.

On producing child 1 Where there is 1 in mask the gene is copied from the first parent, and where there is 0 in mask the gene is copied from the second parent, and for producing child 2 when there is 1 in mask the gene is copied from parent 2 and when 0 gene is copied from parent 1.

Parent 1 1 0 1 1 0 0 1 0

Parent 2 1 0 1 0 1 1 1 1

Mask 1 1 0 1 0 1 1 0

Child 1 1 0 1 1 1 0 1 1

Child 2 1 0 1 0 0 1 1 0

Page 27: GENETIC  ALGORITHM

Genetic Algorithm – Three Parent Crossover

In this crossover technique three parents are randomly chosen.

Each bit of the first parent is compared with the bit of the second parent. if both are same the bit is taken for the offspring otherwise bit from third parent is taken for the offspring.

Parent 1 1 0 1 1 0 0 1 0

Parent 2 1 0 1 0 1 1 1 1

Parent 3 1 1 0 1 0 1 1 0

Child 1 1 0 1 1 0 1 1 0

Page 28: GENETIC  ALGORITHM

Genetic Algorithm – Mutation

Mutation plays the role of recovering the lost genetic material as well as randomly distributing genetic information.

It is an insurance policy against the irreversible loss of genetic material.

Mutation introduces new genetic structure in the population by randomly modifying some of its(genetic) building block.

1. Flipping flipping of bit involves changing 0 to 1 and 1 to 0 based

on mutation chromosome. For a 1 in mutation chromosome the corresponding bit in a parent chromosome is flipped (0 to 1 and 1 to 0)

Parent 1 1 0 1 1 0 1 0 1

Mutation chromosome 1 0 0 0 1 0 0 1

Child 1 0 0 1 1 1 1 0 0

Page 29: GENETIC  ALGORITHM

Genetic Algorithm –Interchanging

Two random position of bit are chosen and the bits corresponding to those position are interchanged.

Parent 1 1 0 1 1 0 1 0 1

Child 1 1 1 1 1 1 0 0 1

Reversing :A random position is chosen and the bits next to that position are reversed and child chromosome is produced.

Parent 1 1 0 1 1 0 0 1 1

Child 1 1 1 1 1 1 1 0 0

Page 30: GENETIC  ALGORITHM

Has been subject of many (early) studies

• still often used as benchmark for novel Gas.

Shows many shortcomings, e.g.

• Representation is too restrictive.• Mutation & crossovers only applicable for bit-string &

integer representations.• Selection mechanism sensitive for converging

populations with close fitness values.

Simple Genetic Algorithm

Page 31: GENETIC  ALGORITHM

Comparison of GA with Traditional Optimization Techniques

GA works with the coding of solution set and not with the solution itself.

GA uses population of solutions rather than a single solution for searching.

GA uses fitness function for evaluation rather the derivatives.

GA uses probabilistic transition and not deterministic rules.

Page 32: GENETIC  ALGORITHM

References

Holland, J. (1992), Adaptation in natural and artificial systems , 2nd Ed. Cambridge: MIT Press.

Davis, L. (Ed.) (1991), Handbook of genetic algorithms. New York: Van Nostrand Reinhold.

Goldberg, D. (1989), Genetic algorithms in search, optimization and machine learning. Addison-Wesley.

Fogel, D. (1995), Evolutionary computation: Towards a new philosophy of machine intelligence. Piscataway: IEEE Press.

Bäck, T., Hammel, U., and Schwefel, H. (1997), ‘Evolutionary computation: Comments on the history and the current state’, IEEE Trans. On Evol. Comp. 1, (1)

Page 33: GENETIC  ALGORITHM

Online Resources

http://www.spectroscopynow.com

http://www.cs.bris.ac.uk/~colin/evollect1/evollect0/index.htm\

IlliGAL (http://www-illigal.ge.uiuc.edu/index.php3)

GAlib (http://lancet.mit.edu/ga/)