[yul-phaser] Common: Add geneSubstitution() mutation

This commit is contained in:
Kamil Śliwak
2020-03-09 13:21:48 +01:00
parent c941eaf5d6
commit 92b54d83a3
3 changed files with 28 additions and 0 deletions
+12
View File
@@ -31,6 +31,18 @@ function<Mutation> phaser::test::wholeChromosomeReplacement(Chromosome _newChrom
return [_newChromosome = move(_newChromosome)](Chromosome const&) { return _newChromosome; };
}
function<Mutation> phaser::test::geneSubstitution(size_t _geneIndex, string _geneValue)
{
return [=](Chromosome const& _chromosome)
{
vector<string> newGenes = _chromosome.optimisationSteps();
assert(_geneIndex < newGenes.size());
newGenes[_geneIndex] = _geneValue;
return Chromosome(newGenes);
};
}
vector<size_t> phaser::test::chromosomeLengths(Population const& _population)
{
vector<size_t> lengths;