ch.12 machine learning genetic algorithm dr. bernard chen ph.d. university of central arkansas...

15
Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Upload: merry-sparks

Post on 31-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Ch.12 Machine Learning Genetic Algorithm

Dr. Bernard Chen Ph.D.University of Central Arkansas

Spring 2011

Page 2: 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

Page 3: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Genetic Algorithm

Page 4: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Genetic Algorithm

Basic functions of Genetic Algorithm (GA) Crossover Mutation: takes a single candidate

and randomly changes some aspect of it

Inversion

Page 5: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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

Page 6: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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)

Page 7: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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

Page 8: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Genetic Algorithm

Now, the problem is how to crossover?

P1= (192465783) P2= (459187623)

Page 9: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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)

Page 10: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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)

Page 11: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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

Page 12: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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)

Page 13: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Genetic Algorithm

So, what is C2?

Page 14: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

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

Page 15: Ch.12 Machine Learning Genetic Algorithm Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2011

Genetic Algorithm

Inversion: Just reverse the order