Pages

Friday, April 15, 2011

F# and genetic algorithms

I have already three posts: fitness, chromosome, and population for the GA. Because my IEEE paper is about the chromosome encoding, so I am very interested in decouple the geno and phone mapping.

This post is to use F# implement the Genetic Algorithm (GA). This GA implementation is based on genotype and phenotype. You can add geno-to-pheno type mapping. Not like simple genetic algorithm, the chromosome is only 0 and 1, this implementation supports the integer. I believe you can support other chromosome representation easily because the beauty of F#. The chromosome representation can be generated by the initialization function. All the GA part is represented as function and you are given the liberty to pass in your function.

I also added the elitism for the evolution. (Aug 05, 2012).

Please use the link below to get the code.


1 comment:

@fbmnds said...

Hi,

thanks for sharing this. I modified your genetic algorithm here: https://github.com/fbmnds/fs-random-snippets/blob/master/GeneticAlgorithm.fsx

/fb