mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] main: Switch from using Population::run() to RandomAlgorithm
This commit is contained in:
parent
e1b8b64f05
commit
4aac7d1673
@ -18,6 +18,7 @@
|
|||||||
#include <tools/yulPhaser/Exceptions.h>
|
#include <tools/yulPhaser/Exceptions.h>
|
||||||
#include <tools/yulPhaser/Population.h>
|
#include <tools/yulPhaser/Population.h>
|
||||||
#include <tools/yulPhaser/FitnessMetrics.h>
|
#include <tools/yulPhaser/FitnessMetrics.h>
|
||||||
|
#include <tools/yulPhaser/GeneticAlgorithms.h>
|
||||||
#include <tools/yulPhaser/Program.h>
|
#include <tools/yulPhaser/Program.h>
|
||||||
#include <tools/yulPhaser/SimulationRNG.h>
|
#include <tools/yulPhaser/SimulationRNG.h>
|
||||||
|
|
||||||
@ -29,7 +30,6 @@
|
|||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <functional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -71,14 +71,26 @@ CharStream loadSource(string const& _sourcePath)
|
|||||||
|
|
||||||
void runAlgorithm(string const& _sourcePath)
|
void runAlgorithm(string const& _sourcePath)
|
||||||
{
|
{
|
||||||
|
constexpr size_t minChromosomeLength = 12;
|
||||||
|
constexpr size_t maxChromosomeLength = 30;
|
||||||
|
|
||||||
CharStream sourceCode = loadSource(_sourcePath);
|
CharStream sourceCode = loadSource(_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,
|
10,
|
||||||
bind(Population::binomialChromosomeLength, Population::MaxChromosomeLength)
|
minChromosomeLength,
|
||||||
|
maxChromosomeLength
|
||||||
);
|
);
|
||||||
population.run(nullopt, cout);
|
RandomAlgorithm(
|
||||||
|
population,
|
||||||
|
cout,
|
||||||
|
{
|
||||||
|
/* elitePoolSize = */ 0.5,
|
||||||
|
/* minChromosomeLength = */ minChromosomeLength,
|
||||||
|
/* maxChromosomeLength = */ maxChromosomeLength,
|
||||||
|
}
|
||||||
|
).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandLineParsingResult parseCommandLine(int argc, char** argv)
|
CommandLineParsingResult parseCommandLine(int argc, char** argv)
|
||||||
|
Loading…
Reference in New Issue
Block a user