mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] AlgorithmRunner: Add support for ProgramCache
This commit is contained in:
@@ -31,9 +31,12 @@ using namespace solidity::phaser;
|
||||
void AlgorithmRunner::run(GeneticAlgorithm& _algorithm)
|
||||
{
|
||||
populationAutosave();
|
||||
cacheClear();
|
||||
|
||||
for (size_t round = 0; !m_options.maxRounds.has_value() || round < m_options.maxRounds.value(); ++round)
|
||||
{
|
||||
cacheStartRound(round + 1);
|
||||
|
||||
m_population = _algorithm.runNextRound(m_population);
|
||||
randomiseDuplicates();
|
||||
|
||||
@@ -66,6 +69,20 @@ void AlgorithmRunner::populationAutosave() const
|
||||
);
|
||||
}
|
||||
|
||||
void AlgorithmRunner::cacheClear()
|
||||
{
|
||||
for (auto& cache: m_programCaches)
|
||||
if (cache != nullptr)
|
||||
cache->clear();
|
||||
}
|
||||
|
||||
void AlgorithmRunner::cacheStartRound(size_t _roundNumber)
|
||||
{
|
||||
for (auto& cache: m_programCaches)
|
||||
if (cache != nullptr)
|
||||
cache->startRound(_roundNumber);
|
||||
}
|
||||
|
||||
void AlgorithmRunner::randomiseDuplicates()
|
||||
{
|
||||
if (m_options.randomiseDuplicates)
|
||||
|
||||
Reference in New Issue
Block a user