genetic algorithms przemyslaw pawluk cse 6111 advanced algorithm design and analysis 03-12-2007

15
Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007 03-12-2007

Upload: howard-greer

Post on 14-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

Genetic Algorithms

Przemyslaw Pawluk

CSE 6111 Advanced Algorithm Design and Analysis

03-12-200703-12-2007

Page 2: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

2

Agenda

• The overview of the genetic idea

• The structure of genetic algorithms

• Where to use?

• The genetic algorithm for Traveling Salesman Problem

• Summary

Page 3: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

3

The overview – definitions

• Genotype (genome) – population of abstract representations of candidate solutions.

• Phenotype – the candidate solution.

• Fitness function – particular type of objective function that quantifies the optimality of the solution.

Page 4: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

4

Generation, Selection, Modification

• The genetic algorithm usually starts from randomly generated population.

• In each generation, the fitness of every individual in the population is evaluated,

• Multiple individuals are stochastically selected from the current population (based on their fitness), and modified (recombined and possibly randomly mutated) to form a new population.

• The new population is then used in the next iteration of the algorithm.

Page 5: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

5

AlgorithmChoose initial populationEvaluate the fitness of each individual in the populationRepeat until gen_no > max_gen_no or best <= <loop-inv: gen_no < max_gen_no and we have a set of

valid solutions and a best solution best that is not necessarily optimal>

Select best-ranking individuals to reproduceBreed new generation through crossover and mutation

(genetic operations) and give birth to offspring (gen_no++)

Evaluate the individual fitnesses of the offspring (set best)

Replace worst ranked part of population with offspring

Page 6: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

6

Changes - Mutation, Crossover

• Mutation – the random change in the chromosome.

• Crossover – two chromosomes change some portion of information

Crossover

i.e. Random change of some bits in the representationM

utation

0

1

Page 7: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

7

Genotype representation

• Usually binary arrays (lists) are used, to make the crossover operations easy however other representation are also used.

Page 8: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

8

Termination

• A solution is found that satisfies minimum criteria.

• Fixed number of generations reached.• Allocated budget (computation time/money)

reached.• The highest ranking solution's fitness is reaching

or has reached a plateau such that successive iterations no longer produce better results.

• Manual inspection.• Combinations of the above.

Page 9: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

9

Applications of GA

• Designing neural networks, both architecture and weights

• Robot trajectory • Evolving LISP programs (genetic

programming) • Strategy planning • Finding shape of protein molecules • TSP and sequence scheduling • Functions for creating images

Page 10: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

10

Traveling Salesman Problem

• Input – the set of cities (nodes) and the distances between them.

• Output – the permutation of cities.

• Goal – to find the minimal Hamiltonian tour.

dxixi+1 is a distance between xi and xi+1

(dxixi+1+ dxnx1)min

n-1

i=1

Page 11: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

11

Traveling Salesman Problem

• Permutation encoding used to encode chromosomes.

• Each chromosome is a string of numbers, which represents number of town in a entry sequence.

Chromosome A 1  5  3  2  6  4  7  9  8

Chromosome B 8  5  6  7  2  3  1  4  9

Page 12: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

12

TSP – crossover and mutation

• Mutation – take 2 arbitrary elements and swap them

• Crossover

Chromosome A 1  5  3  2  6  4 7  9  8

Chromosome B 8  5  6  7  2  3  1  4  9

Offspring A 1  5  3  2  6  4   8 7 9

Offspring B 5  6  2  3  1  4   7  9  8

Page 13: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

13

Traveling Salesman Problem

• Traveling salesman problem is NP-hard.

• The time to find the optimal solution is exponential.

• Application of the GA can reduce the time to polynomial, but do not guarantee that the optimal solution will be found.

• Example: Genetic Algorithm for TSP.

Page 14: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

14

Summary

• Improvements by crossing over

• Random mutation to avoid stucking in local min/max

• Widely used

Page 15: Genetic Algorithms Przemyslaw Pawluk CSE 6111 Advanced Algorithm Design and Analysis 03-12-2007

15

Questions