ECF 1.5
IAPrimitive.h
1#ifndef IAPrimitive_h
2#define IAPrimitive_h
3
4#include<iostream>
5#include "IATree.h"
6
7typedef struct {
8 bool isWithinBounds;
9
10 bool isLowerBoundInclusive;
11 double lowerBound;
12
13 bool isUpperBoundInclusive;
14 double upperBound;
15} IABounds;
16
18{
19public:
20 virtual IABounds calculateBounds(Tree::IATree& tree) = 0;
21
22 // Returns true if everything is ok and expression should be evaluated
23 virtual bool calculateBoundsIfRootNode(void* result, Tree::Tree& tree) {
24 Tree::IATree& iaTree = static_cast<Tree::IATree&>(tree);
25 if (!iaTree.boundsCalculated) {
26 // bounds haven't been calculated yet
27 IABounds bounds = this->calculateBounds(iaTree);
28 iaTree.boundsCalculated = true;
29 tree.iNode_ = 0; // reset tree's node index pointer
30 if (!bounds.isWithinBounds) {
31 // tree not within bounds, delete expression
32 double& arg = *(double*)result;
33 arg = 1e14;
34 return false;
35 }
36 }
37 return true;
38 }
39};
40
41typedef boost::shared_ptr<IAPrimitive> IAPrimitiveP;
42
43#endif // IAPrimitive_h
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