selectTournoi | R Documentation |
This function performs tournament selection on a population, randomly selecting a specified percentage of individuals for the next generation. The selection can be either a fixed number ('discrete = TRUE') or a percentage of the population size.
selectTournoi(selection, percentage, discrete = TRUE)
selection |
A vector representing the indices or identifiers of the individuals from which to select. |
percentage |
A numeric value indicating either the exact number (if 'discrete = TRUE') or percentage (if 'discrete = FALSE') of individuals to select. |
discrete |
A logical value indicating whether 'percentage' should be treated as a discrete number of individuals ('TRUE') or a percentage of the total population ('FALSE'). |
If 'discrete' is set to 'TRUE', the function selects exactly 'percentage' individuals from 'selection'. If 'discrete' is 'FALSE', the function interprets 'percentage' as a proportion of the population size, and the number of individuals selected is calculated accordingly.
This selection method introduces randomness while maintaining a proportionate selection of individuals, which can help maintain diversity within the population in evolutionary algorithms.
A vector of selected individuals from 'selection'.
## Not run:
selection <- 1:10
# Select 3 individuals directly
selected_indices <- selectTournoi(selection, percentage = 3, discrete = TRUE)
print(selected_indices)
# Select 30% of individuals from the population
selected_indices <- selectTournoi(selection, percentage = 30, discrete = FALSE)
print(selected_indices)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.