resetTags | R Documentation |
This function resets specific tags for all individuals in a population, including 'selected', 'toBeMutated', and 'mate' attributes. It can be used to clear or initialize these tags before further processing.
resetTags(pop, selected = FALSE, toBeMutated = FALSE, mate = -1)
pop |
A list representing the population, where each individual is expected to have attributes 'selected', 'toBeMutated', and 'mate'. |
selected |
A logical value to set for the 'selected' attribute of each
individual. Defaults to |
toBeMutated |
A logical value to set for the 'toBeMutated' attribute of
each individual. Defaults to |
mate |
A value to set for the 'mate' attribute of each individual.
Defaults to |
The function iterates through each individual in the population and sets their 'selected', 'toBeMutated', and 'mate' attributes to the specified values. This function is useful for resetting the population's status before selection and mutation operations.
If 'pop' is NULL
, the function issues a warning (if
'clf$params$warnings' is enabled) and returns NULL
. If 'pop' is not a
list, an error is raised.
The modified population list with updated 'selected', 'toBeMutated', and 'mate' attributes for each individual.
## Not run:
pop <- list(
list(fit_ = 0.9, selected = TRUE, toBeMutated = TRUE, mate = 2),
list(fit_ = 0.8, selected = TRUE, toBeMutated = FALSE, mate = 3),
list(fit_ = 0.7, selected = FALSE, toBeMutated = TRUE, mate = -1)
)
pop <- resetTags(pop, selected = FALSE, toBeMutated = FALSE, mate = -1)
# Check updated population
str(pop)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.