genetic algorithms. evolutionary methods methods inspired by the process of biological evolution....

23
Genetic Genetic Algorithms Algorithms

Upload: madeline-fisher

Post on 17-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Genetic Genetic AlgorithmsAlgorithms

Page 2: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Evolutionary Methods Evolutionary Methods

Methods inspired by the process of biological evolution.

Main ideas:

Population of solutions

Assign a score orfitness value to each solution

Retain the bestsolutions (survival of the fittest)

Generate newsolutions (offspring)

Page 3: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Figure 7.2Figure 7.2

Page 4: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Genetic AlgorithmsGenetic Algorithms

The fundamental unit of representation is a chromosome. A chromosome is a bit of strings representing a solution to our problem. 00010011110011111

In our case, a chromosome will be a classifier or hypothesis.

A hypothesis is good if it has a high fitness value.What is a fitness value?

In classification, for example, the fitness value could bethe accuracy of the hypothesis on test examples.

Page 5: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

ParametersParameters

A genetic algorithm has the following parameters:

A fitness function that gives a score to every hypothesis.

Θ: A fitness threshold above which we stop and take the hypothesis with best fit.

L: The number of hypothesis in the current population.

Pco: the fraction of hypothesis replaced by cross-over.

Pmut: the mutation rate.

Page 6: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

AlgorithmAlgorithm

Initialize population with L hypotheses at random

Repeat

For each hypothesis h compute its fitness

Rank all hypotheses based on their fitness value

Generate a new population using genetic operators

Until max_fitness > Θ

Return the hypothesis with highest fitness

Page 7: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Figure 7.13Figure 7.13

Page 8: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Genetic OperatorsGenetic OperatorsThe most common operators are crossover, mutation, and replication.

Crossover (exploration):

There are different variations. The most common is called single-pointcrossover:

Initial Strings Crossover Mask Offspring

11101001000 11101010101 11111000000

00001010101 00001001000

Page 9: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Genetic OperatorsGenetic Operators

Mutation:

The idea is to produce small changes to a string at random.

Under a uniform distribution, we select one bit and switch its value.

00001010101 01001010101

Select second bit.

Replication:

A chromosome is simply reproduced, and left unchanged.

Page 10: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Figure 7.14Figure 7.14

Page 11: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

New PopulationNew Population

Create a new generation Ps:

1. Replicate (1-Pco)L members of P and add them to Ps (Exploitation). The probability of selecting a member is

P(hi) = Fitness (hi) / Σj Fitness (hj)

2. Crossover.- select (Pco L)/2 pairs of hypotheses from P according to P(hi) (Exploration). For each pair (h1,h2)

produce two offspring by applying the Crossover operator. Add all offspring to Ps.

3. Mutate.- Choose (Pmut L) members of Ps with uniform probability. Invert one bit in the representation randomly (Exploration).

4. Update P with Ps

Page 12: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Representing HypothesesRepresenting Hypotheses

We need to represent each hypothesis as a binary string.

We can encode as bits of strings:

Neural Networks

Decision Trees

etc.

Page 13: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Figure 7.15Figure 7.15

Page 14: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Fitness Function and SelectionFitness Function and Selection

Selection.

The typical approach is the “fitness proportionate selection” or“roulette wheel selection”:

P(hi) = Fitness (hi) / Σj Fitness (hj)

Other options are rank selection: Rank according to fitness,but then select based on rank only.

Page 15: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Further HeuristicsFurther Heuristics

Other heuristics exist to improve performance:

1. Adjust the mutation and crossover rates to ensure that convergence is fast. One way to do it is by encoding their values and letting the genetic algorithm adapt them.

2. Use ternary or n-ary chromosomes (instead of binary). The advantage is that classifiers become easier to encode.

Page 16: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Exploration vs ExploitationExploration vs Exploitation

Exploitation: Maximize reward by exploitingoptimal and known solutions.

vs

Exploration: Maximize long-term rewardby searching for new solutions.

Page 17: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

John H. HollandJohn H. Holland

Born in Indiana 1929.Author of “Adaptation in Natural and Artificial Systems”written in 1975, providing the basis of genetic algorithms.Recipient of the McArthur Fellowship.

Page 18: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Genetic ProgrammingGenetic Programming

Genetic programming is a form of evolutionary computation in which the individuals in the population are computer programs.

Programs are normally represented by trees. A program is executedby parsing the tree. Example:

+

sin sqrt

x + ^ y x 2

F = sin(x) + sqrt( x^2 + y)

Page 19: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

VocabularyVocabulary

To apply genetic programming one has to define the functionsthat can be applied:

Example: sin, cos, sqrt, +, -, etc.

A genetic programming algorithm explores the space of combinations of these functions.

The fitness of an individual is determined by executing the program on a set of training data.

Page 20: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Cross OverCross Over

The crossover operator is performed by replacing subtrees ofone program with subtrees of another program.

+

Sin ^

x + x y

+

Sin sqrt

x + ^ y x 2

2

Page 21: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Cross Over: ResultCross Over: Result

+

Sin ^

x ^ x y

+

Sin sqrt

x + + y x 2

2

Page 22: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

Figure 7.17Figure 7.17

Page 23: Genetic Algorithms. Evolutionary Methods Methods inspired by the process of biological evolution. Main ideas: Population of solutions Assign a score or

J.R. KozaJ.R. Koza

Author of “Genetic Programming I II III and IV”. Professor Stanford UniversityMember of several editorial boards.