1.18k likes | 1.81k Views
Genetic Algorithms. 虞台文. Content. Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms Encoding Fitness Function Recombination Mutation Population Selection Models. Genetic Algorithms. Evolutional Algorithms. Biological Evolution. Motivated from Nature.
E N D
Content • Evolutional Algorithms • Genetic Algorithms • Main Components of Genetic Algorithms • Encoding • Fitness Function • Recombination • Mutation • Population • Selection Models
Genetic Algorithms Evolutional Algorithms
Motivated from Nature • Nature evolve strikingly complex organisms in response to complex environmental adaptation problems with apparent ease • Localize and extract principles from nature • Apply them to design algorithms
Darwinian Evolution 1: Survival of the Fittest 1809-1882 • All environments have finite resources • can only support a limited number of individuals • Lifeforms have basic instinct/lifecycles geared towards reproduction • Therefore some kind of selection is inevitable • Those individuals that compete for the resources most effectively have increased chance of reproduction • Note: fitness in natural evolution is a derived, secondary measure, i.e., we (humans) assign a high fitness to individuals with many offspring
Darwinian Evolution 2: Diversity Drives Change 1809-1882 • Phenotypictraits: • Behaviour/physical differences that affect response to environment • Partly determined by inheritance, partly by factors during development • Unique to each individual, partly as a result of random changes • If phenotypic traits: • Lead to higher chances of reproduction • Can be inherited then they will tend to increase in subsequent generations and, hence, lead to new combinations of traits …
Darwinian Evolution:Summary 1809-1882 • Population consists of diverse set of individuals • Combinations of traits that are better adapted tend to increase representation in population Individuals are “units of selection” • Variations occur through random changes yielding constant source of diversity, coupled with selection means that: Population is the “unit of evolution” • Note the absence of “guiding force” w/o God
Parent Selection Initialization Recombination Mutation Termination Survivor Selection General Scheme ofEvolutional Algorithms (EAs) Parents Population Offspring
Parent Selection Initialization Recombination Mutation Termination Survivor Selection • A set of individuals corresponding to candidate solutions to a problem. • Each individual has a fitness value. • How to represent the individuals? • How to define the fitness function? General Scheme ofEvolutional Algorithms (EAs) Parents Population Offspring
Parent Selection Initialization Recombination Mutation Termination Survivor Selection Better individuals get higher probability to become the parents of the next generation. General Scheme ofEvolutional Algorithms (EAs) Parents Population Variation operators Offspring
Parent Selection Initialization Recombination Mutation Termination Survivor Selection General Scheme ofEvolutional Algorithms (EAs) Parents Replace some old individuals with newly born ones. Population Offspring
Typical Behavior of an EA Early phase: quasi-random population distribution Mid-phase: population arranged around/on hills Late phase: population concentrated on high hills
Components of EAs • Representation definition of individuals • Evaluation function fitness function • Population • Parent selection mechanism • Variation operators • Recombination • Mutation • Survivor selection mechanism replacement • Termination
Different Types of EAs • Historically, different flavours of EAs have been associated with differentrepresentations • Binary strings : Genetic Algorithms • Real-valued vectors : Evolution Strategies • Finite state Machines: Evolutionary Programming • LISP trees: Genetic Programming
Binary strings : Genetic Algorithms • Real-valued vectors : Evolution Strategies • Finite state Machines: Evolutionary Programming • LISP trees: Genetic Programming Different Types of EAs • Historically, different flavours of EAs have been associated with differentrepresentations Genetic Algorithms Evolution Strategies
Binary strings : Genetic Algorithms • Real-valued vectors : Evolution Strategies • Finite state Machines: Evolutionary Programming • LISP trees: Genetic Programming Different Types of EAs • Historically, different flavours of EAs have been associated with differentrepresentations Evolutionary Programming Genetic Programming
Genetic Algorithms Genetic Algorithms
The Genetic Algorithm • Directed search algorithms based on the mechanics of biological evolution • Developed by John Holland, University of Michigan (1970’s) • To understand the adaptive processes of natural systems • To design artificial systems software that retainsthe robustness of natural systems
Genetic Algorithms • Holland’s original GA is now known as the simple genetic algorithm (SGA) • Other GAs use different: • Representations • Mutations • Crossovers • Selection mechanisms
Encoding (representation) Decoding (inverse representation) Representation Genotype space Phenotype space 10010001 10010010 010001001 011101001
SGA Evolution Cycle • Select parents for the mating pool • (size of mating pool = population size) • Shuffle the mating pool • For each consecutive pair apply crossover with probability pc , otherwise copy parents • For each offspring apply mutation (bit-flip with probability pm independently for each bit) • Replace the whole population with the resulting offspring
SGA Operators: 1-Point 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)
SGA Operators: Mutation • Alter each gene independently with a probability pm • pmis called the mutation rate • Typically between 1/pop_size and1/chromosome_length
fitness(A) = 3 fitness(B) = 1 fitness(C) = 2 SGA Operators: Selection • Main idea: better individuals get higher chance • Chances proportional to fitness • Implementation roulette wheel technique • Assign to each individual a part of the roulette wheel • Spin the wheel n times to select n individuals
Exercise: The OneMax Problem • The OneMax Problem (or BitCounting) is a simple problem consisting in maximizing the number of ones of a bitstring. • Formally, this problem can be described as finding a string x = (x1, x2, …, xn) , with xi{0, 1} , that maximizes the following equation:
Genetic Algorithms Main Components of GA’s
Main Components of GA’s • Encoding principles (gene, chromosome) • Initialization procedure (creation) • Selection of parents (reproduction) • Genetic operators (mutation, recombination) • Fitness function (environment) • Termination condition
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 characteristic of the individual, similarly, each bit in the string represents a characteristic of the solution. • Hence, the encoding mechanismdepends on thenature of theproblem variables.
Commonly Used Encoding Schemes • Binary Encoding • most common and simplest one • Permutation Encoding • used in “ordering problems”, e.g., TSP • Direct Value Encoding • used in problems with complicatedvalues • Tree Encoding • used mainly for evolving programs or expressions, e.g., genetic programming
Chromosome A 10110010110011100101 Chromosome B 11111110000000011111 • Binary Encoding • Permutation Encoding • Direct Value Encoding • Tree Encoding Binary Encoding • Most common method of encoding. • Chromosomes are strings of 1s and 0s and each position in the chromosome represents a particular characteristic of the problem.
Chromosome A 1 5 3 2 6 4 7 9 8 Chromosome B 8 5 6 7 2 3 1 4 9 • Binary Encoding • Permutation Encoding • Direct Value Encoding • Tree Encoding Permutation Encoding • Useful in ordering problems such as the Traveling Salesman Problem (TSP). • Every chromosome is a string of numbers, each of which represents a city to be visited.
Chromosome A 1.235 5.323 0.454 2.321 2.454 Chromosome B (left), (back), (left), (right), (forward) • Binary Encoding • Permutation Encoding • Direct Value Encoding • Tree Encoding Direct 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.
Binary Encoding • Permutation Encoding • Direct Value Encoding • Tree Encoding Tree Encoding • Tree encoding is used mainly for evolving programs or expressions for genetic programming. • In tree encoding every chromosome is a tree of some objects, such as functions or commands in programming language.
More on Binary Encoding Gray coding of integers • Gray codingis a mapping that “attempts” to improve causality, i.e., small changes in the genotype cause small changes in the phenotype, unlike binary coding. • “Smoother” genotype-phenotype mapping makes life easier for the GA. • Nowadays it is generally accepted that it is better to encode numerical variables directly asintegers and floating pointvariables
More on Binary Encoding Interval Representation • z [x, y]represented by {a1,…,aL} {0,1}L • [x, y] {0,1}Lmust be invertible • : {0,1}L [x, y]defines the representation
Crossover • It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics. • Two strings are picked from the mating pool at random to cross over. • The method chosen depends on the Encoding Method.
Crossover • It is the process in which two chromosomes (strings) combine their genetic material (bits) to produce a new offspring which possesses both their characteristics. • Two strings are picked from the mating pool at random to cross over. • The method chosen depends on the Encoding Method.
Crossover Operators • Binary Encoding • 1-Point Crossover • 2-Point Crossover • N-Point Crossover • Uniform Crossover • Permutation Encoding
Binary Encoding N-Point Crossover • Choose N random crossover points • Split along those points • Glue parts, alternating between parents
Binary Encoding Uniform Crossover • Each gene (bit) is selected randomly from one of the corresponding genes of the parent chromosomes.
Permutation Encoding Order Crossover (OX) • Builds offspring by choosing a sub-sequence of a tour from one parent and preserving the relative order of cities from the other parent and feasibility 1 2 3 4 5 6 7 8 9 4 5 2 1 8 7 6 9 3
1 2 3 4 5 6 7 8 9 Permutation Encoding Order Crossover (OX) • Builds offspring by choosing a sub-sequence of a tour from one parent and preserving the relative order of cities from the other parent and feasibility 1 2 3 4 5 6 7 8 9 4 5 2 1 8 7 6 9 3
1 2 3 4 5 6 7 8 9 Permutation Encoding Order Crossover (OX) • Builds offspring by choosing a sub-sequence of a tour from one parent and preserving the relative order of cities from the other parent and feasibility 1 2 3 4 5 6 7 8 9 2 1 8 9 3 4 5 2 1 8 7 6 9 3