#include <UniformCrossover.h>
◆ UniformCrossover()
Constructs a UniformCrossover object with specified algorithm parameters.
- Parameters
-
params | The algorithm parameters including the crossover rate. |
◆ apply()
void UniformCrossover::apply |
( |
std::mt19937 & | generator | ) |
|
|
overridevirtual |
Performs the uniform crossover operation.
This method performs a uniform crossover on the two parent individuals to generate an offspring individual. Each gene in the offspring is chosen randomly from one of the two parents.
- Parameters
-
generator | The random number generator used to determine gene selection. |
Implements Operator.
◆ setIndividual()
void UniformCrossover::setIndividual |
( |
Individual & | individual | ) |
|
|
inlinevirtual |
Sets the individual for the selection operation.
This method is not used in the UniformCrossover class.
- Parameters
-
individual | The individual to be set. |
Implements Operator.
◆ setParents()
Sets the parents and offspring for the crossover operation.
- Parameters
-
offspring | The offspring individual to be generated. |
parent1 | The first parent individual. |
parent2 | The second parent individual. |
Implements Operator.
◆ setPopulation()
void UniformCrossover::setPopulation |
( |
const std::vector< Individual > & | population, |
|
|
std::vector< Individual > & | selected ) |
|
inlinevirtual |
Sets the population and selected vectors for the selection operation.
This method is not used in the UniformCrossover class.
- Parameters
-
population | The vector of individuals in the population. |
selected | The vector of selected individuals. |
Implements Operator.
◆ crossoverRate
double UniformCrossover::crossoverRate |
|
private |
The crossover rate used to determine if crossover should occur
◆ offspring
Pointer to the offspring individual
◆ parent1
Pointer to the first parent individual
◆ parent2
Pointer to the second parent individual
The documentation for this class was generated from the following files: