next up previous
Next: Genetic programming made Up: Implementation in C Previous: The basic tree

Generating an initial population

To generate a tree, we randomly pick a function for the root node, create children, and recurse through the tree. We pick from , and if we pick a terminal then we must terminate the branch. At the terminal nodes, we use the *pvalue pointer to point into the array TermSet, which holds all possible terminals. Another array, ArgSet points into the TermSet, and makes it possible to ``pass'' arguments to the programs. The value variable stores the result of the evaluation of all nodes below it. So random generation is made as simple as generating random indices into simple arrays.