|
GALib-Parallel
Header-only C++ library for parallel evolutionary algorithms
|
Represents a single candidate solution in the population. More...
#include <Individual.h>
Public Member Functions | |
| Individual () | |
| Default constructor. Initializes fitness to the maximum possible double value. | |
| Individual (std::size_t num_genes) | |
| Constructs an Individual with a specific number of genes. | |
| std::size_t | size () const |
| Returns the number of genes in the genotype. | |
| std::vector< GeneType > & | getGenotype () |
| Returns a reference to the genotype vector. | |
| const std::vector< GeneType > & | getGenotype () const |
| Returns a constant reference to the genotype vector. | |
| void | setGenotype (const std::vector< GeneType > &new_genotype) |
| Sets the genotype by copying. | |
| void | setGenotype (std::vector< GeneType > &&new_genotype) noexcept |
| Sets the genotype by moving. | |
| double | getFitness () const |
| Gets the current fitness score. | |
| void | setFitness (double new_fitness) |
| Sets a new fitness score. | |
| auto | operator<=> (const Individual &other) const |
| Three-way comparison operator based on fitness (for minimization). | |
| bool | operator== (const Individual &other) const |
| Equality operator based on fitness. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Individual &ind) |
| Streams a summary of the individual (fitness and first few genes). | |
Represents a single candidate solution in the population.
An Individual consists of a genotype (a vector of genes) and a fitness score. It supports comparison operators for sorting based on fitness (minimization).
| GeneType | The type of the genes (default: double). |
Definition at line 23 of file Individual.h.
|
inline |
Default constructor. Initializes fitness to the maximum possible double value.
Definition at line 34 of file Individual.h.
|
inlineexplicit |
Constructs an Individual with a specific number of genes.
| num_genes | Number of genes in the genotype. |
Definition at line 40 of file Individual.h.
|
inline |
Gets the current fitness score.
Definition at line 77 of file Individual.h.
Referenced by galib::internal::MpiCommunicator< GeneType >::allReduceBest(), galib::TournamentSelection< GeneType >::select(), galib::BestNeighborSelection< GeneType >::select(), and galib::internal::BinarySerializer< GeneType >::serialize().
|
inline |
Returns a reference to the genotype vector.
Definition at line 53 of file Individual.h.
Referenced by galib::ArithmeticCrossover< GeneType >::crossover(), galib::SinglePointCrossover< GeneType >::crossover(), galib::UniformCrossover< GeneType >::crossover(), galib::BoundaryMutation< GeneType >::mutate(), galib::GaussianMutation< GeneType >::mutate(), galib::UniformMutation< GeneType >::mutate(), galib::DifferentialEvolutionGA< GeneType >::run(), and galib::internal::BinarySerializer< GeneType >::serialize().
|
inline |
Returns a constant reference to the genotype vector.
Definition at line 59 of file Individual.h.
|
inline |
Three-way comparison operator based on fitness (for minimization).
| other | The individual to compare against. |
Definition at line 89 of file Individual.h.
|
inline |
Equality operator based on fitness.
| other | The individual to compare against. |
Definition at line 97 of file Individual.h.
|
inline |
Sets a new fitness score.
| new_fitness | The new fitness value. |
Definition at line 83 of file Individual.h.
Referenced by galib::internal::BinarySerializer< GeneType >::deserialize(), galib::internal::BinarySerializer< GeneType >::deserialize(), and galib::DifferentialEvolutionGA< GeneType >::run().
|
inline |
Sets the genotype by copying.
| new_genotype | The new genotype vector. |
Definition at line 65 of file Individual.h.
Referenced by galib::internal::BinarySerializer< GeneType >::deserialize(), and galib::internal::BinarySerializer< GeneType >::deserialize().
|
inlinenoexcept |
Sets the genotype by moving.
| new_genotype | The new genotype vector. |
Definition at line 71 of file Individual.h.
|
inline |
Returns the number of genes in the genotype.
Definition at line 47 of file Individual.h.
Referenced by galib::ArithmeticCrossover< GeneType >::crossover(), and galib::UniformCrossover< GeneType >::crossover().
|
friend |
Streams a summary of the individual (fitness and first few genes).
Definition at line 104 of file Individual.h.