Presentation is loading. Please wait.

Presentation is loading. Please wait.

Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination.

Similar presentations


Presentation on theme: "Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination."— Presentation transcript:

1 Genetic Algorithms 虞台文

2 Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination – Mutation – Population – Selection Models

3 Genetic Algorithms Evolutional Algorithms

4 Biological Evolution

5 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

6 Darwinian Evolution 1: Survival of the Fittest 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 1809-1882

7 Darwinian Evolution 2: Diversity Drives Change Phenotypic traits: – 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 … 1809-1882

8 Darwinian Evolution:Summary 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 1809-1882

9 Population General Scheme of Evolutional Algorithms (EAs) Parents Offspring Initialization Termination Parent Selection Survivor Selection Recombination Mutation

10 Population General Scheme of Evolutional Algorithms (EAs) Parents Offspring Initialization Termination Parent Selection Survivor Selection Recombination Mutation 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? 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?

11 Population General Scheme of Evolutional Algorithms (EAs) Parents Offspring Initialization Termination Parent Selection Survivor Selection Recombination Mutation Better individuals get higher probability to become the parents of the next generation. Variation operators

12 Population General Scheme of Evolutional Algorithms (EAs) Parents Offspring Initialization Termination Parent Selection Survivor Selection Recombination Mutation Replace some old individuals with newly born ones.

13 Pseudo-Code for Typical EA

14 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

15 Components of EAs Representation  definition of individuals Evaluation function  fitness function Population Parent selection mechanism Variation operators – Recombination – Mutation Survivor selection mechanism  replacement Termination

16 Different Types of EAs Historically, different flavours of EAs have been associated with different representations – Binary strings : Genetic Algorithms – Real-valued vectors : Evolution Strategies – Finite state Machines: Evolutionary Programming – LISP trees: Genetic Programming

17 Different Types of EAs Historically, different flavours of EAs have been associated with different representations 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 Genetic Algorithms Evolution Strategies

18 Different Types of EAs Historically, different flavours of EAs have been associated with different representations 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 Evolutionary Programming Genetic Programming

19 Genetic Algorithms

20 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 retains the robustness of natural systems

21 Genetic Algorithms Holland’s original GA is now known as the simple genetic algorithm (SGA) Other GAs use different: – Representations – Mutations – Crossovers – Selection mechanisms

22 SGA Technical Summary Tableau Representation Binary strings Recombination N-point or uniform Mutation Bitwise bit-flipping with fixed probability Parent selection Fitness-Proportionate Survivor selection All children replace parents Speciality Emphasis on crossover

23 Representation Genotype space Phenotype space Encoding (representation) Decoding (inverse representation) 011101001 010001001 10010010 10010001

24 SGA Evolution Cycle 1.Select parents for the mating pool (size of mating pool = population size) 2.Shuffle the mating pool 3.For each consecutive pair apply crossover with probability p c, otherwise copy parents 4.For each offspring apply mutation (bit-flip with probability p m independently for each bit) 5.Replace the whole population with the resulting offspring 1.Select parents for the mating pool (size of mating pool = population size) 2.Shuffle the mating pool 3.For each consecutive pair apply crossover with probability p c, otherwise copy parents 4.For each offspring apply mutation (bit-flip with probability p m independently for each bit) 5.Replace the whole population with the resulting offspring

25 SGA Operators: 1-Point Crossover Choose a random point on the two parents Split parents at this crossover point Create children by exchanging tails p c typically in range (0.6, 0.9)

26 SGA Operators: Mutation Alter each gene independently with a probability p m p m is called the mutation rate – Typically between 1/pop_size and 1/chromosome_length

27 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 fitness(A) = 3 fitness(B) = 1 fitness(C) = 2

28 An Example after Goldberg ‘89 Simple problem: max x 2 over {0,1,…,31} GA approach: – Representation: binary code, e.g. 01101  13 – Population size: 4 – 1-point xover, bitwise mutation – Roulette wheel selection – Random initialization

29 x 2 Example: Initial Population

30 x 2 Example: Selection 0 1 1 0 1 1 1 0 0 0 1 0 0 1 1

31 x 2 Example: Selection

32 x 2 Example: Crossover

33 x 2 Example: Mutation

34 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 = (x 1, x 2, …, x n ), with x i  {0, 1}, that maximizes the following equation:

35 Genetic Algorithms Main Components of GA’s

36 Nature-to-Computer Mapping NatureComputer IndividualSolution to a problem PopulationSet of solutions FitnessQuality of a solution ChromosomeEncoding for a solution GenePart of the encoding of a solution CrossoverSearch Operator (Local) MutationSearch Operator (Global) Nature SelectionReuse of good (sub-)solutions

37 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

38 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 mechanism depends on the nature of the problem variables.

39 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 complicated values Tree Encoding – used mainly for evolving programs or expressions, e.g., genetic programming

40 Binary Encoding Permutation Encoding Direct Value Encoding Tree 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. 11111110000000011111Chromosome B 10110010110011100101Chromosome A

41 Permutation Encoding Binary Encoding Permutation Encoding Direct Value Encoding Tree 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. 8 5 6 7 2 3 1 4 9Chromosome B 1 5 3 2 6 4 7 9 8Chromosome A

42 Direct Value Encoding Binary Encoding Permutation Encoding Direct Value Encoding Tree 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.454Chromosome A

43 Tree Encoding Binary Encoding Permutation Encoding Direct Value 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.

44 More on Binary Encoding  Gray coding of integers IntegerBinaryGray 0000 1001 2010011 3 010 4100110 5101111 6110101 7111100

45 More on Binary Encoding  Gray coding of integers Gray coding is 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 as integers and floating point variables

46 More on Binary Encoding  Interval Representation z  [x, y]   represented by {a 1,…,a L }  {0,1} L [x, y]  {0,1} L must be invertible  : {0,1} L  [x, y] defines the representation

47 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.

48 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.

49 Crossover Operators Binary Encoding – 1-Point Crossover – 2-Point Crossover – N-Point Crossover – Uniform Crossover Permutation Encoding

50 Binary Encoding  1-Point Crossover Chromosome111011 | 00100110110 Chromosome 211011 | 11000011110 Offspring 111011 | 11000011110 Offspring 211011 | 00100110110

51 Binary Encoding  2-Point Crossover Chromosome111011 | 00100 | 110110 Chromosome 210101 | 11000 | 011110 Offspring 110101 | 00100 | 011110 Offspring 211011 | 11000 | 110110

52 Binary Encoding  N-Point Crossover Choose N random crossover points Split along those points Glue parts, alternating between parents

53 Binary Encoding  Uniform Crossover Each gene (bit) is selected randomly from one of the corresponding genes of the parent chromosomes. Chromosome1 11000101 01011000 01101010 Chromosome 2 00100100 10111001 01111000 Offspring 1 01000101 01111000 01111010 Offspring 2 10100100 10011001 01101000

54 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

55 Permutation Encoding  Order Crossover (OX) 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    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

56 Permutation Encoding  Order Crossover (OX) 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    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 21893

57 Permutation Encoding  Order Crossover (OX) 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    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 21893 Chromosome1 1 2 3 4 5 6 7 8 9 Chromosome 2 4 5 2 1 8 7 6 9 3 Offspring 1 3 4 5 1 8 7 6 9 2 Offspring 2 2 1 8 4 5 6 7 9 3

58 Permutation Encoding  Partially Mapped Crossover (PMX) 123456789937826514

59 123456789 937826514 4567938216547 Step 1

60 Permutation Encoding  Partially Mapped Crossover (PMX) 4567938216547 Step 2 4567 931

61 Permutation Encoding  Partially Mapped Crossover (PMX) 4567938216547 Step 3 4567 93182

62 Permutation Encoding  Partially Mapped Crossover (PMX) 4567931821234567899378265141234567898265 Step 1

63 Permutation Encoding  Partially Mapped Crossover (PMX) 4567931821234567898265 Step 2 8265 139

64 Permutation Encoding  Partially Mapped Crossover (PMX) 4567931821234567898265 Step 3 8265 139 4 7

65 Permutation Encoding  Partially Mapped Crossover (PMX) 456793182 8265 139 4 7 Chromosome1 1 2 3 4 5 6 7 8 9 Chromosome 2 9 3 7 8 2 6 5 1 49 3 7 8 2 6 5 1 4 Offspring 1 9 3 2 4 5 6 7 1 8 Offspring 2 1 7 3 8 2 6 5 4 9

66 Permutation Encoding  Cycle Crossover 456791283 8265 974 1 3

67 456791283 8265 974 1 3 Step 1: identify cycles 4918 8 94 1

68 Permutation Encoding  Cycle Crossover 456791283 8265 974 1 3 Step 1: identify cycles 4918 8 94 1 5723 25 73

69 Permutation Encoding  Cycle Crossover 456791283 8265 974 1 3 Step 1: identify cycles 4918 8 94 1 5723 25 73 6 6

70 Permutation Encoding  Cycle Crossover 456791283 8265 974 1 3 Step 1: identify cycles 4918 8 94 1 5723 25 73 6 6 Step 2: copy alternate cycles into offspring 4918 8 9 4 1 5723 25736 6

71 Permutation Encoding  Edge Recombination 456791283 8265 974 1 3 Step 1: Construct edge table 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348

72 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348 Step 2: Randomly choose start node

73 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Step 2: Randomly choose start node Step 3: Remove visited nodes

74 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random

75 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5

76 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done

77 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348

78 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6

79 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6

80 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 62

81 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 62

82 24591 2 3 4 5 6 7 8 9 13682479135914+62+5736+82+791348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 628

83 2459 1 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 628

84 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6287

85 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6287

86 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 62873

87 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 24591 2 3 4 5 6 7 8 9 1368 2479 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 62873

88 247924591 2 3 4 5 6 7 8 9 1368135914+62+5736+82+791348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 628739

89 2479 24591 2 3 4 5 6 7 8 9 1368 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 628739 2479 24591 2 3 4 5 6 7 8 9 1368 1359 14+6 2+57 36+8 2+79 1348

90 2479 24591 2 3 4 5 6 7 8 9 1368 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6287394

91 2479 24591 2 3 4 5 6 7 8 9 1368 1359 14+6 2+57 36+8 2+79 1348 Permutation Encoding  Edge Recombination 1 Step 1: Construct edge table Step 2: Randomly choose start node Step 3: Remove visited nodes Step 4: Pick common edge if existent Pick one with the shortest list Ties are split at random 5 Step 5: Loop to Step 3 until done 6287394 2479 24591 2 3 4 5 6 7 8 9 1368 1359 14+6 2+57 36+8 2+79 1348

92 Crossover for Real Valued GAs Discrete: – Each allele value in offspring z comes from one of its parents (x, y) with equal probability: z i = x i or y i – Could use n-point or uniform Intermediate – exploits idea of creating children “between” parents (hence a.k.a. arithmetic recombination) – z i =  x i + (1   ) y i where  : 0    1. – The parameter  can be: constant: uniform arithmetical crossover variable (e.g. depend on the age of the population) picked at random every time

93 Single Arithmetic Crossover Parents:  x 1,…, x n  and  y 1,…, y n  Pick a single gene (k) at random child 1 is: reverse for other child. e.g. with  = 0.5

94 Simple Arithmetic Crossover Parents:  x 1,…, x n  and  y 1,…, y n  Pick random gene (k) after this point mix values child 1 is: reverse for other child. e.g. with  = 0.5

95 Whole Arithmetic Crossover Parents:  x 1,…, x n  and  y 1,…, y n  child 1 is: reverse for other child. e.g. with  = 0.5

96 More on Crossover Crossover between 2 good solutions MAY NOT ALWAYS yield a better or as good a solution. Since parents are good, probability of the child being good is high. If offspring is not good (poor solution), it will be removed in the next iteration during “Selection”.

97 Crossover or Mutation Decade long debate: Which one is better / necessary / main-background? Answer (at least, rather wide agreement): – it depends on the problem, but – in general, it is good to have both – both have another role – mutation-only-EA is possible, xover-only-EA would not work in general

98 Crossover or Mutation Exploration: – Discovering promising areas in the search space, i.e. gaining information on the problem – Crossover is “usually” explorative, it makes a big jump to an area somewhere “in between” two (parent) areas Exploitation: – Optimizing within a promising area, i.e. using information – Mutation is “usually” exploitative, it creates random small diversions, thereby staying near (in the area of ) the parent

99 Crossover or Mutation Crossover can combine information from two parents Mutation can introduce new information (alleles) Crossover does not change the allele frequencies of the population To hit the optimum you often need a ‘lucky’ mutation

100 Mutation Operators Binary Encoding Value Encoding – Integers – Floating points Permutation Encoding

101 Mutation Operator for Binary Encoding For chromosomes using Binary Encoding, randomly selected bits are inverted. Offspring 11011 00100 110110 Mutated Offspring 11010 00100 100110 NOTE: The number of bits to be inverted depends on the Mutation Probability.

102 Mutation Operator for Value Encoding Creep  – Adding small offset to randomly chosen allele(s) Random choice  – Assign random value to randomly chosen allele(s) Offspring 9 15 7 0 32 50 70 Mutated Offspring 9 17 7 0 80 50 70

103 Mutation Operators for Permutation Encoding Insert Mutation Swap Mutation Inversion mutation

104 Elitism When creating a new population by crossover or mutation the best chromosome might be lost. Forces GAs to retain some number of the best individuals at each generation. Has been found that elitism significantly improves performance. Elitism is a method which copies the best chromosome to the new offspring population before crossover and mutation.

105 Population Models SGA uses a Generational model: – each individual survives for exactly one generation – the entire set of parents is replaced by the offspring At the other end of the scale are Steady-State models: – one offspring is generated per generation, – one member of population replaced, Generation Gap – the proportion of the population replaced – 1.0 for GGA, 1/pop_size for SSGA

106 Fitness Function A fitness function quantifies the optimality of a solution (chromosome) so that that particular solution may be ranked against all the other solutions. A fitness value is assigned to each solution depending on how close it actually is to solving the problem. Ideal fitness function correlates closely to goal + quickly computable. Example: In TSP, f(x) is sum of distances between the cities in solution. The lesser the value, the fitter the solution is.

107 Selection Models Selection can occur in two places: – Parent selection  Selection from current generation to take part in mating – Survivor selection  Selection from parents + offspring to go into next generation Distinction between selection – operators: define selection probabilities – algorithms: define how probabilities are implemented

108 Parent Selection Fitness-Proportionate Selection – Roulette wheel algorithm – Baker’s SUS algorithm: Rank-Based Selection – Linear Ranking – Exponential Ranking Tournament Selection

109 Fitness-Proportionate Selection Roulette wheel algorithm: – Given a probability distribution, spin a 1-armed wheel n times to make n selections Baker’s SUS algorithm: – Stochastic Universal Sampling – n evenly spaced arms on wheel and spin once

110 Fitness-Proportionate Selection Problems – One highly fit member can rapidly take over if rest of population is much less fit: Premature Convergence – At end of runs when fitnesses are similar, lose selection pressure – Highly susceptible to function transposition Scaling can fix last two problems – Windowing: f’(i) = f(i) -  t where  is worst fitness in this (last n) generations – Sigma Scaling: f’(i) = max[ f(i) – (  f  - c  f ), 0.0] where c is a constant, usually 2.0

111 Function Transposition for FPS

112 Rank-Based Selection Attempt to remove problems of FPS by basing selection probabilities on relative rather than absolute fitness Rank population according to fitness and then base selection probabilities on rank where fittest has rank  and worst rank 1

113 Rank-Based Selection Linear Ranking Exponential Ranking

114 Tournament Selection

115 All methods above rely on global population statistics – Could be a bottleneck esp. on parallel machines – Relies on presence of external fitness function which might not exist: e.g., evolving game players Informal Procedure: – Pick k members at random then select the best of these – Repeat to select more individuals – k = 2: binary tournament selection

116 Tournament Selection

117 Some Demonstrations http://cs.felk.cvut.cz/~xobitko/ga/ http://www.heatonresearch.com/articles/65/page1.html http://homepage.sunrise.ch/homepage/pglaus/gentore.htm#Applet http://www.ads.tuwien.ac.at/raidl/tspga/TSPGA.html http://www.see.ed.ac.uk/~rjt/ga.html?http://oldeee.see.ed.ac.uk/~rjt/ga. html http://www.see.ed.ac.uk/~rjt/ga.html?http://oldeee.see.ed.ac.uk/~rjt/ga. html

118 References A Survey of Genetic Algorithm Genetic Algorithms: A Survey A Genetic Algorithm Tutorial


Download ppt "Genetic Algorithms 虞台文. Content Evolutional Algorithms Genetic Algorithms Main Components of Genetic Algorithms – Encoding – Fitness Function – Recombination."

Similar presentations


Ads by Google