Changeset 853 for cpp/frams/genetics/fB
- Timestamp:
- 02/15/19 03:09:31 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fB/fB_oper.cpp
r821 r853 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 8Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 301 301 } 302 302 } 303 /* no break */303 [[fallthrough]]; 304 304 case FB_INSERTION: 305 305 { … … 359 359 res.insert(res.end(), iters[3], tokenized.end()); 360 360 361 // SString first = line.substr(cuts[0], cuts[1] - cuts[0]);362 // SString second = line.substr(cuts[2], cuts[3] - cuts[2]);363 // SString result = line.substr(0, cuts[0]) + second +364 // line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]);361 // SString first = line.substr(cuts[0], cuts[1] - cuts[0]); 362 // SString second = line.substr(cuts[2], cuts[3] - cuts[2]); 363 // SString result = line.substr(0, cuts[0]) + second + 364 // line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]); 365 365 line = detokenizeSequence(&res); 366 366 chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.len(); … … 420 420 break; 421 421 } 422 // case FB_CROSSING_OVER:423 // {424 // // iterate through all genes of the first parent and assign them425 // // randomly to children426 // for (int i = 0; i < fB_GenoHelpers::geneCount(parent1); i++)427 // {428 // int start, end;429 // SString gene = fB_GenoHelpers::getGene(i, parent1, start, end);430 // if (randomN(2) == 0)431 // {432 // child1 += gene;433 // chg1 += 1.0f;434 // }435 // else436 // {437 // child2 += gene;438 // }439 // }440 // chg1 /= fB_GenoHelpers::geneCount(parent1);441 //442 // // do the same with second parent443 // for (int i = 0; i < fB_GenoHelpers::geneCount(parent2); i++)444 // {445 // int start, end;446 // SString gene = fB_GenoHelpers::getGene(i, parent2, start, end);447 // if (randomN(2) == 0)448 // {449 // child1 += gene;450 // }451 // else452 // {453 // child2 += gene;454 // chg2 += 1.0f;455 // }456 // }457 // chg2 /= fB_GenoHelpers::geneCount(parent2);458 // break;459 // }422 // case FB_CROSSING_OVER: 423 // { 424 // // iterate through all genes of the first parent and assign them 425 // // randomly to children 426 // for (int i = 0; i < fB_GenoHelpers::geneCount(parent1); i++) 427 // { 428 // int start, end; 429 // SString gene = fB_GenoHelpers::getGene(i, parent1, start, end); 430 // if (randomN(2) == 0) 431 // { 432 // child1 += gene; 433 // chg1 += 1.0f; 434 // } 435 // else 436 // { 437 // child2 += gene; 438 // } 439 // } 440 // chg1 /= fB_GenoHelpers::geneCount(parent1); 441 // 442 // // do the same with second parent 443 // for (int i = 0; i < fB_GenoHelpers::geneCount(parent2); i++) 444 // { 445 // int start, end; 446 // SString gene = fB_GenoHelpers::getGene(i, parent2, start, end); 447 // if (randomN(2) == 0) 448 // { 449 // child1 += gene; 450 // } 451 // else 452 // { 453 // child2 += gene; 454 // chg2 += 1.0f; 455 // } 456 // } 457 // chg2 /= fB_GenoHelpers::geneCount(parent2); 458 // break; 459 // } 460 460 case FB_CROSSING_OVER: 461 461 { 462 462 // get maximal count of genes from both parents 463 463 int maxgenecount = max(fB_GenoHelpers::geneCountNoNested(parent1), 464 464 fB_GenoHelpers::geneCountNoNested(parent2)); 465 465 466 466 // while there are genes in at least one genotype … … 472 472 // if both parents have genes available, then distribute them 473 473 if (i < fB_GenoHelpers::geneCountNoNested(parent1) && 474 474 i < fB_GenoHelpers::geneCountNoNested(parent2)) 475 475 { 476 476 if (randomN(2) == 0)
Note: See TracChangeset
for help on using the changeset viewer.