mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Population: Extract sorting from doSelection() into sortIndividuals() in Population class
This commit is contained in:
parent
41f36f421d
commit
85074e7a8a
@ -148,9 +148,7 @@ void Population::doEvaluation()
|
||||
|
||||
void Population::doSelection()
|
||||
{
|
||||
assert(all_of(m_individuals.begin(), m_individuals.end(), [](auto& i){ return i.fitness.has_value(); }));
|
||||
|
||||
sort(m_individuals.begin(), m_individuals.end(), isFitter);
|
||||
m_individuals = sortedIndividuals(move(m_individuals));
|
||||
randomizeWorstChromosomes(m_individuals, m_individuals.size() / 2);
|
||||
}
|
||||
|
||||
@ -179,3 +177,11 @@ vector<Individual> Population::chromosomesToIndividuals(
|
||||
|
||||
return individuals;
|
||||
}
|
||||
|
||||
vector<Individual> Population::sortedIndividuals(vector<Individual> _individuals)
|
||||
{
|
||||
assert(all_of(_individuals.begin(), _individuals.end(), [](auto& i){ return i.fitness.has_value(); }));
|
||||
|
||||
sort(_individuals.begin(), _individuals.end(), isFitter);
|
||||
return _individuals;
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ private:
|
||||
static std::vector<Individual> chromosomesToIndividuals(
|
||||
std::vector<Chromosome> _chromosomes
|
||||
);
|
||||
static std::vector<Individual> sortedIndividuals(std::vector<Individual> _individuals);
|
||||
|
||||
Program m_program;
|
||||
std::vector<Individual> m_individuals;
|
||||
|
Loading…
Reference in New Issue
Block a user