public void MixChromosomesTest_EdgeChromosomes_NormalPower_ShouldPass(int pow) { var rd = DefaultResearchParameters.GetDefaultResearchDefinitions(pow); var highestChromosome = DefaultResearchParameters.GetHigherChromosome(rd); var lowestChromosome = DefaultResearchParameters.GetLowestChromosome(rd); _testOutputHelper.WriteLine(highestChromosome.GeneInBinary()); _testOutputHelper.WriteLine(lowestChromosome.GeneInBinary()); var output = PostSelection.MixChromosomes(highestChromosome, lowestChromosome, 1); foreach (var chromosome in output) { Assert.Contains("1", chromosome.GeneInBinary()); Assert.Contains("0", chromosome.GeneInBinary()); _testOutputHelper.WriteLine(chromosome.GeneInBinary()); } }
public void MixChromosomesTest_TryFindCrossingPointOnEndAllel_ShouldPass() { var rd = DefaultResearchParameters.GetDefaultResearchDefinitions(4); var highestChromosome = DefaultResearchParameters.GetHigherChromosome(rd); var lowestChromosome = DefaultResearchParameters.GetLowestChromosome(rd); var output = new List <Chromosome>(); var found = false; for (int i = 0; i < 1000; i++) { output = PostSelection.MixChromosomes(highestChromosome, lowestChromosome, 1); if (output.All(x => x.GeneInBinary() != "1110")) { continue; } found = true; break; } _testOutputHelper.WriteLine(output[0].GeneInBinary()); _testOutputHelper.WriteLine(output[1].GeneInBinary()); Assert.True(found); }