crossing | R Documentation |
This function performs crossover on a population by selecting pairs of parent individuals to generate children. Each child is created by combining unique genes from two parents, up to a specified sparsity level.
crossing(clf, pop, parents, seed = NULL)
clf |
A classifier object containing parameters for crossover, including: - 'current_sparsity': The target sparsity level for each child. - 'parallel.local': Boolean indicating whether parallel processing should be used. |
pop |
A list representing the population of individuals (feature subsets), where each individual is represented as a vector of feature indices. |
parents |
A vector of indices representing the parent individuals within 'pop' from which to generate children. |
seed |
Optional integer seed for random number generation, ensuring reproducibility. |
The function: 1. Selects a specified number of couples from the parents to generate children. 2. Combines unique genes from each pair of parents to create a child with 'current_sparsity' number of features. 3. Optionally uses parallel processing to accelerate child generation.
For each child, the genes are selected from the combined unique genes of both parents ('parents_gene_reservoir'). The final population consists of both the original parents and the generated children.
A list representing the updated population, including both the original parents and the newly generated children.
## Not run:
clf <- list(
params = list(current_sparsity = 5, parallel.local = FALSE)
)
pop <- list(1:5, 2:6, 3:7, 4:8) # Example parent population
parents <- c(1, 2, 3, 4)
new_population <- crossing(clf, pop, parents, seed = 42)
print(new_population)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.