/** Returns true if inner1 can feasibly be swapped into inner2's position. */ public boolean verifyPoints( final GPInitializer initializer, final GPNode inner1, final GPNode inner2) { // first check to see if inner1 is swap-compatible with inner2 // on a type basis if (!inner1.swapCompatibleWith(initializer, inner2)) return false; // next check to see if inner1 can fit in inner2's spot if (inner1.depth() + inner2.atDepth() > maxDepth) return false; // check for size // NOTE: this is done twice, which is more costly than it should be. But // on the other hand it allows us to toss a child without testing both times // and it's simpler to have it all here in the verifyPoints code. if (maxSize != NO_SIZE_LIMIT) { // first easy check int inner1size = inner1.numNodes(GPNode.NODESEARCH_ALL); int inner2size = inner2.numNodes(GPNode.NODESEARCH_ALL); if (inner1size > inner2size) // need to test further { // let's keep on going for the more complex test GPNode root2 = ((GPTree) (inner2.rootParent())).child; int root2size = root2.numNodes(GPNode.NODESEARCH_ALL); if (root2size - inner2size + inner1size > maxSize) // take root2, remove inner2 and swap in inner1. Is it still small enough? return false; } } // checks done! return true; }