1#include "GPSymbRegEvalOp.h"
9 if (!calculateBoundsIfRootNode(result, tree)) {
19 IAPrimitiveP prim1 = boost::dynamic_pointer_cast<IAPrimitive>(tree[tree.
iNode_]->primitive_);
21 IABounds bounds1 = prim1->calculateBounds(tree);
23 if (!bounds1.isWithinBounds) {
30 IAPrimitiveP prim2 = boost::dynamic_pointer_cast<IAPrimitive>(tree[tree.
iNode_]->primitive_);
32 IABounds bounds2 = prim2->calculateBounds(tree);
34 if (!bounds2.isWithinBounds) {
37 }
else if (boundsContainZero(bounds2)) {
39 retVal.isWithinBounds =
false;
43 double ll = bounds1.lowerBound / bounds2.lowerBound;
44 double lu = bounds1.lowerBound / bounds2.upperBound;
45 double ul = bounds1.upperBound / bounds2.lowerBound;
46 double uu = bounds1.upperBound / bounds2.upperBound;
49 if (ll <= lu && ll <= ul && ll <= uu) {
51 retVal.isLowerBoundInclusive = bounds1.isLowerBoundInclusive && bounds2.isLowerBoundInclusive;
52 retVal.lowerBound = ll;
53 }
else if (lu <= ll && lu <= ul && lu <= uu) {
55 retVal.isLowerBoundInclusive = bounds1.isLowerBoundInclusive && bounds2.isUpperBoundInclusive;
56 retVal.lowerBound = lu;
57 }
else if (ul <= ll && ul <= lu && ul <= uu) {
59 retVal.isLowerBoundInclusive = bounds1.isUpperBoundInclusive && bounds2.isLowerBoundInclusive;
60 retVal.lowerBound = ul;
63 retVal.isLowerBoundInclusive = bounds1.isUpperBoundInclusive && bounds2.isUpperBoundInclusive;
64 retVal.lowerBound = uu;
67 if (ll >= lu && ll >= ul && ll >= uu) {
69 retVal.isUpperBoundInclusive = bounds1.isLowerBoundInclusive && bounds2.isLowerBoundInclusive;
70 retVal.upperBound = ll;
71 }
else if (lu >= ll && lu >= ul && lu >= uu) {
73 retVal.isUpperBoundInclusive = bounds1.isLowerBoundInclusive && bounds2.isUpperBoundInclusive;
74 retVal.upperBound = lu;
75 }
else if (ul >= ll && ul >= lu && ul >= uu) {
77 retVal.isUpperBoundInclusive = bounds1.isUpperBoundInclusive && bounds2.isLowerBoundInclusive;
78 retVal.upperBound = ul;
81 retVal.isUpperBoundInclusive = bounds1.isUpperBoundInclusive && bounds2.isUpperBoundInclusive;
82 retVal.upperBound = uu;
85 retVal.isWithinBounds =
true;
90bool boundsContainZero(
IABounds bounds) {
91 double l = bounds.lowerBound;
92 double u = bounds.upperBound;
98 if (l == 0 && bounds.isLowerBoundInclusive) {
102 if (u == 0 && bounds.isUpperBoundInclusive) {
virtual void execute(void *result, Tree::Tree &tree)
Execute the primitive.
void execute(void *result, Tree &tree)
Execute the primitive.
Tree class - implements genotype as a tree.
uint iNode_
current node index (when parsing the tree)