Changeset 959
- Timestamp:
- 06/26/20 01:30:10 (4 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genooperators.cpp
r957 r959 74 74 } 75 75 return defined == 3; 76 } 77 78 bool GenoOperators::mutateRandomNeuronOrNeuroclassProperty(Neuro* n) 79 { 80 bool mutated = false; 81 int prop = selectRandomNeuronProperty(n); 82 if (prop >= 0) 83 { 84 if (prop >= GenoOperators::NEUROCLASS_PROP_OFFSET) 85 { 86 SyntParam par = n->classProperties(); //commits changes when p is destroyed 87 mutated = mutateProperty(par, prop - GenoOperators::NEUROCLASS_PROP_OFFSET); 88 } 89 else 90 { 91 Param par = n->extraProperties(); 92 mutated = mutateProperty(par, prop); 93 } 94 } 95 return mutated; 76 96 } 77 97 -
cpp/frams/genetics/genooperators.h
r957 r959 185 185 static int roulette(const double *probtab, const int count); ///<returns random index according to probabilities in the \e probtab table or -1 if all probs are zero. \e count is the number of elements in \e probtab. 186 186 static bool getMinMaxDef(ParamInterface *p, int propindex, double &mn, double &mx, double &def); ///<perhaps a more useful (higher-level) way to obtain min/max/def info for integer and double properties. Returns true if min/max/def was really available (otherwise it is just invented). 187 static bool mutateRandomNeuronOrNeuroclassProperty(Neuro* n); ///<high-level neuron mutation function, will select and mutate a random property of a neuron or its neuroclass. Returns true if successful and some property was actually mutated. Could return false when the neuron and its neuroclass have no properties, or when a randomly selected property was not suitable for mutation (for example a string or another non-number type). 187 188 static int selectRandomNeuronProperty(Neuro* n); ///<selects random property (either 0-based extraproperty of Neuro or NEUROCLASS_PROP_OFFSET-based property of its NeuroClass). -1 if Neuro has no properties. 188 189 static double mutateNeuronProperty(double current, Neuro *n, int propindex); ///<returns value \e current mutated for the property \e propindex of NeuroClass \e nc or for extraproperty (\e propindex - NEUROCLASS_PROP_OFFSET) of Neuro. Neuro is used as read-only. Give \e propindex == -1 to mutate connection weight (\e nc is then ignored).
Note: See TracChangeset
for help on using the changeset viewer.