Exploring Genetic Algorithms
November 15th, 2008
Over a year ago, I attended a code camp session down in MPLS on Genetic Algorithms. Being a BCIS student, I unfortunately never explored this in college. The mixing of biological concepts and programming is extremely fascinating to me. Before I start reading about it in great detail I wanted to get my hands somewhat dirty in hopes of understanding concepts better while reading. To do this I created a small application which you can download below. You must have the 3.5 .NET framework installed on your computer to run this. This application takes a phase, preferably short, like “Hello World” or your name. It can take longer ones but be prepared for the application to run slower. This phrase then is used to determine fitness of the individuals in the population. You can also specify the population size and the mutation rate. It is quite interesting to play with the mutation rate and the population size to find the right balance to get to the target the fastest. This application uses roulette wheel selection which just means that the fitter the individual the higher probability that they will get selected to reproduce. I take two parents and then determine a random crossover point and take the genes before the crossover point from one parent and take the genes after the crossover point from the second parent to form the child. An important lesson I learned here was that the crossover point has to be random. When first running this I had the crossover point be the middle and I always take the first half from the first parent and the second half from the second parent. This caused me not to be able to get to my target phrase. There are 28 alleles for each trait. This includes the alphabet, explanation marks and spaces. If an individual gets selected for mutation, one of it’s genes, chosen randomly, is switched to a different allele. Mutation was the second important lesson I learned while writing this application. It is a necessity to keep your population genetically diverse. If you don’t have mutation, it is possible that everyone in the population will become the same before you reach your optimal solution (target phrase). I now need to find a good book so I can learn more about this. If you know of any good GA books, please leave a comment.




November 16th, 2008 at 10:13 am
cool, I think you would really have liked GA courses in CSCI at SCSU. When I was in one, I made an app that would write music using GA’s, it’s pretty interesting.