Lab 7 - Genetic Programming

This lab is worth 10 points.
Due: Friday March 7, 2008 at 5:00pm

This lab will look at a genetic programming program provided by Donna Meyers. The program attempts to learn a function that takes a single variable, e.g. f(x). The program is given a set of training data that consists of the value of x and the value of f(x). It creates a population of parse trees that attempts to replicate the desired value of f(x). At the end of the lifecycle, the best performing parse tree is printed to standard out.

Perform the following steps to compile and test the code:

It will take a minute or two for each command to run and it generates no output until done. When done, it will print the generated function, the error and the time it took to run. If you wish to let it run longer, alter the file gp.cpp and change the variable MAXTIME. Then recompile with make and rerun the commands.

Each input file describes a different function. At the start of the input file is the training data in the form of:

number_of_training_examples
x1      f(x1)
x2      f(x2)
.       .
.       .
.       .
xN      f(xN)
This is the only portion of the file read in by the program. Several of the input files have further information below the training examples that is for the benefit of the people reading the file. This may include the target function and example output. Not all input files have this additional data.

Lab Writeup

Answer the following questions in an email to me.
  1. What is the fitness measuring? Is this program minimizing fitness or maximizing it?
  2. Where is the list of valid functions defined? What are the valid functions?
  3. In gp.cpp, what is the purpose of each column in xMatrix? Do not just give the value stated in the comment. Instead, describe what the value means.
  4. The tournament size for selection is currently 4. Describe the code changes that would be needed to create a tournament of size 8.
  5. The mutation done in this code uses a variation on the process described in the book. Describe how the mutation operation (hillClimb()) works.