views:

616

answers:

3

Hey guys, I'm a bit confused about how multiple iterations of the tournament selection works.

I know you start selecting random pairs (or k members) and putting the winner into a mating pool. You continue do this till the mating pool is filled.

However, I'm not sure what happens afterwards.

Do we just start randomly mating those in the mating pool? And then restart the selection process by choosing random pairs from the new generation?

Thanks.

+4  A: 

I've written quite a lot of these generic algorithms, to the point I made a framework to avoid writing the same code again and again.

For the mating pool, it depends on the kind of individuals you're looking for, the solutions you're looking for, and if you have a way to combine individuals in a way there's a better chance they'll produce a better individual.

You can use random mating, but this will give you the "worse" solutions -- worse because you have no idea if they will produce a better individual or not. It'll still be good solutions, and when I started writing these algorithms I always used random mating, but immediately after getting a new individual from 2 old ones, I compared the performance of the 3, and discarded the worse, ending up with the 2 parents sometimes (and discarding the 1-second-old child), or ending up with 1 parent and 1 child.

But to be more efficient, AND if you know how to combine individuals so that they will produce a better solution (and this can be very tricky), you can use an affinity function, which takes 2 individuals and returns an affinity between them. The tricky part is to determine the affinity. Depending on the problem, it can be very different. For example, if I take the traveling salesman problem, I got the best solutions when mating individual with less similarity. So my affinity function returned 1 - similarity.

This way, I could reduce the number of iterations by 80% and obtain very good solutions.

But keep in mind that the larger is your pool, the longer will take the affinity function to execute -- affinity functions can be O(n²), or even O(n³), in which cases it can be the bottleneck of your algorithm. In this case, it can be better to use random mating.

In conclusion, random mating is good -- after all, we can say it works this way in real life -- but if you know how to compute an affinity between 2 individuals, you can use it to reduce the number of iterations you'll need to obtain a good solution. Keep in mind that computing affinity can be very complex (and I even guess that computing the best affinities for a given pool is NP-Complete).

FWH
+1 for making a framework. I made one myself in college when I was in love with GA and wrote a lot of algorithms. Unfortunately I didn't have the time to continue it after college. :(
Paulo Guedes
A: 

This is not good advice but...

However, I'm not sure what happens afterwards.

Do whatever you want. You could mutate them all...or you can mate each pair that you pick in the tournament. Use whichever works best. Be creative.

As someone else on this forum has pointed out: The dirty little secret about GAs is that it's more art than science.

Also, to get truly good advice, you'll need a better description of the problem you want to solve.

Ray
+1  A: 

Traditionally after the tournament winners are found they form the next generation. All the processes of mutation, selection etc continue after this in cycles.

zenna