[Cs254f11] a complete GP system
Lee Spector
lspector at hampshire.edu
Tue Oct 18 22:35:11 EDT 2011
Here's a big step up from the simple genetic algorithm code that I sent out previously and which we covered in class yesterday:
https://gist.github.com/1297325
This is a complete genetic programming system that solves (sometimes) the same symbolic regression problem that's used in Chapter 4 our our text. It's not exactly the same as the algorithm that they describe there -- I use some different parameters and do a couple of things slightly differently -- because I've tried to strike a balance between doing things in the standard/efficient way and writing relatively simple and clear Clojure code.
Note BTW that a couple of things could be done even more concisely (e.g. the "insert" and "extract" functions), but I also wanted to avoid using fancy Clojure stuff that we haven't gone over in class, like clojure.zip and clojure.walk.
The result is not quite as simple as the earlier genetic algorithm code that I shared (and it's also not exactly what you might end up with following the hints and exercises in clojinc), but it's still fairly concise and all of you should be able to understand it if you study it carefully.
I also think that this is pretty close, in most important respects, to the GP algorithms that professionals use for real problems. And it is certainly a good starting point for exploration and extension.
You should feel free to modify/reuse this code in your own work, with attribution. But you should understand everything that you use!
I will go over it in detail in class.
-Lee
--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector at hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438
More information about the Cs254f11
mailing list