crossing: Generate Children by Crossover from Parent Population

View source: R/terga1.lib.R

crossingR Documentation

Generate Children by Crossover from Parent Population

Description

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.

Usage

crossing(clf, pop, parents, seed = NULL)

Arguments

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.

Details

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.

Value

A list representing the updated population, including both the original parents and the newly generated children.

Examples

## 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)


predomics/predomicspkg documentation built on Dec. 11, 2024, 11:06 a.m.