ECF 1.5
IAERCD.h
1#ifndef IAERCD_h
2#define IAERCD_h
3
4#include "ecf/tree/Terminal.h"
5#include "ecf/tree/Primitive.h"
6#include "IAPrimitive.h"
7
9{
10public:
11 virtual void execute(void* result, Tree::Tree& tree);
12 virtual IABounds calculateBounds(Tree::IATree& tree);
13
14 Tree::PrimitiveP assignToNode(Tree::PrimitiveP primitive)
15 {
16 // shallow copy - the values_ are not copied
17 IAERCD *erc = new IAERCD(*this);
18
19 // generate a random value in the interval
20 if(useInterval_) {
21 double r = state_->getRandomizer()->getRandomDouble();
22 erc->value_ = (*values_)[0] + r * ((*values_)[1] - (*values_)[0]);
23 }
24 // or choose a random predefined value
25 else {
26 uint iData = state_->getRandomizer()->getRandomInteger((int)values_->size());
27 erc->value_ = values_->at(iData);
28 }
29 std::ostringstream ss;
30 ss << erc->value_;
31 erc->setName(name_ + ss.str());
32 return (Tree::PrimitiveP) erc;
33 }
34};
35
36typedef boost::shared_ptr<IAERCD> IAERCDP;
37
38#endif // IAERCD_h
Definition: IAERCD.h:9
virtual void execute(void *result, Tree::Tree &tree)
Execute the primitive.
Definition: IAERCD.cpp:7
Ephemereal random constant (ERC) node of type double (Tree genotype).
Definition: Terminal.h:189
std::vector< double > * values_
Definition: Terminal.h:177
void setName(std::string name)
Set primitive's name.
Definition: Primitive.cpp:100
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29