mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Population: Add select() method
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <tools/yulPhaser/Population.h>
|
||||
|
||||
#include <tools/yulPhaser/Selections.h>
|
||||
|
||||
#include <libsolutil/CommonData.h>
|
||||
#include <libsolutil/CommonIO.h>
|
||||
@@ -95,6 +96,15 @@ void Population::run(optional<size_t> _numRounds, ostream& _outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
Population Population::select(Selection const& _selection) const
|
||||
{
|
||||
vector<Individual> selectedIndividuals;
|
||||
for (size_t i: _selection.materialise(m_individuals.size()))
|
||||
selectedIndividuals.emplace_back(m_individuals[i]);
|
||||
|
||||
return Population(m_fitnessMetric, selectedIndividuals);
|
||||
}
|
||||
|
||||
Population operator+(Population _a, Population _b)
|
||||
{
|
||||
// This operator is meant to be used only with populations sharing the same metric (and, to make
|
||||
|
||||
Reference in New Issue
Block a user