mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Population: Keep the individuals always sorted
This commit is contained in:
@@ -128,8 +128,8 @@ void Population::doMutation()
|
||||
|
||||
void Population::doSelection()
|
||||
{
|
||||
m_individuals = sortedIndividuals(move(m_individuals));
|
||||
randomizeWorstChromosomes(*m_fitnessMetric, m_individuals, m_individuals.size() / 2);
|
||||
m_individuals = sortedIndividuals(move(m_individuals));
|
||||
}
|
||||
|
||||
void Population::randomizeWorstChromosomes(
|
||||
|
||||
@@ -65,8 +65,7 @@ bool isFitter(Individual const& a, Individual const& b);
|
||||
* and selecting the best ones for the next round.
|
||||
*
|
||||
* An individual is a sequence of optimiser steps represented by a @a Chromosome instance.
|
||||
* Individuals are stored together with a fitness value that can be computed by the fitness metric
|
||||
* associated with the population.
|
||||
* Individuals are always ordered by their fitness (based on @_fitnessMetric and @a isFitter()).
|
||||
* The fitness is computed using the metric as soon as an individual is inserted into the population.
|
||||
*/
|
||||
class Population
|
||||
@@ -112,7 +111,7 @@ public:
|
||||
private:
|
||||
explicit Population(std::shared_ptr<FitnessMetric const> _fitnessMetric, std::vector<Individual> _individuals):
|
||||
m_fitnessMetric(std::move(_fitnessMetric)),
|
||||
m_individuals{std::move(_individuals)} {}
|
||||
m_individuals{sortedIndividuals(std::move(_individuals))} {}
|
||||
|
||||
void doMutation();
|
||||
void doSelection();
|
||||
|
||||
Reference in New Issue
Block a user