GERARDIUM RUSH - MINERAL CIRCUIT OPTIMIZER v1.0.0
"A powerful tool designed to optimize circuit configurations using advanced genetic algorithms." - by Pentlandite
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
TwoPointCrossover Class Reference

#include <TwoPointCrossover.h>

Inheritance diagram for TwoPointCrossover:
Inheritance graph
Collaboration diagram for TwoPointCrossover:
Collaboration graph

Public Member Functions

 TwoPointCrossover (const Algorithm_Parameters &params)
 Constructs a TwoPointCrossover object with specified algorithm parameters.
 
void setParents (Individual &offspring, const Individual &parent1, const Individual &parent2) override
 Sets the parents and offspring for the crossover operation.
 
void setPopulation (const std::vector< Individual > &population, std::vector< Individual > &selected)
 Sets the population and selected vectors for the selection operation.
 
void setIndividual (Individual &individual)
 Sets the individual for the operator.
 
void apply (std::mt19937 &generator) override
 Performs the two-point crossover operation.
 
- Public Member Functions inherited from Operator
virtual ~Operator ()=default
 Virtual destructor for the Operator class.
 

Private Attributes

Individualoffspring
 
const Individualparent1
 
const Individualparent2
 
double crossoverRate
 

Constructor & Destructor Documentation

◆ TwoPointCrossover()

TwoPointCrossover::TwoPointCrossover ( const Algorithm_Parameters & params)

Constructs a TwoPointCrossover object with specified algorithm parameters.

Parameters
paramsThe algorithm parameters including the crossover rate.

Member Function Documentation

◆ 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
generatorThe 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
individualThe individual to be set.

Implements Operator.

◆ setParents()

void TwoPointCrossover::setParents ( Individual & offspring,
const Individual & parent1,
const Individual & parent2 )
overridevirtual

Sets the parents and offspring for the crossover operation.

Parameters
offspringThe offspring individual to be generated.
parent1The first parent individual.
parent2The 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
populationThe vector of individuals in the population.
selectedThe vector of selected individuals.

Implements Operator.

Field Documentation

◆ crossoverRate

double TwoPointCrossover::crossoverRate
private

The crossover rate used to determine if crossover should occur

◆ offspring

Individual* TwoPointCrossover::offspring
private

Pointer to the offspring individual

◆ parent1

const Individual* TwoPointCrossover::parent1
private

Pointer to the first parent individual

◆ parent2

const Individual* TwoPointCrossover::parent2
private

Pointer to the second parent individual


The documentation for this class was generated from the following files: