240 likes | 326 Vues
This comprehensive guide explores the basic ideas, representation methods, mutation techniques, fitness evaluation, and evolution process of Genetic Algorithms (GAs). Learn how GAs can solve complex problems like the knapsack example and understand the crucial components of GAs through practical examples and demonstrations.
E N D
CS26110AI Toolbox Evolutionary and Genetic Algorithms 2
GA Megaman controller • http://www.youtube.com/watch?v=c7xJNAJys2s • Procedural animation via GAs • http://www.youtube.com/watch?v=_v9_hTSOHN4 • Starcraft 2 build orders • http://lbrandy.com/blog/2010/11/using-genetic-algorithms-to-find-starcraft-2-build-orders/ • Evolving locomotion • http://www.youtube.com/watch?v=STkfUZtR-Vs
Basic ideas of EAs • An EA is an iterative procedure which evolves a population of individuals • Each individual is a candidate solution to a given problem • Each individual is evaluated by a fitness function, which measures the quality of its candidate solution • At each iteration (generation): • The best individuals are selected • Genetic operators are applied to selected individuals in order to produce new individuals (offspring) • New individuals are evaluated by fitness function
Representation CHROMOSOME GENE 0.12 1 A 0.33 0 C B 1 5.2 0 -1.2 C W 3.0 0 1.18 0 W 1 20.4 Q S 1 5.2
Task • The knapsack problem is as follows: • given a set of weights W, and a target weight T, find a subset of W whose sum is as close to T as possible • Example: W = {5, 8, 10, 23, 27, 31, 37, 41} and T = 82 • 1. Solve the instance of the knapsack problem given above • 2. How can a solution be encoded as a (binary) chromosome?
Task • 1. Solve the instance of the knapsack problem given above... • 82 = 41+31+10 is one solution, there may be others • 2. How can a solution be encoded as a (binary) chromosome? • Each bit i in a chromosome encodes whether weight w[i] is present or not • Solution above: {5, 8, 10, 23, 27, 31, 37, 41} [0, 0, 1, 0, 0, 1, 0, 1]
The GA cycle chosen parents recombination children selection modification modified children parents evaluation population evaluated children deleted members discard
Mutation: local modification • Causes movement in the search space • Restores lost information to the population Before: (1 0 1 1 0 1 1 0) After: (1 0 1 0 0 1 1 0) Before: (1.38 -69.4 326.44 0.1) After: (1.38 -67.5 326.44 0.1)
Mutation • Given the representation for TSPs, how could we achieve mutation?
Mutation For TSPs, involves reordering of the list: ** Before: (5 8 7 2 1 6 3 4) After: (5 8 6 2 1 7 3 4)
Note • Both mutation and crossover are applied based on user-supplied probabilities • We usually use a fairly high crossover rate and fairly low mutation rate • Why do you think this is?
Evaluation of fitness • The evaluator decodes a chromosome and assigns it a fitness measure • The evaluator is the only link between a classical GA and the problem it is solving modified children evaluation evaluated children
Fitness functions • Evaluate the ‘goodness’ of chromosomes • (How well they solve the problem) • Critical to the success of the GA • Often difficult to define well • Must be fairly fast, as every chromosome must be evaluated each generation (iteration)
Fitness functions • Fitness function for the TSP? • (3 5 7 2 1 6 4 8) • As we’re minimizing the distance travelled, the fitness is the total distance travelled in the journey defined by the chromosome
Fitness functions • The knapsack problem: fitness function? • given a set of weights W, and a target weight T, find a subset of W whose sum is as close to T as possible • Example: W = {5, 8, 10, 23, 27, 31, 37, 41} and T = 82
Deletion • Generational GA:entire populations replaced with each iteration • Steady-state GA:a few members replaced each generation population deleted members discard
The GA cycle chosen parents recombination children selection modification modified children parents evaluation population evaluated children deleted members discard
Stopping! • The GA cycle continues until • The system has ‘converged’; or • A specified number of iterations (‘generations’) has been performed
Good demo of the GA components • http://www.obitko.com/tutorials/genetic-algorithms/example-function-minimum.php
An abstract example Distribution of Individuals in Generation 0 Distribution of Individuals in Generation N
Examples • Eaters • http://math.hws.edu/xJava/GA/ • TSP • http://www.heatonresearch.com/articles/65/page1.html • http://www.ads.tuwien.ac.at/raidl/tspga/TSPGA.html • Good demo of the GA components • http://www.obitko.com/tutorials/genetic-algorithms/example-function-minimum.php
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 fitness function (often hardest part)
Benefits of GAs • Concept is easy to understand • Supports multi-objective optimization • Good for “noisy” environments • Always an answer; answer gets better with time • Inherently parallel; easily distributed