Home > Genetic-Prog

Genetic-Prog

Genetic-Prog is a project mainly written in C++ and C, it's free.

Simple Code For Genetic Programming in C++

Genetic Programming C++ Code

This directory contains a simple implementation of genetic programming.
I decided to write it in C++, well becasue C++ is awesome, and fast. No one will sue you if you write something in C and make money off of it. C is an ANSI standard.
I have provided some code to do some simple things with Genetic Programming. You can extend this code to do whatever you want. You will need some way of quantifying if you are getting closer to what you want.

I have provided an example where I have nine pairs of x,y values and ask the computer to find out what generated this. The data is generated by a simple equation: y=2x^2 + 3x + 1. I have gotten exact solutions in five generations with 100 euqtions in the population. I often get very close solutions similar to: 2x^2 + 2.97x + 0.98 within a few generations. You can experiment with the rate of mutation, the amount of crossover, the percentage of the population that survies to breed, etc. Have fun.

For an introduction to Genetic Programming I recommend: A Field Guide to Genetic Programming (ISBN 978-1-4092-0073-4). You can get the pdf version of the book for free.