Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

My big idea: Ancient Brain


CA114      CA170

CA668      CA669      Projects

Sample code for Genetic Algorithms

Here is some sample C++ (pseudo)code for how to implement a basic Genetic Algorithm:

The basic Genetic Algorithm classes

Sample implementation - Optimise a function over some interval

Be warned though, that this GA code is a bit of a hack, and is not very object-oriented. In particular, the separation of the abstract GA classes from the user application is not very good. I'm sure you can figure out a more elegant design yourself.

ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.

Wikipedia: Sometimes I link to Wikipedia. I have written something In defence of Wikipedia. It is often a useful starting point but you cannot trust it. Linking to it is like linking to a Google search. A starting point, not a destination. I automatically highlight in red all links to Wikipedia and Google search and other possibly-unreliable user-generated content.