mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Add --rounds option
This commit is contained in:
parent
63f13c5b18
commit
d8e5f8f965
@ -185,6 +185,11 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription()
|
||||
("help", "Show help message and exit.")
|
||||
("input-file", po::value<string>()->required()->value_name("<PATH>"), "Input file.")
|
||||
("seed", po::value<uint32_t>()->value_name("<NUM>"), "Seed for the random number generator.")
|
||||
(
|
||||
"rounds",
|
||||
po::value<size_t>()->value_name("<NUM>"),
|
||||
"The number of rounds after which the algorithm should stop. (default=no limit)."
|
||||
)
|
||||
;
|
||||
keywordDescription.add(generalDescription);
|
||||
|
||||
@ -249,6 +254,13 @@ void Phaser::initialiseRNG(po::variables_map const& _arguments)
|
||||
cout << "Random seed: " << seed << endl;
|
||||
}
|
||||
|
||||
AlgorithmRunner::Options Phaser::buildAlgorithmRunnerOptions(po::variables_map const& _arguments)
|
||||
{
|
||||
return {
|
||||
_arguments.count("rounds") > 0 ? static_cast<optional<size_t>>(_arguments["rounds"].as<size_t>()) : nullopt
|
||||
};
|
||||
}
|
||||
|
||||
void Phaser::runAlgorithm(po::variables_map const& _arguments)
|
||||
{
|
||||
auto programOptions = ProgramFactory::Options::fromCommandLine(_arguments);
|
||||
@ -266,6 +278,6 @@ void Phaser::runAlgorithm(po::variables_map const& _arguments)
|
||||
PopulationFactory::MaxChromosomeLength
|
||||
);
|
||||
|
||||
AlgorithmRunner algorithmRunner(population, AlgorithmRunner::Options{}, cout);
|
||||
AlgorithmRunner algorithmRunner(population, buildAlgorithmRunnerOptions(_arguments), cout);
|
||||
algorithmRunner.run(*geneticAlgorithm);
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tools/yulPhaser/AlgorithmRunner.h>
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
|
||||
#include <istream>
|
||||
@ -147,6 +149,7 @@ private:
|
||||
static CommandLineDescription buildCommandLineDescription();
|
||||
static std::optional<boost::program_options::variables_map> parseCommandLine(int _argc, char** _argv);
|
||||
static void initialiseRNG(boost::program_options::variables_map const& _arguments);
|
||||
static AlgorithmRunner::Options buildAlgorithmRunnerOptions(boost::program_options::variables_map const& _arguments);
|
||||
|
||||
static void runAlgorithm(boost::program_options::variables_map const& _arguments);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user