#include <TwoPointCrossover.h>
◆ TwoPointCrossover()
Constructs a TwoPointCrossover object with specified algorithm parameters.
- Parameters
-
params | The algorithm parameters including the crossover rate. |
◆ apply()
void TwoPointCrossover::apply |
( |
std::mt19937 & | generator | ) |
|
|
overridevirtual |
Performs the two-point crossover operation.
This method performs a two-point crossover on the two parent individuals to generate an offspring individual. Two crossover points are chosen randomly, and the genetic material from the two parents is combined to create the offspring.
- Parameters
-
generator | The random number generator used to determine the crossover points. |
Implements Operator.
◆ setIndividual()
void TwoPointCrossover::setIndividual |
( |
Individual & | individual | ) |
|
|
inlinevirtual |
Sets the individual for the operator.
This method is not used by the TwoPointCrossover operator.
- 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 TwoPointCrossover::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 by the TwoPointCrossover operator.
- Parameters
-
population | The vector of individuals in the population. |
selected | The vector of selected individuals. |
Implements Operator.
◆ crossoverRate
double TwoPointCrossover::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: