Changeset 534 for cpp/frams/genetics
- Timestamp:
- 07/20/16 01:17:14 (8 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f1/conv_f1.cpp
r528 r534 111 111 builder.model.close(); // model is ready to use now 112 112 if (map) builder.model.getCurrentToF0Map(*map); // generate f1-to-f0 conversion map 113 return builder.model.getF0Geno().getGene ();113 return builder.model.getF0Geno().getGenes(); 114 114 } 115 115 -
cpp/frams/genetics/f4/conv_f4.cpp
r528 r534 32 32 // generate to-f0 conversion map 33 33 model->getCurrentToF0Map(*map); 34 SString out = model->getF0Geno().getGene ();34 SString out = model->getF0Geno().getGenes(); 35 35 delete model; 36 36 return out; -
cpp/frams/genetics/f9/conv_f9.cpp
r319 r534 56 56 if (map != NULL) 57 57 m.getCurrentToF0Map(*map); 58 return m.getF0Geno().getGene ();58 return m.getF0Geno().getGenes(); 59 59 } 60 60 -
cpp/frams/genetics/genman.cpp
r532 r534 198 198 int GenMan::testValidity(Geno &g, bool &canvalidate) 199 199 { 200 SString ggs=g.getGene ();200 SString ggs=g.getGenes(); 201 201 const char *gg = ggs.c_str(); 202 202 GenoOperators *gf = getOper_f(g.getFormat()); … … 210 210 if (check1 == GENOPER_NOOPER) //disaster: cannot check because there is no check operator 211 211 { 212 g.setGene Only(g2); free(g2); canvalidate = false; return GENOPER_NOOPER;212 g.setGenesAssumingSameFormat(g2); free(g2); canvalidate = false; return GENOPER_NOOPER; 213 213 } 214 214 int check2 = gf->checkValidity(g2, "validated"); 215 if (check2 == GENOPER_OK) g.setGene Only(g2);215 if (check2 == GENOPER_OK) g.setGenesAssumingSameFormat(g2); 216 216 free(g2); 217 217 if (check2 == GENOPER_OK) return check1; … … 237 237 if (gf == NULL) 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 char *g2 = strdup(geny.getGene ().c_str()); //copy for validation239 char *g2 = strdup(geny.getGenes().c_str()); //copy for validation 240 240 int res = gf->validate(g2, geny.getName().c_str()); 241 241 SString sg2 = g2; … … 263 263 while (!ok) 264 264 { 265 char *gn = strdup(gv.getGene ().c_str()); //copy for mutation265 char *gn = strdup(gv.getGenes().c_str()); //copy for mutation 266 266 chg = 0; 267 267 if (gf->mutate(gn, chg, method) == GENOPER_OK) … … 284 284 if (!ok && (count - pcount > 100)) 285 285 { 286 logPrintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene ().c_str());286 logPrintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGenes().c_str()); 287 287 return Geno("", -1, "", "GENOPER_OPFAIL: Mutate() tried 100x and failed"); 288 288 } 289 289 } 290 290 mutchg += chg; 291 if (history) saveLink(g.getGene ().c_str(), "", gv.getGene().c_str(), chg);291 if (history) saveLink(g.getGenes().c_str(), "", gv.getGenes().c_str(), chg); 292 292 SString mutinfo; 293 293 if (extmutinfo == 0) mutinfo = SString::sprintf("%.2f%% mutation of '%s'", 100 * chg, g.getName().c_str()); else … … 324 324 { 325 325 float chg1, chg2; 326 char *g1n = strdup(g1.getGene ().c_str()); //copy for crossover327 char *g2n = strdup(g2.getGene ().c_str()); //copy for crossover326 char *g1n = strdup(g1.getGenes().c_str()); //copy for crossover 327 char *g2n = strdup(g2.getGenes().c_str()); //copy for crossover 328 328 chg1 = chg2 = 0; 329 329 if (gf->crossOver(g1n, g2n, chg1, chg2) == GENOPER_OK) … … 351 351 if (!ok && (count - pcount > 100)) 352 352 { 353 logPrintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene ().c_str(), g2.getGene().c_str());353 logPrintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGenes().c_str(), g2.getGenes().c_str()); 354 354 return Geno("", -1, "", "GENOPER_OPFAIL: CrossOver() tried 100x and failed"); 355 355 } … … 357 357 // result in g1v 358 358 xochg += chg; 359 if (history) saveLink(g1.getGene ().c_str(), g2.getGene().c_str(), g1v.getGene().c_str(), chg);359 if (history) saveLink(g1.getGenes().c_str(), g2.getGenes().c_str(), g1v.getGenes().c_str(), chg); 360 360 SString xoinfo = SString::sprintf("Crossing over of '%s' (%.2f%%) and '%s' (%.2f%%)", 361 361 g1.getName().c_str(), 100 * chg, g2.getName().c_str(), 100 * (1 - chg)); … … 369 369 if (format != g2.getFormat()) return GENOPER_NOOPER; 370 370 GenoOperators *gf = getOper_f(format); 371 if (!gf) return GENOPER_NOOPER; else return gf->similarity(g1.getGene ().c_str(), g2.getGene().c_str());371 if (!gf) return GENOPER_NOOPER; else return gf->similarity(g1.getGenes().c_str(), g2.getGenes().c_str()); 372 372 } 373 373 … … 380 380 GenoOperators *gf = getOper_f(format); 381 381 if (!gf) return GENSTYLE_CS(0, 0); //black & valid 382 else return gf->style(G->getGene ().c_str(), pos);382 else return gf->style(G->getGenes().c_str(), pos); 383 383 } 384 384 … … 399 399 } 400 400 GenoOperators *gf = getOper_f(format); 401 SString geny=G->getGene ();401 SString geny=G->getGenes(); 402 402 for (unsigned int pos = 0; pos < strlen(g); pos++) 403 403 { -
cpp/frams/genetics/geno.cpp
r530 r534 32 32 name = genname; 33 33 txt = comment; 34 setGene AndFormat(genstring,genformat);35 } 36 37 void Geno::setGene AndFormat(const SString& genstring, char genformat)34 setGenesAndFormat(genstring,genformat); 35 } 36 37 void Geno::setGenesAndFormat(const SString& genstring, char genformat) 38 38 { 39 39 mapinshift = 0; … … 151 151 } 152 152 153 void Geno::setGene Only(const SString& g)153 void Geno::setGenesAssumingSameFormat(const SString& g) 154 154 { 155 155 gen = g; … … 174 174 } 175 175 176 SString Geno::getGene AndFormat(void) const176 SString Geno::getGenesAndFormat(void) const 177 177 { 178 178 SString out; … … 211 211 } 212 212 213 SString Geno::getGene (void) const { return gen; }213 SString Geno::getGenes(void) const { return gen; } 214 214 SString Geno::getName(void) const { return name; } 215 215 char Geno::getFormat(void) const { return format; } -
cpp/frams/genetics/geno.h
r530 r534 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2016 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 85 85 86 86 /// return string representation, with format comment at the beginning 87 SString getGene AndFormat(void) const;87 SString getGenesAndFormat(void) const; 88 88 89 89 void setString(const SString& genewithcomments); 90 90 91 /** @param genformat=-1 -> take from genstring comment (like the constructor) else specify the valid format in genformat and pure gene in genstring*/92 void setGene AndFormat(const SString& genstring, char genformat=-1);93 /** g must be pure gene , without format. for the standard behavior use setGeneAndFormat() */94 void setGene Only(const SString& g);95 SString getGene (void) const;91 /** @param genformat=-1 -> detect genotype format from genstring comment (like the constructor does), else specify the valid format in genformat and pure genes in genstring. */ 92 void setGenesAndFormat(const SString& genstring, char genformat=-1); 93 /** g must be pure genes, without format. For the standard behavior use setGenesAndFormat() */ 94 void setGenesAssumingSameFormat(const SString& g); 95 SString getGenes(void) const; 96 96 97 97 SString getName(void) const; -
cpp/frams/genetics/genoconv.cpp
r483 r534 181 181 char *t = path; 182 182 SString tmp; 183 tmp = in.getGene ();183 tmp = in.getGenes(); 184 184 MultiMap lastmap, tmpmap; 185 185 int firstmap = 1;
Note: See TracChangeset
for help on using the changeset viewer.