[yul-phaser] Change the design of crossover operators so that they produce a single chromosome rather than a pair

This commit is contained in:
Kamil Śliwak
2020-03-09 13:21:48 +01:00
parent a3e97108c5
commit 763bdb1d51
6 changed files with 74 additions and 65 deletions
+4 -10
View File
@@ -98,7 +98,7 @@ function<Mutation> phaser::alternativeMutations(
namespace
{
ChromosomePair buildChromosomesBySwappingParts(
Chromosome buildChromosomesBySwappingParts(
Chromosome const& _chromosome1,
Chromosome const& _chromosome2,
size_t _crossoverPoint
@@ -110,15 +110,9 @@ ChromosomePair buildChromosomesBySwappingParts(
auto begin1 = _chromosome1.optimisationSteps().begin();
auto begin2 = _chromosome2.optimisationSteps().begin();
return ChromosomePair(
Chromosome(
vector<string>(begin1, begin1 + _crossoverPoint) +
vector<string>(begin2 + _crossoverPoint, _chromosome2.optimisationSteps().end())
),
Chromosome(
vector<string>(begin2, begin2 + _crossoverPoint) +
vector<string>(begin1 + _crossoverPoint, _chromosome1.optimisationSteps().end())
)
return Chromosome(
vector<string>(begin1, begin1 + _crossoverPoint) +
vector<string>(begin2 + _crossoverPoint, _chromosome2.optimisationSteps().end())
);
}