diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index 5f0e3d87b..f02e942f7 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -96,11 +96,19 @@ unique_ptr GeneticAlgorithmFactory::build( } } +FitnessMetricFactory::Options FitnessMetricFactory::Options::fromCommandLine(po::variables_map const& _arguments) +{ + return { + _arguments["chromosome-repetitions"].as(), + }; +} + unique_ptr FitnessMetricFactory::build( + Options const& _options, Program _program ) { - return make_unique(move(_program), RepetitionCount); + return make_unique(move(_program), _options.chromosomeRepetitions); } Population PopulationFactory::build( @@ -190,6 +198,15 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription() ; keywordDescription.add(algorithmDescription); + po::options_description metricsDescription("METRICS", lineLength, minDescriptionLength); + metricsDescription.add_options() + ( + "chromosome-repetitions", + po::value()->value_name("")->default_value(1), + "Number of times to repeat the sequence optimisation steps represented by a chromosome." + ) + ; + keywordDescription.add(metricsDescription); po::positional_options_description positionalDescription; positionalDescription.add("input-file", 1); @@ -235,10 +252,11 @@ void Phaser::initialiseRNG(po::variables_map const& _arguments) void Phaser::runAlgorithm(po::variables_map const& _arguments) { auto programOptions = ProgramFactory::Options::fromCommandLine(_arguments); + auto metricOptions = FitnessMetricFactory::Options::fromCommandLine(_arguments); auto algorithmOptions = GeneticAlgorithmFactory::Options::fromCommandLine(_arguments); Program program = ProgramFactory::build(programOptions); - unique_ptr fitnessMetric = FitnessMetricFactory::build(move(program)); + unique_ptr fitnessMetric = FitnessMetricFactory::build(metricOptions, move(program)); Population population = PopulationFactory::build(move(fitnessMetric)); unique_ptr geneticAlgorithm = GeneticAlgorithmFactory::build( diff --git a/tools/yulPhaser/Phaser.h b/tools/yulPhaser/Phaser.h index 9ac6f81f0..20d9ace25 100644 --- a/tools/yulPhaser/Phaser.h +++ b/tools/yulPhaser/Phaser.h @@ -80,9 +80,15 @@ public: class FitnessMetricFactory { public: - static constexpr size_t RepetitionCount = 5; + struct Options + { + size_t chromosomeRepetitions; + + static Options fromCommandLine(boost::program_options::variables_map const& _arguments); + }; static std::unique_ptr build( + Options const& _options, Program _program ); };