selector_v1: Select Top Individuals from a Population Based on Fitness

View source: R/terga2.lib.R

selector_v1R Documentation

Select Top Individuals from a Population Based on Fitness

Description

This function selects a specified number of top individuals from a population based on their fitness scores. It sorts the population in descending order of fitness and returns the highest-ranking individuals.

Usage

selector_v1(pop, number, clf)

Arguments

pop

A list representing the population, where each individual has a 'fit_' attribute that represents its fitness score.

number

An integer specifying the number of individuals to select from the sorted population.

clf

A classifier object containing any additional parameters needed for selection (though not directly used in this function).

Details

The function sorts the population in descending order by the 'fit_' attribute and returns the top 'number' individuals. This selection strategy prioritizes individuals with the highest fitness scores, making it useful for selecting elites in evolutionary algorithms.

Value

A list of the top 'number' individuals from the population, sorted by fitness.

Examples

## Not run: 
pop <- list(
  list(fit_ = 0.9, indices_ = 1:5),
  list(fit_ = 0.8, indices_ = 6:10),
  list(fit_ = 0.7, indices_ = 11:15)
)
clf <- list() # Placeholder for classifier settings
selected_individuals <- selector_v1(pop, number = 2, clf)
print(selected_individuals)

## End(Not run)


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