You can edit a GPTree any way you like, but ECJ doesn't provide any method to do it.

A GP tree is just a tree of GPNodes with back-pointers.  Every GPNode has an array of children, a pointer to its parent, and an integer indicating where in its parent's children array the GPNode may be found.  Leaf nodes may have zero-length children arrays, or may have null for the array.

So when you update a GPNode, you may need to update:
	1. The parent pointer of the GPNode
	2. The child array of the GPNode
	3. The "argposition" of the GPNode (which indicates its position in its' parent array)
	4. The slot in the parent's child array
	5. The parent pointer of every child to the GPNode
	6. The argposition of every child to the GPNode

The GPTree is special.  It is the parent of the root, and it has a single child (the root) rather than an array.  You'll need to check to see if the parent is a GPTree rather than a GPNode.

Be warned that if you replace nodes with ones which violate type constraints, you're on your own: you'll probably break breeding operators at the very least.


On May 24, 2013, at 10:35 PM, Bojan Janisch wrote:

> Hey everyone,
> is there a way to remove a GPNode from a GPTree or to merge multiple Nodes that have only 1 child?
> The node replacement would be an option, but it seems that it does not affect the GPTree. Well
> means I don't see a difference if I print the individual before and after the replacement. 
> Greetings 
> Bojan