180 likes | 594 Views
Ch.12 Machine Learning Genetic Algorithm. Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011. Genetic Algorithm (GA). GA view learning as a competition among a population of evolving candidate problem solutions.
E N D
Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011
Genetic Algorithm (GA) • GA view learning as a competition among a population of evolving candidate problem solutions. • A “fitness” function evaluates each solution to decide whether it will contribute to the next generation of solutions
Genetic Algorithm • Basic functions of Genetic Algorithm (GA) • Crossover • Mutation: takes a single candidate and randomly changes some aspect of it • Inversion
Genetic Algorithm • Example: Traveling Salesperson problem • The Traveling salesperson problem • Suppose a salesperson has five cities to visit and then must return home • The goal of the problem is to find the shortest path for the salesperson to travel
Genetic Algorithm • Traveling Salesperson Problem (TSP) is classic to AI and computer science • It has been shown to be NP-hard problem • TSP has some very nice applications, including • Circuit board drilling • X-ray crystallography • Routing in VLSI fabrications • Some of these applications required to travel tens of thousands points (cities)
Genetic Algorithm • How might we use genetic algorithm (GA) to solve traveling salesperson problem (TSP)? • First of all, the choice of a representation for the path of cities visited in not trivial • Give each city an numeric name • The design of fitness function is much easier
Genetic Algorithm • Now, the problem is how to crossover? • P1= (192465783) • P2= (459187623)
Genetic Algorithm • First of all, select two cut point, indicate by a “|”, which are randomly inserted into the same location of each parent • P1= (192 | 4657 | 83) • P2= (459 | 1876 | 23)
Genetic Algorithm • Two children C1 and C2 are produced in the following way. • First, the segments between cut points are copied into the offspring: • C1= (XXX | 4657 | XX) • C2= (XXX | 1876 | XX)
Genetic Algorithm • Next, starting from the second cut point of one parent, the cities from the other parent are copied in the same order, omitting cities already present • When the end of the string is reached, continue on from the beginning • Thus, the sequence of cities from P2 (459 | 1876 | 23) is 23 459 1876
Genetic Algorithm • For C1= (XXX | 4657 | XX), once 4657 are removed from the sequence generated by P2, we get the sequence 23918. • Then we just use these numbers to fill in the XXX XX portion in order • Thus, C1=(239 | 4657 | 18)
Genetic Algorithm • So, what is C2?
Genetic Algorithm • Mutation: • A mutation operation could be defined that randomly selected a city and placed it in a new randomly selected location in the path • Randomly selected two cities and swap their location
Genetic Algorithm • Inversion: Just reverse the order