You are on page 1of 23

Genetic Algorithm

Main steps of GA

Step-1: Coding.

Step-2: Selection (for reproduction).

Step-3: Cross-over.

Step-4: Mutations.

2
Genetic Algorithms: Stochastic Operators
Selection replicates the most successful solutions
found in a population at a rate proportional to their
relative quality. Also known as Reproduction.

Examples of selections schemes:


Roulette wheel selection (probabilistic selection
based on fitness).

Rank selection (pick the best individual each


time).

Tournament selection (select K individuals, and


keep best for reproduction).
3
Genetic Algorithms: Stochastic Operators Cont…

Recombination decomposes two distinct solutions


and then randomly mixes their parts to form novel
solutions. Also known as Crossover.

Mutation randomly perturbs a candidate solution.

4
Genetic Algorithms: Metaphors Cont…

The computer model introduces simplifications


(relative to the real biological mechanisms),

BUT

Surprisingly complex and interesting structures have


emerged out of evolutionary algorithms.

5
Genetic Algorithms: A Simple Genetic Algorithm

Produce an initial population of individuals

Evaluate the fitness of all individuals

while termination condition not met do


select fitter individuals for reproduction
recombine between individuals
mutate individuals
evaluate the fitness of the modified individuals
generate a new population
End while
6
Genetic Algorithms: The Evolutionary Cycle

parents
selection modification
modified
offspring
initiate & evaluation
population
evaluate evaluated off-spring
deleted
members

discard
GA: Example f(x) = x2
Actual count was generated using coin tosses.

Note the similarity with pselect, we obtained what we


expected.

The best strings get more copies, while the weak ones
just die off.

After selection, crossover takes place in two steps

(i) strings combined randomly using coin tosses


(ii) selection of crossing sites using coin tosses.

13
GA: Example f(x) = x2

Mating pool after Mate coded New population x value f(x) x2


selection

1 13 0110|1 2 24 1100|0 01100 12 144


2 24 1100|0 1 13 0110|1 11001 25 625
2 24 11|000 4 19
10|011 11011 27 729
3 08
4 19
10|011 01|000 10000 16 256

14
GA: Example f(x) = x2

Before After

2000

1500

1000

500

0
Sum Avg Max

15
GA: Example f(x) = x2
Notes:
Initial population chosen by four repetitions of five coin tosses
where head = 1 and tail = 0

Reproduction performed through 1 part in 8 simulation of


roulette wheel selection i.e. 3 coin tosses.

Crossover performed by binary decoding of 2 coin tosses (TT


= 002 = 0 = cross site 1, HH = 112 = 3 = cross site 4)

Crossover probability assumed to be unity pc = 1.0.

Mutation probability pm assumed to be 0.001, expected


mutations = 5 x 4 x 0.0001 = 0.02. No mutation expected
during a single generation. None simulated.
18
Visualizing GA (maximizing)
BEFORE

Objective

AFTER

Function

Multidimensional Search Space 19


A Simple Example

“The Gene is by far the most sophisticated program around.”


- Bill Gates, Business Week, June 27, 1994

20
A Simple Example

The Traveling Salesman Problem:

Find a tour of a given set of cities so that


– each city is visited only once
– the total distance traveled is minimized

21
Representation

Representation is an ordered list of city


numbers known as an order-based GA.
1) London 3) Dunedin 5) Beijing 7) Tokyo
2) Venice 4) Singapore 6) Phoenix 8) Victoria

CityList1 (3 5 7 2 1 6 4 8)
CityList2 (2 5 7 6 8 1 3 4)

22
Crossover

Crossover combines inversion and


recombination:
* *
Parent1 (3 5 7 2 1 6 4 8)
Parent2 (2 5 7 6 8 1 3 4)

Child (5 8 7 2 1 6 3 4)

This operator is called the Order1 crossover.


23
Mutation

Mutation involves reordering of the list:

* *
Before: (5 8 7 2 1 6 3 4)

After: (5 8 6 2 1 7 3 4)

24
Genetic Algorithms: Why do they work?
GA offers a means of searching a broad search space.

Different features of problem are represented in search space by


DNA representation
– parallel nature: often many solutions to a problem
– different “good” characteristics represented by particular gene
settings
– some combinations of these genes are better than others

Evolution creates new gene combinations --> new areas of search


space to try.

Key to success: individuals that are fitter are more likely to be


retained and mated; poorer individuals are more likely discarded.

Global search technique, unlike other search techniques that use


heuristics to prune the search space.

Adv Algo: Spring 2006 30


When to use GA?
• Alternate solutions are too slow or overly complicated

• Need an exploratory tool to examine new approaches

• Problem is similar to one that has already been


successfully solved by using a GA

• Want to hybridize with an existing solution

• Benefits of the GA technology meet key problem


requirements

31
Some GA Application Types

Domain Application Types


Control gas pipeline, pole balancing, missile evasion, pursuit

Design semiconductor layout, aircraft design, keyboard


configuration, communication networks
Scheduling manufacturing, facility scheduling, resource allocation

Robotics trajectory planning

Machine Learning designing neural networks, improving classification


algorithms, classifier systems
Signal Processing filter design

Game Playing poker, checkers, prisoner’s dilemma

Combinatorial set covering, travelling salesman, routing, bin packing,


graph colouring and partitioning
Optimization
32
Issues for GA Practitioners
• Choosing basic implementation issues:
– representation
– population size, mutation rate, ...
– selection, deletion policies
– crossover, mutation operators

• Termination Criteria

• Performance, scalability

• Solution is only as good as the evaluation function


(often hardest part)
33
GA: Limitations & Weaknesses
Extremely appealing idea, but falls-short for
practical combinatorial optimization problems
because:

Unnatural to model most applications in terms of genetic


operators like mutation and crossover on bit strings.

Pseudo biology adds another level of complexity between


you and your problem.

Process of selection alone is too systematic and


predictable, not like creativity as we know it.

34
GA: Limitations & Weaknesses

Binary representations limited in operations and for certain


problems alternative operators and representations required.

Real problem info NOT used, hence slow convergence.

Take very long on non-trivial problems due to many


objective function evaluations as compared to classical
optimization techniques.

Analogy with evolution is appropriate, but it took millions of


years to achieve significant improvement. Can we afford to
wait that long?

35

You might also like