420 likes | 558 Views
Biologically Inspired Intelligent Systems. Lecture 13 Dr. Roger S. Gaborski. HW#4 Solution. Some General Ideas. Search Space. Potential solutions to a problem Any point in the search space defines a potential solution ‘Search’ – navigating through the search space
E N D
Biologically Inspired Intelligent Systems Lecture 13 Dr. Roger S. Gaborski Roger S. Gaborski
HW#4 Solution Roger S. Gaborski
Some General Ideas Roger S. Gaborski
Search Space • Potential solutions to a problem • Any point in the search space defines a potential solution • ‘Search’ – navigating through the search space • ‘Evolutionary Search’ is inspired by nature Roger S. Gaborski
Populations • Evolutionary algorithms consider a large number, or population, of potential solutions at once • Use the whole population, or a subset of the population, to help navigate through the search space in search of the ‘optimal’ solution • Making use of previously evaluated solutions Roger S. Gaborski
Populations • Perform search by evolving solutions • Maintain a population of potential solutions • Breed better solutions in the population • Keep ‘children’ that are created • Remove poorer performing solutions • Evolve solutions for a given number of generations or until an acceptable solution is found Roger S. Gaborski
Optimization Exploration and Exploitation • Optimization • Knowledge-rich encoding of problem • Solution is parameterized in minimum number of parameters • Evolution is used to find the best parameters Roger S. Gaborski
Optimization – find maximum of a function cos(0.1*(x*x + y*y)) f(x,y) =1.2 + 1+ .01*(x*x + y*y) Roger S. Gaborski
Multimodal 2D Function Roger S. Gaborski
Multimodal 2D Function(shown in color) Roger S. Gaborski
Problem • Given 2D function • We would like to find the (x,y) pair that corresponds to the maximum of the function Roger S. Gaborski
Initial Population Create a population of 100 random potential solutions Measure fitness of each potential solution True maximum is F(0,0) = 2.2 Best solution found in random population F(-.8318, -.2905) = 2.1893 For this function there are many solutions near the maximum Roger S. Gaborski
Fitness Value of random Population Roger S. Gaborski
Approach • Similar to string problem • Select best candidate from population • Create new population by modifying x and y coordinates of best candidate • Modify coordinates by adding a small random numbers to the x and y coordinate • Include original ‘best candidate’ in new population • Select best candidate from new population • Continue until optimal solution found Roger S. Gaborski
Initial Fitness: 1.7992Coordinates: 4.1685, 6.8659 bestCoord = 0.0476 0.0524 Roger S. Gaborski
HW#5 Due Tuesday • ES(µ,λ) and ES(µ+λ) algorithms Roger S. Gaborski
HW#6:Optimization for given NN Architecture – Due Thursday • Given XOR Architecture from HW#4 • Find weight matrix using ES algorithm • Run program 10 times • Was the program successful? • Was more than one correct weight matrix found? • Email code and write up to course account Roger S. Gaborski
Genetic Algorithms • Holland – explained adaptive processes of natural systems and design artificial systems based on natural systems • Most widely used evolutionary algorithm • GAs use two spaces: • Search space: space of coded solutions • Coded solutions genotypes • Solution space; space of actual solutions • Actual solutions phenotypes • Fitness is evaluated on phenotype solutions Roger S. Gaborski
Genetic Algorithms • Maintain of population of individuals • Each individual consists of genotype and its phenotype • Genotypes are coded versions of parameters • A coded parameter is a gene • Collect of genes in one genotype is a chromosome • Phenotypes are the actual set of parameters Roger S. Gaborski
Genetic Algorithms • GAs do not use the representation of the parameter space directly • The population consists of individuals commonly referred to as chromosomes • The genotypes are represented as binary strings • Genetic operators are applied to the binary strings • The most common operator is crossover Roger S. Gaborski
Search Space and Solution Space Search Space Solution Space 11100110 GENOTYPES 11100000 11011000 14x+6y PHENOTYPES 14x+4y 13x-8y NOTE: Only the numerical values are determined by the genotype (ai,bi) ai x + bi y Evaluate Fitness of Each Solution Roger S. Gaborski
Terminology • Interpretation and Evaluation • Selection and Reproduction • Variation • Reproduction Roger S. Gaborski
Terminology • Interpretation and Evaluation • Decode binary strings into decimal values, such as, the x and y coordinates • Coordinates are evaluated using the objective function Roger S. Gaborski
Terminology • Interpretation and Evaluation • Selection and Reproduction • Select two individuals from the current population • Many methods are available to implement the selection step of the algorithm Roger S. Gaborski
Terminology • Variation • Two selected bit strings are modified by a crossover and mutation operator • Crossover – randomly select a position in the binary string. Create first child by recombining the first section from parent 1 with the second section from string 2 • The second child is forms by combining the second section of parent 1 with the first section of parent 2 • Mutation is implemented by simply selecting a bit and flipping its value, 01, 10 • Application of the operators is determined by a probability • Both classes of operators are biologically inspired Roger S. Gaborski
Basic GA Operators • Crossover: After selecting two chromosomes from the population, Parent1: ABCDEFG and Parent2: abcdefg Select a random position (for example, 4), split the two chromosomes at this point, interchange substrings and recombine ABCDEFG and abcdefg child1: ABCDefg child2: abcdEFG Roger S. Gaborski
Basic GA Operators • Mutation: Randomly change the value of one element of the chromosome ABCDefg ABKDefg Roger S. Gaborski
Simple Crossover and Mutation Example Crossover: Parent1: 011011101011 Parent2: 100110110101 Choose crossover point as position 3 Parent1: 011011101011 Parent2: 100110110101 Child1: 011110110101 Child2: 100011101011 Mutation (randomly choose position 8): Child1: 011110110101 011110100101 Roger S. Gaborski
New Population • There are several popular methods to create the new population • One approach is to simply replace the two parents with the two children • Another approach is to evaluate both children and only replace the parents if the children are more fit • Yet another approach is to replace the least fit individuals in the population with the children and also retain the original parents in the population Roger S. Gaborski
Genetic Algorithms • The two parameter problem can be represented by two segments of binary strings of equal length • For example, [0100100110] • The first 5 bits represent the x coordinate • The last 5 bits represent the y coordinate • Must be mapped to phenotypical representation of real numbers Roger S. Gaborski
Decoding Function • For the 2D example we restrict [ xmin , xmax] = [ ymin , ymax] = [-10,10] x coordinate: Xmin +[ (xmax - xmin)/ (2kx-1) ] * [ binary to decimal] kx is the number of bits representing the x coordinate -10 +[ (10-(-10))/(25 –1)] * [ binary to decimal] -10+ [20/31]*[ binary to decimal] Roger S. Gaborski
-10+ [20/31]*[ binary to decimal] 00000 -10+ [20/31]*[ 0] = 0 00001 -10+ [20/31]*[ 1] = -9.3548 00010 -10+ [20/31]*[ 2] = -8.7097 ….. 11111 -10+ [20/31]*[ 31] = +10 Increasing the number of bits representing the coordinate will increase the accuracy For 10 bits: -10 +[ (10-(-10))/(210 –1)]*[ binary to decimal] -10+ [20/1023]*[ binary to decimal] 0000000001 -10+ [20/1023]*[1 ] = -9.9804 0000000010 -10+ [20/1023]*[2 ] = -9.9609 Roger S. Gaborski
Population The initial population consists of randomly generated individuals which are strings 20 binary bits long The first 10 bits represent the x-coordinate, the last 10 bits represent the y-coordinate Calculate corresponding fitness of original population Procedure: Decode first 10 bits to x-coordinate Decode second 10 bits to y-coordinate Calculate fitness of individual At this point, each individual in the population has a fitness associated with it. Roger S. Gaborski
Another Population – each vector is a solution [001000101110101100011101] [111000100110101100011101] [011010101110101100011100] [001000101110101100011101] [011000101101101100011101] [011000101110101000011100] [011111101110101100010100] Roger S. Gaborski
Each vector is 24 binary bits long • Assume each 4 bits represents a decimal number: 0000 = 0 0001 = 1 0010 = 2 … 1111 = 15 Roger S. Gaborski
Chromosome – collection of genes • [0010 0010 1110 1011 0001 1101] • The whole vector is the chromosome • In this example each 4 bit sequence is a gene • This chromosome has 6 genes • In this example the genes represent integer numbers: • [ 2 2 14 11 1 13] Roger S. Gaborski
Simple GA Algorithm Create a random population Evaluate all individuals in population If individual meets fitness requirement, DONE Create a mating pool – chromosomes with higher fitness values have more copies in the mating pool- highly fit individuals have a better chance of reproducing Randomly select two parents from the mating pool With a given probability, apply GA operators (crossover and mutation) Depending on the probability crossover or mutation operators may not be applied Place children into population Continue until all chromosomes in population are children (Completion of generation) Roger S. Gaborski
Remarks • GA search is not random, but is a directed search • In the simple GA, the number of times a copy of a parent is placed in the mating pool depends on that parent’s fitness function • The simple GA is just that, simple • Literature contains examples of more advanced GAs Roger S. Gaborski
Genetic Programming • Example from: Creative Evolutionary Systems (Bentley and Corne) • The chromosome represents a ‘program’ • Programs are represented by a tree like structure • Genetic Programs evolves a hierarchical tree structure that can be interpreted as a computer program Roger S. Gaborski
Robot Controller Program Repeat 3 times [move 3 steps forward move 2 steps right repeat 2 times [move back 1 step ] ] Repeat 3 List Forward Right Repeat Back 3 2 2 1 Roger S. Gaborski
Crossover Parent 1 Parent 2 Child 1 Child 2 Roger S. Gaborski
How Do We Direct Evolution • How do we know if the solution provided by a ‘child’ is better? • Need to define a ‘distance measure’ • How ‘close’ are we to the optimal solution Roger S. Gaborski