mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Add --population-from-file option
This commit is contained in:
parent
ff99d25bc3
commit
04c7c56d84
@ -120,6 +120,9 @@ PopulationFactory::Options PopulationFactory::Options::fromCommandLine(po::varia
|
|||||||
_arguments.count("random-population") > 0 ?
|
_arguments.count("random-population") > 0 ?
|
||||||
_arguments["random-population"].as<vector<size_t>>() :
|
_arguments["random-population"].as<vector<size_t>>() :
|
||||||
vector<size_t>{},
|
vector<size_t>{},
|
||||||
|
_arguments.count("population-from-file") > 0 ?
|
||||||
|
_arguments["population-from-file"].as<vector<string>>() :
|
||||||
|
vector<string>{},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +142,9 @@ Population PopulationFactory::build(
|
|||||||
_fitnessMetric
|
_fitnessMetric
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (string const& populationFilePath: _options.populationFromFile)
|
||||||
|
population = move(population) + buildFromFile(populationFilePath, _fitnessMetric);
|
||||||
|
|
||||||
return population;
|
return population;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +173,14 @@ Population PopulationFactory::buildRandom(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Population PopulationFactory::buildFromFile(
|
||||||
|
string const& _filePath,
|
||||||
|
shared_ptr<FitnessMetric> _fitnessMetric
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return buildFromStrings(readLinesFromFile(_filePath), move(_fitnessMetric));
|
||||||
|
}
|
||||||
|
|
||||||
ProgramFactory::Options ProgramFactory::Options::fromCommandLine(po::variables_map const& _arguments)
|
ProgramFactory::Options ProgramFactory::Options::fromCommandLine(po::variables_map const& _arguments)
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
@ -261,6 +275,11 @@ Phaser::CommandLineDescription Phaser::buildCommandLineDescription()
|
|||||||
po::value<vector<size_t>>()->value_name("<SIZE>"),
|
po::value<vector<size_t>>()->value_name("<SIZE>"),
|
||||||
"The number of randomly generated chromosomes to be included in the initial population."
|
"The number of randomly generated chromosomes to be included in the initial population."
|
||||||
)
|
)
|
||||||
|
(
|
||||||
|
"population-from-file",
|
||||||
|
po::value<vector<string>>()->value_name("<FILE>"),
|
||||||
|
"A text file with a list of chromosomes (one per line) to be included in the initial population."
|
||||||
|
)
|
||||||
;
|
;
|
||||||
keywordDescription.add(populationDescription);
|
keywordDescription.add(populationDescription);
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::vector<std::string> population;
|
std::vector<std::string> population;
|
||||||
std::vector<size_t> randomPopulation;
|
std::vector<size_t> randomPopulation;
|
||||||
|
std::vector<std::string> populationFromFile;
|
||||||
|
|
||||||
static Options fromCommandLine(boost::program_options::variables_map const& _arguments);
|
static Options fromCommandLine(boost::program_options::variables_map const& _arguments);
|
||||||
};
|
};
|
||||||
@ -124,6 +125,10 @@ public:
|
|||||||
size_t _populationSize,
|
size_t _populationSize,
|
||||||
std::shared_ptr<FitnessMetric> _fitnessMetric
|
std::shared_ptr<FitnessMetric> _fitnessMetric
|
||||||
);
|
);
|
||||||
|
static Population buildFromFile(
|
||||||
|
std::string const& _filePath,
|
||||||
|
std::shared_ptr<FitnessMetric> _fitnessMetric
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user