1#include "../ECF_base.h"
3#include "TreeMutNodeReplace.h"
12 myGenotype_->registerParameter(state,
"mut.nodereplace", (voidP)
new double(0), ECF::DOUBLE);
18 voidP sptr =
myGenotype_->getParameterValue(state,
"mut.nodereplace");
29 uint origNodeIndex = state_->getRandomizer()->getRandomInteger((
int) tree->size());
30 std::string origNodeName = tree->at(origNodeIndex)->primitive_->getName();
31 int origNodeNumberOfArguments = tree->at(origNodeIndex)->primitive_->getNumberOfArguments();
37 primitive = tree->primitiveSet_->getRandomPrimitive();
39 }
while((origNodeName == primitive->getName()
40 || origNodeNumberOfArguments != primitive->getNumberOfArguments()) && tries < 4);
42 if(origNodeName == primitive->getName() || origNodeNumberOfArguments != primitive->getNumberOfArguments()) {
43 ECF_LOG(state_, 5,
"TreeMutNodeReplace not successful.");
47 tree->at(origNodeIndex)->setPrimitive(primitive);
49 std::stringstream log;
50 log <<
"TreeMutNodeReplace successful (oldNode = " << origNodeName <<
", ";
51 log <<
"newNode = " << primitive->getName() <<
")";
52 ECF_LOG(state_, 5, log.str());
double probability_
probability of usage of this mutation operator
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
Tree class - implements genotype as a tree.
void registerParameters(StateP)
Register parameters with the system. Called before MutationOp::initialize.
bool initialize(StateP)
Initialize mutation operator. Called before first mutation operation.
bool mutate(GenotypeP gene)
Performs mutation of a genotype object. The genotype object must be initialized!