Random selector that disregards fitness and individual values and selects individuals randomly. Depending on the configuration parameter replace,
it samples with or without replacement.
sample_unique :: character(1)
Whether to sample individuals globally unique ("global"), unique within groups ("groups"), or not unique at all ("no", sample with replacement).
This is done with best effort; if group_size (when sample_unique is "groups") or n_select (when sample_unique is "global")
is greater than nrow(values), then individuals are selected with as few repeats as possible. Initialized to "groups".
This Selector can be created with the short access form sel()
(sels() to get a list), or through the the dictionary
dict_selectors in the following way:
miesmuschel::MiesOperator -> miesmuschel::Selector -> SelectorRandom
set.seed(1)
sr = sel("random")
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorRandom does not depend on data content
data = data.frame(x = rep(0, 5))
fitnesses = c(1, 5, 2, 3, 0)
sr$prime(p)
sr$operate(data, fitnesses, 2)
#> [1] 1 4
sr$operate(data, fitnesses, 2)
#> [1] 1 2
sr$operate(data, fitnesses, 2)
#> [1] 5 3
sr$operate(data, fitnesses, 4)
#> [1] 2 3 3 1
sr$operate(data, fitnesses, 4)
#> [1] 5 5 2 2
sr$operate(data, fitnesses, 4)
#> [1] 1 5 5 1