350 likes | 364 Views
Learn about Genetic Algorithms, a class of algorithms inspired by evolution, designed for complex problems. Developed by John Holland, these algorithms involve generating initial populations, selection, recombination, and mutation to evolve towards optimal solutions. Discover the principles of evolution, fitness evaluation, genome encoding, and fitness functions.
E N D
Genetic Algorithms What are Genetic Algorithms? • Bio-Inspired artificial intelligence class of probabilistic optimization algorithms • Well-suited for nonlinear/hard problems with a large search space • Developed by John Holland • Influenced by Darwin’s Origin of species
Evolution Darwin’s principles • Variety of species individuals within the population • Competition for limited resources • Overproduction of offspring generation • Survival of the fittest Origin of Species, 1859
Evolution How does it work? • Initial population • Variety of shapes, colors, behaviors • Each individual fits differently to the environment
Evolution How does it work? • Initial population • Reproduction • Offspring combines both parents properties • Siblings may differ in properties • Mutations may occur
Evolution How does it work? • Initial population • Reproduction • Limited environmental resources • Only a portion of the individuals survive • Survival chances –according to fitnessmeasure... • ... usually.
Evolution Observations • Changes in the population content • “good” properties are kept, “bad” are distinct • evolutionary pressure
Genetic Algorithms The computational model produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms The computational model produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms The computational model Gn Gn+1 fitness crossover 55 + 44 = 12 31 95 32 87 12 0 65 mutation 53 2 91 73
GA in action The Knapsack problem (NP) • There are N items: • Each item i has a weight wi • Each item i has a value vi • The knapsack has a limited capacity of W units. • The problem description: • Maximize • While
GA in action The Knapsack problem (NP) • For example: • Knapsack capacity = 100
GA in action Before we begin… • Define the genome encoding • Define the fitness function
GA in action Genome Encoding Bit array: 0 = don’t take the item 1 = take the item (items taken: A, B, E)
GA in action Genome Encoding Bit array: 0 = don’t take the item 1 = take the item (items taken: A, B, C, D, E, F, G, I)
GA in action Fitness Function
GA in action Fitness Function
Genetic Algorithms Fitness Evaluation produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Fitness Evaluation For each individual, calculate the fitness value:
Genetic Algorithms Selection produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Selection • Fitness-proportionate (roulette wheel) • Rank Selection (scaling) • Tournament Selection • …
Genetic Algorithms Crossover produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Crossover Using a crossover probability PC per individual: • Single point crossover • Two/multi points crossover • Uniform / weighted crossover • …
Genetic Algorithms Mutation produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Mutation Using a crossover probability PM per bit: • Bit flip mutation • Bit switch mutation • …
Genetic Algorithms Crossover & Mutation examples
Genetic Algorithms Initial Population produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Initial Population Create a fixed size population using: • Random generated individuals • Individuals resulted from previous evolutionary runs
GA in action Initial Population Example of random population:
Genetic Algorithms Termination Condition produce an initial population of individuals while (termination condition not met) do evaluate the fitness of all individuals select fitter individuals for reproduction recombine between individuals mutate individuals
Genetic Algorithms Termination Condition • When an optimal solution is found • When the results converge to constant value • After a predetermined number of generations
Genetic Algorithms Sample Evolutionary Run • Population size: 100 individuals • Crossover: Single pt., PC=0.9 • Mutation: Bit flip, PM=0.01 • Selection: tournament, groups of 2 • Termination condition: after 100 generations
Genetic Algorithms Sample Evolutionary Run
Genetic Algorithms Conclusions • GA is nondeterministic – two runs may end with different results • There’s no indication whether best individual is optimal • Fitness tends to converge during time
Genetic Algorithms GA variations • Coevolution • Cooperative • Competitive • Parallel GA • Hybrid GA