62 template <
typename GeneArray,
typename Compare = std::less<GeneArray>>
65 template <
typename GeneArray,
typename Compare,
typename Gene>
72 std::vector<std::shared_ptr<GeneArray>>
children;
86 children.assign(size,
nullptr);
105 children.reserve(size);
107 for (
size_t i = 0; i < size; i++)
109 GeneArray *ptr =
new GeneArray(*geneArray);
112 std::random_shuffle(ptr->begin(), ptr->end());
114 children.emplace_back(ptr);
125 std::shared_ptr<GeneArray> best = children[0];
127 for (
size_t i = 1; i < children.size(); i++)
128 if (Compare()(*children[i], *best) ==
true)
auto fitTest() const -> std::shared_ptr< GeneArray >
Test fitness of each GeneArray in the population.
GAPopulation(size_t size)
Private Constructor with population.
A population of a generation in G.A.
A genetic algorithm class.
std::vector< std::shared_ptr< GeneArray > > children
Genes representing the population.
GAPopulation(std::shared_ptr< GeneArray > geneArray, size_t size)
Construct from a GeneArray and size of the population.
Top level namespace of products built from samchon.