ECF 1.5
IASub.cpp
1#include "GPSymbRegEvalOp.h"
2
3#include "IASub.h"
4#include "IATree.h"
5#include <cmath>
6
7void IASub::execute(void* result, Tree::Tree& tree)
8{
9 if (!calculateBoundsIfRootNode(result, tree)) {
10 return;
11 }
12
14}
15
16IABounds IASub::calculateBounds(Tree::IATree& tree) {
17 // get next argument
18 tree.iNode_++;
19 IAPrimitiveP prim1 = boost::dynamic_pointer_cast<IAPrimitive>(tree[tree.iNode_]->primitive_);
20 // calculate bounds
21 IABounds bounds1 = prim1->calculateBounds(tree);
22
23 if (!bounds1.isWithinBounds) {
24 // subtree not within bounds, delete expression
25 return bounds1;
26 }
27
28 // get next argument
29 tree.iNode_++;
30 IAPrimitiveP prim2 = boost::dynamic_pointer_cast<IAPrimitive>(tree[tree.iNode_]->primitive_);
31 // calculate bounds
32 IABounds bounds2 = prim2->calculateBounds(tree);
33
34 if (!bounds2.isWithinBounds) {
35 // subtree not within bounds, delete expression
36 return bounds2;
37 } else {
38 // subtree is ok
39 IABounds retVal;
40 retVal.isWithinBounds = true;
41 retVal.isLowerBoundInclusive = bounds1.isLowerBoundInclusive && bounds2.isUpperBoundInclusive;
42 retVal.lowerBound = bounds1.lowerBound - bounds2.upperBound;
43 retVal.isUpperBoundInclusive = bounds1.isUpperBoundInclusive && bounds2.isLowerBoundInclusive;
44 retVal.upperBound = bounds1.upperBound - bounds2.lowerBound;
45 return retVal;
46 }
47}
virtual void execute(void *result, Tree::Tree &tree)
Execute the primitive.
Definition: IASub.cpp:7
void execute(void *result, Tree &tree)
Execute the primitive.
Definition: Sub.h:37
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29
uint iNode_
current node index (when parsing the tree)
Definition: Tree_c.h:75