Hi Nicole, sorry for the delay in response.
So what I gather is that you'd like to do tree editing during evaluation. ECJ has no built-in facilities for this, and the pipelines won't help you anyway since they're designed for breeding.
What I suggest is that you just go ahead and do the editing directly in your Problem.evaluate(...) function. Some hints:
- GPNodes have backpointers to their parents. If you modify or move a node, make sure to update the backpointers. The root's backpointer points to the GPTree.
- You can create new GPNodes in various ways. One way is to clone an existing node or subtree. GPNode has a lot of functions for that. You can also construct a GPNode from scratch by grabbing the appropriate GPFunctionSet and cloning a node off of one of its prototypical GPNodes. See the various GPNodeBuilders (like PTC1 or GrowBuilder) to see how that's done.
- If you create an ERC, make sure to call reset() on it to randomize it to a new value. Heck, you should do that for all GPNodes you clone just for good measure, though it only matters for ERCs.
On Sep 15, 2011, at 1:57 PM, Nicole Nelson wrote:
> I am using ECJ for my masters thesis. However, I am still working on becoming familiar with the API. I am
> trying to alter a GPIndividual prior to evaluation. For instance, when I have a tree that is + 5 2 I would like
> to replace this portion with a constant 7. I had the wrong impression of breeding pipelines and have the
> functionality through a pipeline. However, I want to be able to simplify a tree prior to evaluating its fitness.
> Is there anything built into ECJ that I can extend to do such a thing?