Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic algorithms Prof Kang Li

Similar presentations


Presentation on theme: "Genetic algorithms Prof Kang Li"— Presentation transcript:

1 Genetic algorithms Prof Kang Li

2 Last lecture RBF This Lecture Genetic algorithm Basic GA operations

3 Content What is Genetic Algorithm? How to implement GA? A example
Encoding Selection Crossover Mutation A example Matlab demo Differential evolution

4 What is Genetic Algorithm?
Bio-Inspired artificial intelligence class of probabilistic optimization algorithms Well-suited for nonlinear/hard problems with a large search space Influenced by Darwin’s Origin of species Developed by John Holland, Adaptation in Natural and Artificial Systems, U of Michigan Press, 1975

5 Natural Selection (Darwin’s theory)
Genetic contents -> survival capacity -> features Reproduction recombination (or crossover) first occurs. Genes from parents combine to form a whole new chromosome. Newly created offspring mutated, elements of DNA are changed.  Diversity Survival of the fittest Gene of the fittest survive, gene of weaker die out Elitism Evolution - change of species’ feature to fit environment

6 Natural Selection

7 Main idea Produce a population of candidate solutions for a given problem Use operators inspired by the mechanisms of natural genetic variation Apply selective pressure toward certain properties Evolve to a more fit solution

8 Nature to Computer Mapping
Population Individual Fitness Chromosome Gene Set of solutions Solution to a problem Quality of a solution Encoding for a Solution Part of the encoding of a solution

9

10 Simple Genetic Algorithm
Simple_Genetic_Algorithm() { Initialize the Population; Calculate Fitness Function; While(the number of generation > maximum number) { Selection;//Natural Selection, Survival Of Fittest Crossover;//Reproduction, Propagate favorable characteristics Mutation;//Mutation Calculate Fitness Function; } }

11 Structure of Genetic Algorithm
crossover 1 selection Search space 1 1 population A B C D mutation Fitness evaluation 1 reproduction Substitution

12 Genetic Algorithm Process
2017/4/23 Genetic Algorithm Process Initial population 5th generation 10th generation

13 Applications of GA Difficult Problems such as NP-class
Nonlinear dynamical systems - predicting, data analysis Designing neural networks, both architecture and weights Robot Trajectory Planning Evolving LISP programs (genetic programming) Strategy planning Finding shape of protein molecules TSP and sequence scheduling Functions for creating images VLSI layout planning

14 GA Process Crossover Selection Encoding Mutation

15 Encoding The process of representing the solution in the form of a string that conveys the necessary information. Just as in a chromosome, each gene controls a particular characteristics of the individual, and each bit in the string represents a characteristics of the solution.

16 Encoding Methods Binary Encoding
Most common method of encoding. Chromosomes are strings of 1s and 0s and a gene of chromosomes represents the a particular characteristics of the problem. Chromosome B Chromosome A

17 Encoding Methods (contd.)
Permutation Encoding Useful in ordering problems such as the Traveling Salesman Problem (TSP). Example. In 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  9 Chromosome B 1  5  3  2  6  4  7  9  8 Chromosome A

18 Encoding Methods (contd.)
Value 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.454 Chromosome A

19 Selection Based on fitness function:
Determines how ‘good’ an individual is (fitness) Better fitness, higher probability of survival Selection of individuals for differential reproduction of offspring in next generation Favors better solutions Decreases diversity in population B A C

20 Selection – Roulette Wheel
Each solution gets a region on a roulette wheel according to its fitness Spin wheel, select solution marked by roulette-wheel pointer stochastic selection (better fitness = higher chance of reproduction) Individual i will have a probability to be chosen

21 Selection - Tournament
randomly select q individuals from current population Winner: individual(s) with best fitness among these q individuals Example: select the best two individuals as parents for recombination q=6 selection

22 Crossover Crossover is a critical feature of genetic algorithms:
Crossover process simulates the exchange of genetic material that occurs during biological reproduction In this process pairs in the breeding population are mated randomly with a crossover rate, Pc Typical crossover properties include that an offspring inherits the common feature from the parents along with the ability of the offspring to inherit two completely different features Popular crossover techniques: one point, two point and uniform crossover Chromosome A Chromosome B Chromosome A* Chromosome B*

23 Example-Bit string Crossover
Single point crossover Two point Crossover = =

24 Bit string Crossover Uniform crossover : bits are randomly copied from the parents = if random-number > Crossover-rate then Crossover otherwise remain unaltered

25 Mutation Mutation consists of making small alterations to the values of one or more genes in a chromosome Mutation randomly perturbs the population’s characteristics, and prevents evolutionary dead ends Most mutations are damaging rather than beneficial and hence mutation rate must be low to avoid the destruction of species It works by randomly selecting a bit with a certain mutation rate in the string and reversing its value 42 58 Offspring Mutated Offspring

26 Fitness Function A measure of how successful an individual is in the environment Problem dependent Given chromosome, the fitness function returns a number f : S  R Smooth and regular Similar chromosomes produce close fitness values Not have too many local extremes and isolated global extreme

27 Example(1) Finding the maximum of a function: f(x) = x²
Range [0, 31] Goal: find max (31² = 961) Binary representation: string length 5 = 32 numbers (0-31) = f(x)

28 Start Population Typical parameter values population size : 30 -100
crossover rate : mutation rate : 1 00001 String 5 441 21 10101 String 4 100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary

29 Selection Worst one removed 1 00001 String 5 441 21 10101 String 4 100
01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary 6.13% 1.53% 17.04% 75.13% 0.17% Worst one removed

30 Selection Best individual: reproduces twice  keep population size constant 1 00001 String 5 441 21 10101 String 4 100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary

31 Selection All others are reproduced once 441 10101 String 5 21
100 10 01010 String 3 9 3 00011 String 2 36 6 00110 String 1 fitness value binary All others are reproduced once

32 Crossover Parents and x-position randomly selected 1 1 1 1 1 1 1 1 1 1
2 String 4 String 3 4 String 2 String 1 x-position partner Parents and x-position randomly selected 1 1 1 1 1 6 7 String 1: 1 1 1 String 2: 3 23 1 1 1 1 1 10 21 String 3: 1 1 1 1 1 String 4: 21 17

33 Mutation bit-flip Offspring -String 1: 00111 (7) 10111 (23)

34 New population All individuals in the parent population are replaced by offspring in the new generation (generations are discrete!) New population (Offspring): binary value fitness String 1 00111 7 49 String 2 10111 23 529 String 3 10101 21 441 String 4 10001 17 289 String 5 10101 21 441

35 End Iterate until termination condition reached, e.g.:
Number of generations Best fitness Process time No improvements after a number of generations Result after one generation: Best individual: (23) – fitness 529 Best solution after 100 generation: Best solution: (31) – fitness 961

36 When to Use a 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

37 Summary Introduction to GA Basic GA operations


Download ppt "Genetic algorithms Prof Kang Li"

Similar presentations


Ads by Google