Question

I am working on a project that makes use of TinyGP. I am in the process of studying the TinyGP code but it is really "dense", with few comments. I can get it to evolve equations based on my sample data just fine. They are typically sprawling equations that do infarct come close to the source equation that I used to generate my data from.

What I can't figure out is where TinyGP is actually creating new random constants, and what is the technique by which this is done in GP?

Was it helpful?

Solution

You should take a look at the Genetic Programming Field Guide. It explains some of this. Different GP's use different techniques to generate the constants. In TinyGP you they are part of the "terminal set". TinyGP generates them at the very beginning. So they are fixed. New "constants" are created through mutation and crossover.

Perhaps 1, 2 and 10 are in your constant set. You might have a constant of 1 as a terminal node. Mutation might make this "1/2", and now you have .5. Further mutation might change this to "1/2/10". Now you have 0.05. The full tree remains through each step. This is how TinyGP effectively gets more constant values.

This DOES result in the sprawling equations like you noticed. Rewrite rules can help with this. Though, you need to think about when to rewrite. Rewriting at the end can give you better looking equations. Rewriting as you go gives you smaller trees which might prevent TinyGP from creating a richer set of constants, as there are now fewer branches to mutate and cross over to.

A really simple rewrite rule that helps is to squash all of the constant values. For example, if you detect no variables under a node, just calculate it and replace with the calculated value. For TinyGP, you can only do this at the end because you cannot introduce new constant nodes as you go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top