1#include "MutFunctionSwap.h"
2#include "Cartesian_genotype.h"
3#include "FunctionSet.h"
8 myGenotype_->registerParameter(state,
"mut.funcswap", (voidP)
new double(0), ECF::DOUBLE);
13 voidP sptr =
myGenotype_->getParameterValue(state,
"mut.funcswap");
21 const std::vector<FunctionP_basic>& vRef = cartesian->functionSet_->vActiveFunctions_;
23 uint firstIndex = cartesian->get_random_int(0, cartesian->size() - 1 - cartesian->
nOutputs);
24 uint secondIndex = cartesian->get_random_int(0, cartesian->size() - 1 - cartesian->
nOutputs);
25 uint firstFunction = cartesian->operator[](firstIndex).value;
26 uint secondFunction = cartesian->operator[](secondIndex).value;
27 uint firstNoOfArgs = vRef[firstFunction]->getNumOfArgs();
28 uint secondNoOfArgs = vRef[secondFunction]->getNumOfArgs();
29 while(firstNoOfArgs != secondNoOfArgs) {
30 secondIndex = cartesian->get_random_int(0, cartesian->size() - 1 - cartesian->
nOutputs);
31 secondFunction = cartesian->operator[](secondIndex).value;
32 secondNoOfArgs = vRef[secondFunction]->getNumOfArgs();
34 cartesian->operator[](firstIndex).value = secondFunction;
35 cartesian->operator[](secondIndex).value = firstFunction;
double probability_
probability of usage of this mutation operator
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
uint nOutputs
number of final outputs
bool mutate(GenotypeP gene)
Performs mutation of a genotype object. The genotype object must be initialized!
bool initialize(StateP state)
Initialize mutation operator. Called before first mutation operation.
void registerParameters(StateP state)
Register parameters with the system. Called before MutationOp::initialize.