Changeset 752 for cpp/frams/genetics/fn/oper_fn.cpp
- Timestamp:
- 02/28/18 23:43:57 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fn/oper_fn.cpp
r747 r752 11 11 static ParamEntry GENOfnparam_tab[] = 12 12 { 13 { "Genetics: fn", 1, 1, }, 14 { "fn_xover", 0, 0, "Inherited in linear mix crossover", "f 0.5 1.0 0.5", FIELD(xover_proportion), "0.5 => children are averaged parents.\n0.8 => children are only 20% different from parents.\n1.0 => each child is identical to one parent (no crossover).", }, 13 { "Genetics: fn", 1, 4, }, 14 { "fn_xover", 0, 0, "Inherited in linear mix crossover", "f 0.5 1.0 0.9", FIELD(xover_proportion), "0.5 => children are averaged parents.\n0.8 => children are only 20% different from parents.\n1.0 => each child is identical to one parent (no crossover).", }, 15 { "fn_mut_bound_low", 1, 0, "Lower bounds for mutation", "s 0 0 [-1.0]", FIELD(mut_bound_low), "A vector of lower bounds (one real value for each variable)", }, 16 { "fn_mut_bound_high", 1, 0, "Higher bounds for mutation", "s 0 0 [1.0]", FIELD(mut_bound_high), "A vector of higher bounds (one real value for each variable)", }, 17 { "fn_mut_stddev", 1, 0, "Standard deviations for mutation", "s 0 0 [0.1]", FIELD(mut_stddev), "A vector of standard deviations (one real value for each variable)", }, 15 18 { 0, }, 16 19 }; … … 51 54 if (values.size() == 0) 52 55 return GENOPER_OPFAIL; 56 vector<double> bound_low = GenoConv_fn0::stringToVector(mut_bound_low.c_str()); 57 vector<double> bound_high = GenoConv_fn0::stringToVector(mut_bound_high.c_str()); 58 vector<double> stddev = GenoConv_fn0::stringToVector(mut_stddev.c_str()); 59 if (bound_low.size() != bound_high.size() || bound_high.size() != stddev.size() || stddev.size() != values.size()) 60 { 61 logPrintf("GenoOper_fn", "mutate", LOG_ERROR, "The solution vector, bound vectors, and standard deviation vectors must all have the same number of values"); 62 return GENOPER_OPFAIL; 63 } 64 53 65 int which = randomN(values.size()); 54 values[which] = GenoOperators::mutateCreep('f', values[which], -100, 100); //TODO precision 0.001 is forced!66 values[which] = GenoOperators::mutateCreep('f', values[which], bound_low[which], bound_high[which], stddev[which], false); 55 67 string saved = GenoConv_fn0::vectorToString(values); 56 68 free(gene);
Note: See TracChangeset
for help on using the changeset viewer.