Samchon Framework for CPP
1.0.0
|
A population in a generation in G.A. More...
#include <GAPopulation.hpp>
Public Member Functions | |
GAPopulation (std::shared_ptr< GeneArray > geneArray, size_t size) | |
Construct from a GeneArray and size of the population. More... | |
auto | fitTest () const -> std::shared_ptr< GeneArray > |
Test fitness of each GeneArray in the population. More... | |
Private Member Functions | |
GAPopulation (size_t size) | |
Private Constructor with population. More... | |
Private Attributes | |
std::vector< std::shared_ptr< GeneArray > > | children |
Genes representing the population. More... | |
A population in a generation in G.A.
GeneArray |
An array(std::vector) containing genes as elments; sequnce listing
The GeneArray must be a type of std::vector.
Compare | A comparison class (or struct) returns whether left gene is more optimal. Default template parameter of Compare is std::less<GeneArray>. It means to compare two std::vector (GeneArray must be a std::vector). Thus, you've to keep follwing rules.
|
If you don't want to follow the rules or want a custom comparison class, you have to realize a comparison class. The following code is an example realizing the comparison class.
GAPopulation is a class representing population of candidate genes(sequence listing) having an array of GeneArray as a member. GAPopulation also manages initial set of genes and handles fitting test direclty by the method fitTest.
The success of evolution of genetic algorithm is depend on the GAPopulation's initial set and fitting test. (GeneArray and Compare.)
Be careful for the mistakes of direction or position of Compare.
Most of logical errors failed to access optimal solution are occured from those mistakes.
Definition at line 57 of file GAPopulation.hpp.
|
inlineprivate |
Private Constructor with population.
Private constructor of GAPopulation does not create children (candidate genes) but fills only nullptr repeatedly following the size.
The private constructor is only for and handled by GeneticAlgorithm.
size | Size of the population |
Definition at line 78 of file GAPopulation.hpp.
|
inline |
Construct from a GeneArray and size of the population.
Constructor with initial set of genes and size of the population.
The public constructor creates GeneArray(s) as population (size) having shuffled genes which are came from the initial set of genes (geneArray).
geneArray | An initial sequence listing |
size | The size of population to have as children |
Definition at line 97 of file GAPopulation.hpp.
|
inline |
Test fitness of each GeneArray in the population.
Definition at line 117 of file GAPopulation.hpp.
Referenced by samchon::library::GeneticAlgorithm< GeneArray, Compare >::selection().
|
private |
Genes representing the population.
Definition at line 66 of file GAPopulation.hpp.
Referenced by samchon::library::GeneticAlgorithm< GeneArray, Compare >::selection().