150 likes | 231 Views
Genetic Algorithms. The Basic Genetic Algorithm. [Start] Generate random population of n chromosomes (suitable solutions for the problem) [Fitness] Evaluate the fitness f(x) of each chromosome x in the population
E N D
The Basic Genetic Algorithm • [Start] Generate random population of n chromosomes (suitable solutions for the problem) • [Fitness] Evaluate the fitness f(x) of each chromosome x in the population • [New population] Create a new population by repeating following steps until the new population is complete • [Selection] Select two parent chromosomes from a population according to their fitness (the better fitness, the bigger chance to be selected) • [Crossover] With a crossover probability cross over the parents to form new offspring (children). If no crossover was performed, offspring is the exact copy of parents. • [Mutation] With a mutation probability mutate new offspring at each locus (position in chromosome). • [Accepting] Place new offspring in the new population • [Replace] Use new generated population for a further run of the algorithm • [Test] If the end condition is satisfied, stop, and return the best solution in current population • [Loop] Go to step 2
Basicprinciples 1 • Coding or Representation • String with all parameters • Fitness function • Parent selection • Reproduction • Crossover • Mutation • Convergence • When to stop
Basicprinciples 2 • An individual is characterized by a set of parameters: Genes • The genes are joined into a string: Chromosome • The chromosome forms the genotype • The genotype contains all information to construct an organism: the phenotype • Reproduction is a “dumb” process on the chromosome of the genotype • Fitness is measured in the real world (‘struggle for life’) of the phenotype
Initialize Population Evaluate Fitness Yes satisfy constraints ? No Randomly Vary Individuals Select Survivors Output Results Conceptual Algorithm
Genetic Algorithm • Encoding • Fitness Evaluation • Reproduction • Survivor Selection
Reproduction • Crossover • Two parents produce two offspring • There is a chance that the chromosomes of the two parents are copied unmodified as offspring • There is a chance that the chromosomes of the two parents are randomly recombined (crossover) to form offspring • Generally the chance of crossover is between 0.6 and 1.0 • Mutation • There is a chance that a gene of a child is changed randomly • Generally the chance of mutation is low (e.g. 0.001)
One-point crossover • Randomly one position in the chromosomes is chosen • Child 1 is head of chromosome of parent 1 with tail of chromosome of parent 2 • Child 2 is head of 2 with tail of 1 Randomly chosen position Parents: 10100011100011010010 Offspring: 01010100100011001110
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)
Mutation • Alter each gene independently with a probability pm • pm is called the mutation rate • Typically between 1/pop_size and 1/ chromosome_length
Algorithm BEGIN Generate initial population; Compute fitness of each individual; REPEAT /* New generation /* FOR population_size / DO Select two parents from old generation; /* biased to the fitter ones */ Recombine parents for two offspring; Compute fitness of offspring; Insert offspring in new generation END FOR UNTIL population has converged END
Parent/Survivor Selection • Strategies:Survivor selection • Always keep the best one • Elitist: deletion of the K worst
After many random crossover-combination, we get the following generation: In a long terme process only sohn three will survive. Sohn 1 and 2 will be eliminate from the existence because of the nature conditions(fitness function)
Conclusion • The genetic algorithms are very good techniques however the main obstacle is to encode problem, to define a good fitness function! • Demo TSM • AISteroid