Transcript
Page 1: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Genetic Algorithms

虞台文

Page 2: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms

– Encoding– Fitness Function– Recombination– Mutation– Population– Selection Models

Page 3: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Genetic Algorithms

Evolutional Algorithms

Page 4: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Biological Evolution

Page 5: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Motivated from Nature

Nature evolve strikingly complex

organisms in response to

complex environmental

adaptation problems with

apparent ease

Localize and extract principles

from nature

Apply them to design algorithms

Page 6: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Darwinian Evolution 1: Survival of the Fittest

All environments have finite resources– can only support a limited number of individuals

Lifeforms have basic instinct/lifecycles geared towards reproduction

– Therefore some kind of selection is inevitable

– Those individuals that compete for the resources most effectively have increased chance of reproduction

Note: fitness in natural evolution is a derived, secondary measure, i.e., we (humans) assign a high fitness to individuals with many offspring

1809-1882

Page 7: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Darwinian Evolution 2: Diversity Drives Change

Phenotypic traits:– Behaviour/physical differences that affect response to

environment– Partly determined by inheritance, partly by factors

during development– Unique to each individual, partly as a result of random

changes If phenotypic traits:

– Lead to higher chances of reproduction– Can be inherited

then they will tend to increase in subsequent generations and, hence, lead to new combinations of traits …

1809-1882

Page 8: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Darwinian Evolution:Summary

Population consists of diverse set of individuals Combinations of traits that are better adapted

tend to increase representation in population Individuals are “units of selection”

Variations occur through random changes yielding constant source of diversity, coupled with selection means that:

Population is the “unit of evolution” Note the absence of “guiding force” w/o God

1809-1882

Page 9: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

PopulationPopulation

General Scheme ofEvolutional Algorithms (EAs)

ParentsParents

OffspringOffspring

Initialization

Termination

Parent Selection

Survivor Selection

Recombination

Mutation

Page 10: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

PopulationPopulation

General Scheme ofEvolutional Algorithms (EAs)

ParentsParents

OffspringOffspring

Initialization

Termination

Parent Selection

Survivor Selection

Recombination

Mutation

•A set of individuals corresponding

to candidate solutions to a

problem.

•Each individual has a fitness

value.

•How to represent the individuals?

•How to define the fitness

function?

•A set of individuals corresponding

to candidate solutions to a

problem.

•Each individual has a fitness

value.

•How to represent the individuals?

•How to define the fitness

function?

Page 11: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

PopulationPopulation

General Scheme ofEvolutional Algorithms (EAs)

ParentsParents

OffspringOffspring

Initialization

Termination

Parent Selection

Survivor Selection

Recombination

Mutation

Better individuals get higher probability

to become the parents of the next

generation.

Better individuals get higher probability

to become the parents of the next

generation.

Variation

operators

Variation

operators

Page 12: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

PopulationPopulation

General Scheme ofEvolutional Algorithms (EAs)

ParentsParents

OffspringOffspring

Initialization

Termination

Parent Selection

Survivor Selection

Recombination

Mutation

Replace some old

individuals with

newly born ones.

Replace some old

individuals with

newly born ones.

Page 13: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Pseudo-Code for Typical EA

Page 14: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Typical Behavior of an EA

Early phase:quasi-random population

distribution

Mid-phase:population arranged around/on

hills

Late phase:population concentrated on high

hills

Page 15: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Components of EAs

Representation definition of individuals Evaluation function fitness function Population Parent selection mechanism Variation operators

– Recombination– Mutation

Survivor selection mechanism replacement Termination

Page 16: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Different Types of EAs

Historically, different flavours of EAs have

been associated with different representations

– Binary strings : Genetic Algorithms

– Real-valued vectors : Evolution Strategies

– Finite state Machines: Evolutionary Programming

– LISP trees: Genetic Programming

Page 17: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Different Types of EAs

Historically, different flavours of EAs have

been associated with different representations

• Binary strings : Genetic Algorithms• Real-valued vectors : Evolution Strategies• Finite state Machines: Evolutionary Programming• LISP trees: Genetic Programming

• Binary strings : Genetic Algorithms• Real-valued vectors : Evolution Strategies• Finite state Machines: Evolutionary Programming• LISP trees: Genetic Programming

GeneticAlgorithms

EvolutionStrategies

Page 18: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Different Types of EAs

Historically, different flavours of EAs have

been associated with different representations

• Binary strings : Genetic Algorithms• Real-valued vectors : Evolution Strategies• Finite state Machines: Evolutionary Programming• LISP trees: Genetic Programming

• Binary strings : Genetic Algorithms• Real-valued vectors : Evolution Strategies• Finite state Machines: Evolutionary Programming• LISP trees: Genetic Programming

EvolutionaryProgramming

GeneticProgramming

Page 19: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Genetic Algorithms

Genetic Algorithms

Page 20: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

The Genetic Algorithm

Directed search algorithms based on the mechanics of biological evolution

Developed by John Holland, University of Michigan (1970’s)– To understand the adaptive processes of

natural systems– To design artificial systems software that

retains the robustness of natural systems

Page 21: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Genetic Algorithms

Holland’s original GA is now known as the simple genetic algorithm (SGA)

Other GAs use different:– Representations– Mutations– Crossovers– Selection mechanisms

Page 22: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

SGA Technical Summary Tableau

Representation Binary strings

Recombination N-point or uniform

MutationBitwise bit-flipping with fixed probability

Parent selection Fitness-Proportionate

Survivor selection

All children replace parents

Speciality Emphasis on crossover

Page 23: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Representation

Genotype space

Phenotype spaceEncoding

(representation)

Decoding(inverse representation)

011101001

010001001

10010010

10010001

Page 24: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

SGA Evolution Cycle

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

2. Shuffle the mating pool3. For each consecutive pair apply crossover

with probability pc , otherwise copy parents

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

5. Replace the whole population with the resulting offspring

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

2. Shuffle the mating pool3. For each consecutive pair apply crossover

with probability pc , otherwise copy parents

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

5. Replace the whole population with the resulting offspring

Page 25: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

SGA Operators: 1-Point Crossover

Choose a random point on the two parents Split parents at this crossover point Create children by exchanging tails pc typically in range (0.6, 0.9)

Page 26: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

SGA Operators: Mutation

Alter each gene independently with a probability pm

pm is called the mutation rate

– Typically between 1/pop_size and 1/chromosome_length

Page 27: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

SGA Operators: Selection

Main idea: better individuals get

higher chance

– Chances proportional to fitness

– Implementation

roulette wheel technique

Assign to each individual a part of

the roulette wheel

Spin the wheel n times to select n

individuals

C33%

B17%

A50%

fitness(A) = 3

fitness(B) = 1

fitness(C) = 2

Page 28: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Exercise: The OneMax Problem

The OneMax Problem (or BitCounting) is a simple problem consisting in maximizing the number of ones of a bitstring.

Formally, this problem can be described as finding a string x = (x1, x2, …, xn) , with xi{0, 1} , that maximizes the following equation:

1

( )n

ii

F x

x

Page 29: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Genetic Algorithms

Main Components of GA’s

Page 30: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Nature-to-Computer Mapping

Nature Computer

Individual Solution to a problem

Population Set of solutions

Fitness Quality of a solution

Chromosome Encoding for a solution

Gene Part of the encoding of a solution

Crossover Search Operator (Local)

Mutation Search Operator (Global)

Nature Selection Reuse of good (sub-)solutions

Page 31: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Main Components of GA’s

Encoding principles (gene, chromosome)

Initialization procedure (creation)

Selection of parents (reproduction)

Genetic operators (mutation, recombination)

Fitness function (environment)

Termination condition

Page 32: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Encoding The process of representing the solution in the for

m of a string that conveys the necessary information.

Just as in a chromosome, each gene controls a particular characteristic of the individual, similarly, each bit in the string represents a characteristic of the solution.

Hence, the encoding mechanism depends on the nature of the problem variables.

Page 33: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Commonly Used Encoding Schemes

Binary Encoding– most common and simplest one

Permutation Encoding– used in “ordering problems”, e.g., TSP

Direct Value Encoding– used in problems with complicated values

Tree Encoding– used mainly for evolving programs or

expressions, e.g., genetic programming

Page 34: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Binary Encoding

• Binary Encoding• Permutation Encoding• Direct Value Encoding• Tree Encoding

Most common method of encoding.– Chromosomes are strings of 1s and 0s and

each position in the chromosome represents a particular characteristic of the problem.

11111110000000011111Chromosome B

10110010110011100101Chromosome A

Page 35: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding

• Binary Encoding• Permutation Encoding• Direct Value Encoding• Tree Encoding

Useful in ordering problems such as the Traveling Salesman Problem (TSP). – Every chromosome is a string of numbers,

each of which represents a city to be visited.

8  5  6  7  2  3  1  4  9Chromosome B

1  5  3  2  6  4  7  9  8Chromosome A

Page 36: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Direct Value Encoding

• Binary Encoding• Permutation Encoding• Direct Value Encoding• Tree Encoding

Used in problems where complicated values, such as real numbers, are used and where binary encoding would not suffice.

Good for some problems, but often necessary to develop some specific crossover and mutation techniques for these chromosomes.

(left), (back), (left), (right), (forward)Chromosome B

1.235  5.323  0.454  2.321  2.454Chromosome A

Page 37: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Tree Encoding

• Binary Encoding• Permutation Encoding• Direct Value Encoding• Tree Encoding

Tree encoding is used mainly for evolving programs or expressions for genetic programming.

In tree encoding every chromosome is a tree of some objects, such as functions or commands in programming language.

Page 38: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

More on Binary Encoding Gray coding of integers

Integer Binary Gray

0 000 000

1 001 001

2 010 011

3 011 010

4 100 110

5 101 111

6 110 101

7 111 100 

Page 39: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

More on Binary Encoding Gray coding of integers

Gray coding is a mapping that “attempts” to improve causality, i.e., small changes in the genotype cause small changes in the phenotype, unlike binary coding.– “Smoother” genotype-phenotype mapping makes

life easier for the GA.

Nowadays it is generally accepted that it is better to encode numerical variables directly as integers and floating point variables

Page 40: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

More on Binary Encoding Interval Representation

z [x, y] represented by {a1,…,aL} {0,1}L

[x, y] {0,1}L must be invertible

: {0,1}L [x, y] defines the representation1

10

( ,..., ) 2 [ , ]2 1

Lj

L L jLj

y xa a x a x y

Page 41: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover

It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics.

Two strings are picked from the mating pool at random to cross over.

The method chosen depends on the Encoding Method.

Page 42: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover

It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics.

Two strings are picked from the mating pool at random to cross over.

The method chosen depends on the Encoding Method.

Page 43: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover Operators

Binary Encoding– 1-Point Crossover– 2-Point Crossover– N-Point Crossover– Uniform Crossover

Permutation Encoding

Page 44: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Binary Encoding 1-Point Crossover

Chromosome1 11011 | 00100110110

Chromosome 2 11011 | 11000011110

Offspring 1 11011 | 11000011110

Offspring 2 11011 | 00100110110

Page 45: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Binary Encoding 2-Point Crossover

Chromosome1 11011 | 00100 | 110110

Chromosome 2 10101 | 11000 | 011110

Offspring 1 10101 | 00100 | 011110

Offspring 2 11011 | 11000 | 110110

Page 46: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Binary Encoding N-Point Crossover

Choose N random crossover points Split along those points Glue parts, alternating between parents

Page 47: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Binary Encoding Uniform Crossover

Each gene (bit) is selected randomly from one of the corresponding genes of the parent chromosomes.

Chromosome1 11000101 01011000 01101010

Chromosome 2 00100100 10111001 01111000

Offspring 1 01000101 01111000 01111010

Offspring 2 10100100 10011001 01101000

Page 48: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Order Crossover (OX)

Builds offspring by choosing a sub-sequence of a tour

from one parent and preserving the relative order of

cities from the other parent and feasibility

1 2 3 4 5 6 7 8 9

4 5 2 1 8 7 6 9 3

Page 49: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Order Crossover (OX)

1 2 3 4 5 6 7 8 9

4 5 2 1 8 7 6 9 3

1 2 3 4 5 6 7 8 9

Builds offspring by choosing a sub-sequence of a tour

from one parent and preserving the relative order of

cities from the other parent and feasibility

Page 50: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Order Crossover (OX)

1 2 3 4 5 6 7 8 9

4 5 2 1 8 7 6 9 3

1 2 3 4 5 6 7 8 9

Builds offspring by choosing a sub-sequence of a tour

from one parent and preserving the relative order of

cities from the other parent and feasibility

2 1 8 9 3

Page 51: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Order Crossover (OX)

1 2 3 4 5 6 7 8 9

4 5 2 1 8 7 6 9 3

1 2 3 4 5 6 7 8 9

Builds offspring by choosing a sub-sequence of a tour

from one parent and preserving the relative order of

cities from the other parent and feasibility

2 1 8 9 3

Chromosome1 1 2 3 4 5 6 7 8 9

Chromosome 2 4 5 2 1 8 7 6 9 3

Offspring 1 3 4 5 1 8 7 6 9 2

Offspring 2 2 1 8 4 5 6 7 9 3

Page 52: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

Page 53: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

4 5 6 7

9 3 8 2 16 5 47

Step 1

Page 54: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 7

9 3 8 2 16 5 47

Step 2

4 5 6 79 3 1

Page 55: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 7

9 3 8 2 16 5 47

Step 3

4 5 6 79 3 1 82

Page 56: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 79 3 1 82

1 2 3 4 5 6 7 8 9

9 3 7 8 2 6 5 1 4

1 2 3 4 5 6 7 8 9

8 2 6 5

Step 1

Page 57: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 79 3 1 82

1 2 3 4 5 6 7 8 9

8 2 6 5

Step 2

8 2 6 51 3 9

Page 58: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 79 3 1 82

1 2 3 4 5 6 7 8 9

8 2 6 5

Step 3

8 2 6 51 3 947

Page 59: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Partially Mapped Crossover (PMX)

4 5 6 79 3 1 82

8 2 6 51 3 947

Chromosome1 1 2 3 4 5 6 7 8 9

Chromosome 2 9 3 7 8 2 6 5 1 4

Offspring 1 9 3 2 4 5 6 7 1 8

Offspring 2 1 7 3 8 2 6 5 4 9

Page 60: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Cycle Crossover

4 5 6 7 91 2 83

8 2 6 59 7 413

Page 61: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Cycle Crossover

4 5 6 7 91 2 83

8 2 6 59 7 413

Step 1: identify cycles

4 91 8

89 41

Page 62: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Cycle Crossover

4 5 6 7 91 2 83

8 2 6 59 7 413

Step 1: identify cycles

4 91 8

89 41

5 72 3

2 573

Page 63: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Cycle Crossover

4 5 6 7 91 2 83

8 2 6 59 7 413

Step 1: identify cycles

4 91 8

89 41

5 72 3

2 573

6

6

Page 64: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Cycle Crossover

4 5 6 7 91 2 83

8 2 6 59 7 413

Step 1: identify cycles

4 91 8

89 41

5 72 3

2 573

6

6

Step 2: copy alternate cycles into offspring

4 91 8

89 415 72 3

2 573 6

6

Page 65: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Edge Recombination

4 5 6 7 91 2 83

8 2 6 59 7 413

Step 1: Construct edge table

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Page 66: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Permutation Encoding Edge Recombination

1

Step 1: Construct edge table

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Step 2: Randomly choose start node

Page 67: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge table

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Step 2: Randomly choose start nodeStep 3: Remove visited nodes

Page 68: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

Page 69: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Page 70: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

Page 71: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Page 72: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6

Page 73: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6

Page 74: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2

Page 75: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2

Page 76: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8

Page 77: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8

Page 78: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7

Page 79: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7

Page 80: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3

Page 81: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

2 4 7 9

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3

Page 82: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3 9

Page 83: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3 9

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Page 84: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3 9 4

Page 85: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Permutation Encoding Edge Recombination

1

Step 1: Construct edge tableStep 2: Randomly choose start nodeStep 3: Remove visited nodes

Step 4:Pick common edge if existentPick one with the shortest listTies are split at random

5

Step 5: Loop to Step 3 until done

6 2 8 7 3 9 4

2 4 7 9

2 4 5 91

2

3

4

5

6

7

8

9

1 3 6 8

1 3 5 9

1 4 +6

2 +5 7

3 6 +8

2 +7 9

1 3 4 8

Page 86: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover for Real Valued GAs

Discrete:– Each allele value in offspring z comes from one of its

parents (x, y) with equal probability: zi = xi or yi

– Could use n-point or uniform Intermediate

– exploits idea of creating children “between” parents (hence a.k.a. arithmetic recombination)

– zi = xi + (1 ) yi where : 0 1.– The parameter can be:

• constant: uniform arithmetical crossover• variable (e.g. depend on the age of the population) • picked at random every time

Page 87: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Single Arithmetic Crossover

• Parents: x1,…, xn and y1,…, yn• Pick a single gene (k) at random

• child1 is:

• reverse for other child. e.g. with = 0.5

1 11, ..., , ,..., (1 )k kk nx x xy x

Page 88: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Simple Arithmetic Crossover

• Parents: x1,…, xn and y1,…, yn• Pick random gene (k) after this point mix values

• child1 is:

• reverse for other child. e.g. with = 0.5

11 1 (1 ) (, ..., , ,.. 1. ), k k n nk y x y xx x

Page 89: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Whole Arithmetic Crossover

• Parents: x1,…, xn and y1,…, yn

• child1 is:

• reverse for other child. e.g. with = 0.5

(1 ) x y

Page 90: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

More on Crossover

Crossover between 2 good solutions MAY NOT ALWAYS yield a better or as good a solution.

Since parents are good, probability of the child being good is high.

If offspring is not good (poor solution), it will be removed in the next iteration during “Selection”.

Page 91: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover or Mutation

Decade long debate: Which one is better / necessary / main-background?

Answer (at least, rather wide agreement):– it depends on the problem, but– in general, it is good to have both– both have another role– mutation-only-EA is possible, xover-only-EA would not wor

k in general

Page 92: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover or Mutation

Exploration: – Discovering promising areas in the search space, i.e.

gaining information on the problem– Crossover is “usually” explorative, it makes a big jump

to an area somewhere “in between” two (parent) areas

Exploitation:– Optimizing within a promising area, i.e. using

information– Mutation is “usually” exploitative, it creates random

small diversions, thereby staying near (in the area of ) the parent

Page 93: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Crossover or Mutation

Crossover can combine information from two parents

Mutation can introduce new information (alleles)

Crossover does not change the allele frequencies of the population

To hit the optimum you often need a ‘lucky’ mutation

Page 94: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Mutation Operators

Binary EncodingValue Encoding

– Integers– Floating points

Permutation Encoding

Page 95: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Mutation Operator for Binary Encoding

For chromosomes using Binary Encoding, randomly selected bits are inverted.

Offspring 11011 00100 110110

Mutated Offspring 11010 00100 100110

NOTE: The number of bits to be inverted depends on the Mutation Probability.

Page 96: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Mutation Operator for Value Encoding

Creep – Adding small offset to randomly chosen allele(s)

Random choice – Assign random value to randomly chosen allele

(s)Offspring 9 15 7 0 32 50 70

Mutated Offspring 9 17 7 0 80 50 70

Page 97: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Mutation Operators for Permutation Encoding

Insert Mutation

Swap Mutation

Inversion mutation

Page 98: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Elitism

When creating a new population by crossover or mutation the best chromosome might be lost.

Forces GAs to retain some number of the best individuals at each generation.

Has been found that elitism significantly improves performance.

Elitism is a method which copies the best chromosome to the new offspring population before crossover and mutation.

Page 99: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Population Models

SGA uses a Generational model:– each individual survives for exactly one generation– the entire set of parents is replaced by the offspring

At the other end of the scale are Steady-State models:– one offspring is generated per generation,– one member of population replaced,

Generation Gap – the proportion of the population replaced– 1.0 for GGA, 1/pop_size for SSGA

Page 100: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Fitness Function A fitness function quantifies the optimality of a solution (chr

omosome) so that that particular solution may be ranked against all the other solutions.

A fitness value is assigned to each solution depending on how close it actually is to solving the problem.

Ideal fitness function correlates closely to goal + quickly computable.

Example: In TSP, f(x) is sum of distances between the cities in solution. The lesser the value, the fitter the solution is.

Page 101: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Selection Models

Selection can occur in two places:– Parent selection Selection from current

generation to take part in mating– Survivor selection Selection from parents

+ offspring to go into next generation Distinction between selection

– operators: define selection probabilities – algorithms: define how probabilities are

implemented

Page 102: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Parent Selection

Fitness-Proportionate Selection– Roulette wheel algorithm

– Baker’s SUS algorithm:

Rank-Based Selection– Linear Ranking

– Exponential Ranking

Tournament Selection

Page 103: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Fitness-Proportionate Selection

Roulette wheel algorithm:– Given a probability distribution, spin a 1-

armed wheel n times to make n selections

Baker’s SUS algorithm:– Stochastic Universal Sampling– n evenly spaced arms on wheel and spin

once

Page 104: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Fitness-Proportionate Selection

Problems– One highly fit member can rapidly take over if rest of

population is much less fit: Premature Convergence– At end of runs when fitnesses are similar, lose

selection pressure – Highly susceptible to function transposition

Scaling can fix last two problems– Windowing: f’(i) = f(i) - t

where is worst fitness in this (last n) generations

– Sigma Scaling: f’(i) = max[ f(i) – ( f - c • f ), 0.0] where c is a constant, usually 2.0

Page 105: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Function Transposition for FPS

Page 106: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Rank-Based Selection

Attempt to remove problems of FPS by basing selection probabilities on relative rather than absolute fitness

Rank population according to fitness and then base selection probabilities on rank where fittest has rank and worst rank 1

Page 107: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Rank-Based Selection

Linear Ranking

Exponential Ranking

lin-rank(2 ) 1)( 1)

( ) ,1.0 2.0s i s

P i s

exp-rank1

( )ie

P ic

Page 108: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Tournament Selection

Page 109: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Tournament Selection

All methods above rely on global population statistics– Could be a bottleneck esp. on parallel machines– Relies on presence of external fitness function

which might not exist: e.g., evolving game players

Informal Procedure:– Pick k members at random then select the best

of these– Repeat to select more individuals– k = 2: binary tournament selection

Page 110: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Tournament Selection

6 3 4 5 2 18479

2 6 3 4 5 18142

4 1 3 2 5 67993

4 3 2 1 5 66872

3 6 4 1 2 58971

4 1 3 2 5 67993

4 3 2 1 5 66872

6 3 4 5 2 18479

3 6 4 1 2 58971

5 2 6 4 3 18673

5 2 6 4 3 18673

2 6 3 4 5 18142

4 3 2 1 5 66872

5 2 6 4 3 18673

4 1 3 2 5 67993

2 6 3 4 5 18142

4 3 2 1 5 66872

2 6 3 4 5 18142

Mating Pool

Page 111: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

Some Demonstrations

http://cs.felk.cvut.cz/~xobitko/ga/ http://www.heatonresearch.com/articles/65/page1.html http://homepage.sunrise.ch/homepage/pglaus/gentore.htm#Applet http://www.ads.tuwien.ac.at/raidl/tspga/TSPGA.html http://www.see.ed.ac.uk/~rjt/ga.html?http://oldeee.see.ed.ac.uk/~rjt/ga.

html

Page 112: Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination

References

A Survey of Genetic Algorithm

Genetic Algorithms: A Survey

A Genetic Algorithm Tutorial