2#include "MutIntoSilent.h"
3#include "Cartesian_genotype.h"
4#include "FunctionSet.h"
8 myGenotype_->registerParameter(state,
"mut.tosilent", (voidP)
new double(0), ECF::DOUBLE);
13 voidP sptr =
myGenotype_->getParameterValue(state,
"mut.tosilent");
22 uint whichOutput = cartesian->get_random_int(0, cartesian->
nOutputs - 1);
23 std::vector<uint> activeTrail = cartesian->
getActiveTrail(whichOutput);
24 uint whoIsMutated = activeTrail[cartesian->get_random_int(0, activeTrail.size() - 1)];
26 std::set<uint> allActiveIndexes;
27 std::vector<std::vector<uint> > allTrails = cartesian->
getActiveTrails();
28 for(uint i = 0; i < allTrails.size(); i++) {
29 for(uint j = 0; j < allTrails[i].size(); j++) {
30 if(allTrails[i][j] < whoIsMutated) {
31 allActiveIndexes.insert(allTrails[i][j]);
35 if(allTrails.empty()){
38 if(allActiveIndexes.size() == cartesian->size() - cartesian->
nOutputs) {
41 uint rowNumber = cartesian->getRowNumber(whoIsMutated);
43 std::set<uint> allPossibleConnections = cartesian->allPossibleConnection(rowNumber);
44 std::set<uint> tempSet;
45 for(std::set<uint>::iterator it = allPossibleConnections.begin(); it != allPossibleConnections.end(); it++) {
46 if(allActiveIndexes.count(*it) > 0) {
53 allPossibleConnections = tempSet;
54 if(allPossibleConnections.empty()) {
57 while(allActiveIndexes.count(newConnection)) {
60 for(uint i = 0; i < activeTrail.size(); i++) {
62 if(activeTrail[i] + cartesian->
nInputs > newConnection) {
63 for(uint j = 0; j < cg.inputConnections.size(); j++) {
64 if(cg.inputConnections[j] == whoIsMutated) {
65 cg.inputConnections[j] = newConnection;
double probability_
probability of usage of this mutation operator
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
uint nInputs
total number of inputs (including constants)
uint randomConnectionGenerator(uint rowNumber)
std::vector< uint > getActiveTrail(uint output_number)
uint nOutputs
number of final outputs
std::vector< std::vector< uint > > getActiveTrails()
bool mutate(GenotypeP gene)
Performs mutation of a genotype object. The genotype object must be initialized!
void registerParameters(StateP state)
Register parameters with the system. Called before MutationOp::initialize.
bool initialize(StateP state)
Initialize mutation operator. Called before first mutation operation.