2#include "MutConnectionSilent.h"
3#include "Cartesian_genotype.h"
4#include "FunctionSet.h"
8 myGenotype_->registerParameter(state,
"mut.connectionsilent", (voidP)
new double(0), ECF::DOUBLE);
13 voidP sptr =
myGenotype_->getParameterValue(state,
"mut.connectionsilent");
21 const std::vector<FunctionP_basic>& vRef = cartesian->functionSet_->vActiveFunctions_;
22 std::set<uint> allActiveIndexes;
23 std::vector<std::vector<uint> > allTrails = cartesian->
getActiveTrails();
24 for(uint i = 0; i < allTrails.size(); i++) {
25 for(uint j = 0; j < allTrails[i].size(); j++) {
26 allActiveIndexes.insert(allTrails[i][j]);
29 uint toBeMutated = cartesian->get_random_int(0, cartesian->size() - 1 - cartesian->
nOutputs);
30 if(allActiveIndexes.size() == cartesian->size() - cartesian->
nOutputs) {
33 while(allActiveIndexes.count(toBeMutated)) {
34 toBeMutated = cartesian->get_random_int(0, cartesian->size() - 1 - cartesian->
nOutputs);
36 uint oldFunctionId = cartesian->operator[](toBeMutated).value;
37 uint rowNumber = cartesian->getRowNumber(toBeMutated);
38 uint oldConnection = cartesian->get_random_int(0, vRef[oldFunctionId]->getNumOfArgs() - 1);
40 cartesian->operator[](toBeMutated).inputConnections[oldConnection] = newConnection;
double probability_
probability of usage of this mutation operator
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
uint randomConnectionGenerator(uint rowNumber)
uint nOutputs
number of final outputs
std::vector< std::vector< uint > > getActiveTrails()
void registerParameters(StateP state)
Register parameters with the system. Called before MutationOp::initialize.
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.