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()
|
void Population::doSelection()
|
||||||
{
|
{
|
||||||
assert(all_of(m_individuals.begin(), m_individuals.end(), [](auto& i){ return i.fitness.has_value(); }));
|
m_individuals = sortedIndividuals(move(m_individuals));
|
||||||
|
|
||||||
sort(m_individuals.begin(), m_individuals.end(), isFitter);
|
|
||||||
randomizeWorstChromosomes(m_individuals, m_individuals.size() / 2);
|
randomizeWorstChromosomes(m_individuals, m_individuals.size() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,3 +177,11 @@ vector<Individual> Population::chromosomesToIndividuals(
|
|||||||
|
|
||||||
return individuals;
|
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(
|
static std::vector<Individual> chromosomesToIndividuals(
|
||||||
std::vector<Chromosome> _chromosomes
|
std::vector<Chromosome> _chromosomes
|
||||||
);
|
);
|
||||||
|
static std::vector<Individual> sortedIndividuals(std::vector<Individual> _individuals);
|
||||||
|
|
||||||
Program m_program;
|
Program m_program;
|
||||||
std::vector<Individual> m_individuals;
|
std::vector<Individual> m_individuals;
|
||||||
|
Loading…
Reference in New Issue
Block a user