Changeset 348 for cpp/frams/genetics/genman.cpp
- Timestamp:
- 04/09/15 23:51:28 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genman.cpp
r344 r348 199 199 { 200 200 SString ggs=g.getGene(); 201 const char *gg = ggs ;201 const char *gg = ggs.c_str(); 202 202 GenoOperators *gf = getOper_f(g.getFormat()); 203 203 int 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() ); //copy for validation239 char *g2 = strdup(geny.getGene().c_str()); //copy for validation 240 240 int res = gf->validate(g2); 241 241 SString sg2 = g2; … … 263 263 while (!ok) 264 264 { 265 char *gn = strdup(gv.getGene() ); //copy for mutation265 char *gn = strdup(gv.getGene().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 FMprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", (const char*)g.getGene());286 FMprintf("GenMan", "Mutate", 2, "Tried 100x and failed: %s", g.getGene().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( (const char*)g.getGene(), "", (const char*)gv.getGene(), chg);291 if (history) saveLink(g.getGene().c_str(), "", gv.getGene().c_str(), chg); 292 292 SString mutinfo; 293 if (extmutinfo == 0) mutinfo = SString::sprintf("%.2f%% mutation of '%s'", 100 * chg, (const char*)g.getName()); else294 if (extmutinfo == 1) mutinfo = SString::sprintf("%.2f%% mutation(%d) of '%s'", 100 * chg, method, (const char*)g.getName()); else295 mutinfo = SString::sprintf("%.2f%% mutation(%s) of '%s'", 100 * chg, gf->mutation_method_names ? gf->mutation_method_names[method] : "unspecified method name", (const char*)g.getName());293 if (extmutinfo == 0) mutinfo = SString::sprintf("%.2f%% mutation of '%s'", 100 * chg, g.getName().c_str()); else 294 if (extmutinfo == 1) mutinfo = SString::sprintf("%.2f%% mutation(%d) of '%s'", 100 * chg, method, g.getName().c_str()); else 295 mutinfo = SString::sprintf("%.2f%% mutation(%s) of '%s'", 100 * chg, gf->mutation_method_names ? gf->mutation_method_names[method] : "unspecified method name", g.getName().c_str()); 296 296 gv.setComment(mutinfo); 297 297 return gv; … … 324 324 { 325 325 float chg1, chg2; 326 char *g1n = strdup(g1.getGene() ); //copy for crossover327 char *g2n = strdup(g2.getGene() ); //copy for crossover326 char *g1n = strdup(g1.getGene().c_str()); //copy for crossover 327 char *g2n = strdup(g2.getGene().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 FMprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", (const char*)g1.getGene(), (const char*)g2.getGene());353 FMprintf("GenMan", "CrossOver", 2, "Tried 100x and failed: %s and %s", g1.getGene().c_str(), g2.getGene().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( (const char*)g1.getGene(), (const char*)g2.getGene(), (const char*)g1v.getGene(), chg);359 if (history) saveLink(g1.getGene().c_str(), g2.getGene().c_str(), g1v.getGene().c_str(), chg); 360 360 SString xoinfo = SString::sprintf("Crossing over of '%s' (%.2f%%) and '%s' (%.2f%%)", 361 (const char*)g1.getName(), 100 * chg, (const char*)g2.getName(), 100 * (1 - chg));361 g1.getName().c_str(), 100 * chg, g2.getName().c_str(), 100 * (1 - chg)); 362 362 g1v.setComment(xoinfo); 363 363 return g1v; … … 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() , g2.getGene());371 if (!gf) return GENOPER_NOOPER; else return gf->similarity(g1.getGene().c_str(), g2.getGene().c_str()); 372 372 } 373 373 … … 378 378 GenoOperators *gf = getOper_f(G.getFormat()); 379 379 if (!gf) return GENSTYLE_CS(0, 0); //black & valid 380 else return gf->style(G.getGene() , pos);380 else return gf->style(G.getGene().c_str(), pos); 381 381 } 382 382 … … 391 391 if (posmapped == -1) styletab[pos] = GENSTYLE_COMMENT; 392 392 else if (!gf) styletab[pos] = GENSTYLE_CS(0, 0); //black & valid 393 else styletab[pos] = gf->style(geny , posmapped);393 else styletab[pos] = gf->style(geny.c_str(), posmapped); 394 394 } 395 395 } … … 448 448 void GenMan::p_htmlize(ExtValue *args, ExtValue *ret) 449 449 { 450 ret->setString(HTMLize(args->getString() ));450 ret->setString(HTMLize(args->getString().c_str())); 451 451 } 452 452 453 453 void GenMan::p_htmlizeshort(ExtValue *args, ExtValue *ret) 454 454 { 455 ret->setString(HTMLizeShort(args->getString() ));455 ret->setString(HTMLizeShort(args->getString().c_str())); 456 456 } 457 457
Note: See TracChangeset
for help on using the changeset viewer.