selectElite | R Documentation |
This function selects the top-performing individuals from a population based on their evaluation scores. It returns the indices of the highest-scoring individuals, making up a specified percentage of the total population.
selectElite(evaluation, percentage)
evaluation |
A numeric vector of evaluation scores for each individual in the population. Higher scores indicate better performance. |
percentage |
A numeric value representing the percentage of the top individuals to select, specified as a value between 0 and 100. |
The function calculates the number of individuals to select based on the given 'percentage' and the length of 'evaluation'. It then sorts 'evaluation' in descending order and returns the indices of the top-performing individuals.
This selection method is often used to maintain high-quality solutions (elites) in evolutionary algorithms, ensuring that the best individuals are retained across generations.
A vector of indices representing the top-performing individuals in the population.
## Not run:
evaluation <- c(0.8, 0.6, 0.9, 0.7, 0.5)
elite_indices <- selectElite(evaluation, percentage = 40)
print(elite_indices) # Returns indices of the top 40% based on evaluation scores
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.