mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Population: Add combine()
This commit is contained in:
parent
ef8d0888af
commit
8c86a4983d
@ -364,6 +364,14 @@ BOOST_FIXTURE_TEST_CASE(symmetricCrossoverWithRemainder_should_return_empty_popu
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(combine_should_add_two_populations_from_a_pair, PopulationFixture)
|
||||
{
|
||||
Population population1(m_fitnessMetric, {Chromosome("aa"), Chromosome("hh")});
|
||||
Population population2(m_fitnessMetric, {Chromosome("gg"), Chromosome("cc")});
|
||||
|
||||
BOOST_TEST(Population::combine({population1, population2}) == population1 + population2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
@ -163,6 +163,11 @@ Population operator+(Population _a, Population _b)
|
||||
|
||||
}
|
||||
|
||||
Population Population::combine(std::tuple<Population, Population> _populationPair)
|
||||
{
|
||||
return get<0>(_populationPair) + get<1>(_populationPair);
|
||||
}
|
||||
|
||||
bool Population::operator==(Population const& _other) const
|
||||
{
|
||||
// We consider populations identical only if they share the same exact instance of the metric.
|
||||
|
@ -106,6 +106,7 @@ public:
|
||||
) const;
|
||||
|
||||
friend Population operator+(Population _a, Population _b);
|
||||
static Population combine(std::tuple<Population, Population> _populationPair);
|
||||
|
||||
std::shared_ptr<FitnessMetric> fitnessMetric() { return m_fitnessMetric; }
|
||||
std::vector<Individual> const& individuals() const { return m_individuals; }
|
||||
|
Loading…
Reference in New Issue
Block a user