Changeset 968 for cpp/frams/genetics/genooperators.cpp
 Timestamp:
 06/30/20 00:30:39 (3 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

cpp/frams/genetics/genooperators.cpp
r967 r968 9 9 #include <frams/util/rndutil.h> 10 10 11 // 12 // custom distributions for mutations of various parameters 13 // 11 14 static double distrib_force[] = // for '!' 12 15 { … … 31 34 1, 1, // ~linear 32 35 }; 33 36 /* 37 static double distrib_weight[] = 38 { 39 5, // distribution 999 _^_^_ +999 40 999, 999, // each weight value may be useful, especially... 41 5, 0.3, // ...little nonzero values 42 3, 0.6, 43 0.6, 3, 44 0.3, 5, 45 }; 46 */ 34 47 35 48 int GenoOperators::roulette(const double *probtab, const int count) … … 108 121 double GenoOperators::getMutatedNeuroClassProperty(double current, Neuro *n, int i) 109 122 { 110 if (i == 1) return mutateCreepNoLimit('f', current, 2, true); //i==1: mutating weight of neural connection 123 if (i == 1) 124 { 125 logPrintf("GenoOperators", "getMutatedNeuroClassProperty", LOG_WARN, "Deprecated usage in C++ source: to mutate connection weight, use getMutatedNeuronConnectionWeight()."); 126 return getMutatedNeuronConnectionWeight(current); 127 } 111 128 Param p; 112 129 if (i >= NEUROCLASS_PROP_OFFSET) { i = NEUROCLASS_PROP_OFFSET; p = n>getClass()>getProperties(); } … … 117 134 } 118 135 136 double GenoOperators::getMutatedNeuronConnectionWeight(double current) 137 { 138 return mutateCreepNoLimit('f', current, 2, true); 139 } 140 119 141 bool GenoOperators::mutatePropertyNaive(ParamInterface &p, int i) 120 142 { … … 145 167 if (p.type(i)[0] != 'f' && p.type(i)[0] != 'd') return false; //don't know how to mutate 146 168 const char *n = p.id(i), *na = p.name(i); 147 if (strcmp(n, "si") == 0 && strcmp(na, "Sigmoid") == 0) newval = CustomRnd(distrib_sigmo); else148 if (strcmp(n, "in") == 0 && strcmp(na, "Inertia") == 0) newval = CustomRnd(distrib_inertia); else149 if (strcmp(n, "fo") == 0 && strcmp(na, "Force") == 0) newval = CustomRnd(distrib_force); else169 if (strcmp(n, "si") == 0 && strcmp(na, "Sigmoid") == 0) newval = round(CustomRnd(distrib_sigmo), 3); else 170 if (strcmp(n, "in") == 0 && strcmp(na, "Inertia") == 0) newval = round(CustomRnd(distrib_inertia), 3); else 171 if (strcmp(n, "fo") == 0 && strcmp(na, "Force") == 0) newval = round(CustomRnd(distrib_force), 3); else 150 172 { 151 173 double mn, mx, df; … … 167 189 { 168 190 if (limit_precision_3digits) 169 result = floor(result * 1000 + 0.5) / 1000.0; //round191 result = round(result, 3); 170 192 } 171 193 return result; … … 186 208 { 187 209 //reflect and wrap above may have changed the (limited) precision, so try to round again (maybe unnecessarily, because we don't know if reflect+wrap above were triggered) 188 double result_try = floor(result * 1000 + 0.5) / 1000.0; //round210 double result_try = round(result, 3); 189 211 if (mn <= result_try && result_try <= mx) result = result_try; //after rounding still witin allowed range, so keep rounded value 190 212 } … … 375 397 int l = (int)strlen(n); 376 398 if (len >= l && l > Len && (strncmp(s, n, l) == 0)) { I = NEUROCLASS_PROP_OFFSET + i; Len = l; } 377 if (also_v1_N_props) //recognize old properties symbols/=!399 if (also_v1_N_props) //recognize old symbols of properties: /=! 378 400 { 379 401 if (strcmp(n, "si") == 0) n = "/"; else
Note: See TracChangeset
for help on using the changeset viewer.