- Timestamp:
- 10/21/09 23:45:09 (15 years ago)
- Location:
- cpp/geno_fx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/geno_fx/geno_fx.cpp
r3 r31 55 55 double Geno_fx::mutateNeuProperty(double current,Neuro *n,int i) 56 56 { 57 if (i==-1) return mutateCreep ('f',current,-10,10);57 if (i==-1) return mutateCreepNoLimit('f',current,-10,10); 58 58 ParamInterface *pi; 59 59 if (i>=100) {i-=100; pi=&n->getClass()->getProperties();} 60 60 else pi=&n->extraProperties(); 61 double newval ;61 double newval=current; 62 62 /*bool ok=*/getMutatedProperty(*pi,i,current,newval); 63 63 return newval; … … 103 103 } 104 104 105 double Geno_fx::mutateCreep (char type,double current,double mn,double mx)105 double Geno_fx::mutateCreepNoLimit(char type,double current,double mn,double mx) 106 106 { 107 107 double result=RndGen.Gauss(current,(mx-mn)/2/5); // /halfinterval, 5 times narrower 108 108 if (type=='d') {result=int(result+0.5); if (result==current) result+=randomN(2)*2-1;} 109 else result=floor(result*1000)/1000.0; 109 else result=floor(result*1000+0.5)/1000.0; //round 110 return result; 111 } 112 113 double Geno_fx::mutateCreep(char type,double current,double mn,double mx) 114 { 115 double result=mutateCreepNoLimit(type,current,mn,mx); 116 //reflect: 117 if (result>mx) result=mx-(result-mx); else 118 if (result<mn) result=mn+(mn-result); 119 //absorb (just in case 'result' exceeded the allowed range so much): 110 120 if (result>mx) result=mx; else 111 121 if (result<mn) result=mn; -
cpp/geno_fx/geno_fx.h
r3 r31 185 185 static bool mutateProperty(ParamInterface &p,int propindex); ///<like mutatePropertyNaive(), but uses special probability distributions for some neuron properties. 186 186 static bool getMutatedProperty(ParamInterface &p,int i,double oldval,double &newval); ///<like mutateProperty(), but just returns \e newval, does not get nor set it using \e p. 187 static double mutateCreep(char type,double current,double mn,double mx); ///<returns \e current value creep-mutated with Gaussian distribution within [ \e mn , \e mx ] interval. Forced precision: 3 digits after comma. \e type must be either 'd' (integer) or 'f' (float/double). 187 static double mutateCreepNoLimit(char type,double current,double mn,double mx); ///<returns \e current value creep-mutated with Gaussian distribution within [ \e mn , \e mx ] interval. Forced precision: 3 digits after comma. \e type must be either 'd' (integer) or 'f' (float/double). 188 static double mutateCreep(char type,double current,double mn,double mx); ///<just as mutateCreepNoLimit(), but forces mutated value into the [mn,mx] range using the 'reflect' approach. 188 189 static NeuroClass* getRandomNeuroClass(); ///<returns random neuroclass or NULL when no active classes. 189 190 static NeuroClass* parseNeuroClass(char *&s); ///<returns neuroclass or NULL if the string does not begin with a valid name. Advance \e s pointer.
Note: See TracChangeset
for help on using the changeset viewer.