Changeset 513
- Timestamp:
- 05/23/16 13:52:53 (8 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/oper_f4.cpp
r375 r513 86 86 87 87 88 int Geno_f4::validate(char *& geno )88 int Geno_f4::validate(char *& geno, const char *genoname) 89 89 { 90 90 // convert geno to tree, then try to validate 20 times … … 100 100 101 101 102 int Geno_f4::checkValidity(const char * geno )102 int Geno_f4::checkValidity(const char * geno, const char *genoname) 103 103 { 104 104 f4_node root; -
cpp/frams/genetics/f4/oper_f4.h
r286 r513 33 33 public: 34 34 Geno_f4(); 35 int validate(char *&);36 int checkValidity(const char *);35 int checkValidity(const char *, const char *genoname); 36 int validate(char *&, const char *genoname); 37 37 int mutate(char *& g, float & chg, int &method); 38 38 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); -
cpp/frams/genetics/f9/oper_f9.cpp
r348 r513 26 26 } 27 27 28 int GenoOper_f9::checkValidity(const char* gene )28 int GenoOper_f9::checkValidity(const char* gene, const char *genoname) 29 29 { 30 30 if (!gene[0]) return 1; //empty is not valid … … 36 36 37 37 ///Remove all invalid letters from the genotype 38 int GenoOper_f9::validate(char *&gene )38 int GenoOper_f9::validate(char *&gene, const char *genoname) 39 39 { 40 40 SString validated; //new genotype (everything except turtle_commands_f9 is skipped) -
cpp/frams/genetics/f9/oper_f9.h
r286 r513 13 13 public: 14 14 GenoOper_f9(); 15 int checkValidity(const char * );16 int validate(char *& );17 int mutate(char *&g, float& chg,int &method);18 int crossOver(char *&g1, char *&g2,float& chg1,float& chg2);15 int checkValidity(const char *, const char *genoname); 16 int validate(char *&, const char *genoname); 17 int mutate(char *&g, float& chg, int &method); 18 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); 19 19 uint32_t style(const char *g, int pos); 20 const char* getSimplest() { return "R";}20 const char* getSimplest() { return "R"; } 21 21 22 22 double mut_prob; //mutation probability -
cpp/frams/genetics/fF/oper_fF.cpp
r286 r513 26 26 } 27 27 28 int GenoOper_fF::checkValidity(const char* gene )28 int GenoOper_fF::checkValidity(const char* gene, const char *genoname) 29 29 { 30 30 fF_growth_params par; … … 32 32 } 33 33 34 int GenoOper_fF::validate(char *&gene )34 int GenoOper_fF::validate(char *&gene, const char *genoname) 35 35 { 36 36 fF_growth_params par; //is initialized with default values -
cpp/frams/genetics/fF/oper_fF.h
r286 r513 13 13 public: 14 14 GenoOper_fF(); 15 int checkValidity(const char * );16 int validate(char *& );15 int checkValidity(const char *, const char *genoname); 16 int validate(char *&, const char *genoname); 17 17 int mutate(char *&g, float& chg, int &method); 18 18 int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); 19 19 uint32_t style(const char *g, int pos); 20 const char* getSimplest() { return "6, 1.05, 1.05, 1.05, 0, 0, 0"; }20 const char* getSimplest() { return "6, "/*"1, 1, 1, "*/"1.05, 1.05, 1.05, 0, 0, 0"; } 21 21 22 22 double xover_proportion; -
cpp/frams/genetics/genman.cpp
r467 r513 203 203 int check1; 204 204 if (!gf) { canvalidate = false; return GENOPER_NOOPER; } 205 else check1 = gf->checkValidity(gg );205 else check1 = gf->checkValidity(gg,g.getName().c_str()); 206 206 if (!canvalidate) return check1; //just checking 207 207 if (check1 == GENOPER_OK) { canvalidate = false; return check1; } 208 208 char *g2 = strdup(gg); 209 if (gf->validate(g2 ) == GENOPER_NOOPER) { free(g2); canvalidate = false; return check1; }209 if (gf->validate(g2,g.getName().c_str()) == GENOPER_NOOPER) { free(g2); canvalidate = false; return check1; } 210 210 if (check1 == GENOPER_NOOPER) //disaster: cannot check because there is no check operator 211 211 { 212 212 g.setGene(g2); free(g2); canvalidate = false; return GENOPER_NOOPER; 213 213 } 214 int check2 = gf->checkValidity(g2 );214 int check2 = gf->checkValidity(g2, "validated"); 215 215 if (check2 == GENOPER_OK) g.setGene(g2); 216 216 free(g2); … … 238 238 return Geno(SString::empty(), -1, SString::empty(), SString::sprintf("GENOPER_NOOPER: Validate(): don't know how to handle genetic format %c", format)); 239 239 char *g2 = strdup(geny.getGene().c_str()); //copy for validation 240 int res = gf->validate(g2 );240 int res = gf->validate(g2, geny.getName().c_str()); 241 241 SString sg2 = g2; 242 242 free(g2); … … 537 537 { 538 538 string l; 539 if (oper_fx_list[i]->checkValidity("" ) != GENOPER_NOOPER) l += " checkValidity";539 if (oper_fx_list[i]->checkValidity("","") != GENOPER_NOOPER) l += " checkValidity"; 540 540 if (oper_fx_list[i]->getSimplest()) 541 541 { 542 542 g = strdup(oper_fx_list[i]->getSimplest()); 543 543 g2 = strdup(g); 544 if (oper_fx_list[i]->validate(g ) != GENOPER_NOOPER) l += " validate";544 if (oper_fx_list[i]->validate(g,"") != GENOPER_NOOPER) l += " validate"; 545 545 if (oper_fx_list[i]->mutate(g, f1, m) != GENOPER_NOOPER) l += " mutate"; 546 546 if (oper_fx_list[i]->crossOver(g, g2, f1, f2) != GENOPER_NOOPER) l += " crossover"; -
cpp/frams/genetics/genoconv.h
r286 r513 50 50 51 51 /// You have to reimplement this method. 52 /// If your converter cannot do its job, return empty string 53 /// (return SString();), any other return value is assumed 54 /// to be output genotype. 52 /// If your converter cannot do its job, return empty string - return SString(); 53 /// Any other return value is assumed to be output genotype. 55 54 /// @param map if not null, mapping informaton is requested, converter should add conversion map to this object 56 55 virtual SString convert(SString &i, MultiMap *map) { return SString(); } -
cpp/frams/genetics/oper_fx.h
r287 r513 92 92 /**Checks a genotype for minor mistakes and major errors. 93 93 \param geno genotype to be checked 94 \param genoname name of the genotype to be checked 94 95 \retval error_position 1-based (or 1 if no exact error position known) 95 96 \retval GENOPER_OK when the genotype is fully valid, and can be translated by the converter with \b no modifications nor tweaks*/ 96 virtual int checkValidity(const char *geno ) {return GENOPER_NOOPER;}97 virtual int checkValidity(const char *geno, const char *genoname) { return GENOPER_NOOPER; } 97 98 98 99 /**Validates a genotype. The purpose of this function is to validate … … 100 101 to introduce entirely new genes in place of an error. 101 102 \param geno input/output: genotype to be validated 103 \param genoname name of the genotype to be validated 102 104 \retval GENOPER_OK must be returned in any case ("did my best to validate")*/ 103 virtual int validate(char *&geno ) {return GENOPER_NOOPER;}105 virtual int validate(char *&geno, const char *genoname) { return GENOPER_NOOPER; } 104 106 105 107 /**Mutates a genotype. Mutation should always change something.
Note: See TracChangeset
for help on using the changeset viewer.