Skip to contents

Function to perform crossover between selected individuals

Usage

crossover_cpp(selected_parents, offspring_size)

Arguments

selected_parents

Numeric matrix representing the selected individuals.

offspring_size

Number of offspring to generate.

Value

Numeric matrix representing the offspring.

Examples

# example of usage
genomic_data <- matrix(rnorm(100), nrow = 10, ncol = 10)
population <- BioGA::initialize_population_cpp(genomic_data,
                population_size = 5)
fitness <- BioGA::evaluate_fitness_cpp(genomic_data, population)
selected_parents <- BioGA::selection_cpp(population, fitness,
                num_parents = 2)
BioGA::crossover_cpp(selected_parents, offspring_size = 2)
#>           [,1]      [,2]      [,3]         [,4]      [,5]     [,6]      [,7]
#> [1,] -1.400044 0.2553171 -2.437264 -0.005571287 0.6215527 1.148412 -1.821818
#> [2,] -1.400044 0.2553171 -2.437264 -0.005571287 0.6215527 1.148412 -1.821818
#>            [,8]       [,9]      [,10]
#> [1,] -0.2473253 -0.2441996 -0.2827054
#> [2,] -0.2473253 -0.2441996 -0.2827054