Print

Print


Hi everybody!

I started using ECJ a few weeks ago and I have a question about how to 
implement certain tree constraints, in a genetic programming problem.

My individuals, should be trees that have the structure I show in 
the attached file. Each tree holds a rule (in fact, it holds the antecedent 
of an association rule) that has the following form:

        A>5 & B<10 & ....

Just to simplify the problem, let's suppose that the only logical operator 
availale is the AND one. 

I saw that for implementing the constraint that a comparator node has to 
have a non-terminal + a random value as children, I have to use GPNode 
constraints, specifying the type of node I want for left and right child.

The problem I have is how to tell ECJ to build a tree with that specific 
structure. When ECJ creates a tree, it puts the terminals on the leaves, and 
non-terminals on the remainder nodes. But how can I specify that the nodes 
previous to the leaves have to have a comparator?

Should I use Tree constraints? or should I modify the tree builder to meet 
my needs? I know that this latter can be done but I'm not sure if it's the 
right approach. I'm trying to extend the ECJ framework without touching its 
classes, as I want to preserve the original code so in future releases of 
ECJ I just "plug" my classes and everything continues working.

In case I have to implement it by specifying tree constraints, could you 
provide me with an example about how to do it?

Thanks in advance.

Norberto Roth