[yul-phaser] main: Change the number of chromosomes preserved in every round of the algorithm to 1

This commit is contained in:
Kamil Śliwak 2020-02-05 19:25:15 +01:00
parent 4aac7d1673
commit 3aaca31c31

View File

@ -71,6 +71,7 @@ CharStream loadSource(string const& _sourcePath)
void runAlgorithm(string const& _sourcePath) void runAlgorithm(string const& _sourcePath)
{ {
constexpr size_t populationSize = 10;
constexpr size_t minChromosomeLength = 12; constexpr size_t minChromosomeLength = 12;
constexpr size_t maxChromosomeLength = 30; constexpr size_t maxChromosomeLength = 30;
@ -78,7 +79,7 @@ void runAlgorithm(string const& _sourcePath)
shared_ptr<FitnessMetric> fitnessMetric = make_shared<ProgramSize>(Program::load(sourceCode), 5); shared_ptr<FitnessMetric> fitnessMetric = make_shared<ProgramSize>(Program::load(sourceCode), 5);
auto population = Population::makeRandom( auto population = Population::makeRandom(
fitnessMetric, fitnessMetric,
10, populationSize,
minChromosomeLength, minChromosomeLength,
maxChromosomeLength maxChromosomeLength
); );
@ -86,7 +87,7 @@ void runAlgorithm(string const& _sourcePath)
population, population,
cout, cout,
{ {
/* elitePoolSize = */ 0.5, /* elitePoolSize = */ 1.0 / populationSize,
/* minChromosomeLength = */ minChromosomeLength, /* minChromosomeLength = */ minChromosomeLength,
/* maxChromosomeLength = */ maxChromosomeLength, /* maxChromosomeLength = */ maxChromosomeLength,
} }