Selector
that repeatedly samples k
individuals and selects the best ouf of these.
k
:: integer(1)
Tournament size. Must be set by the user.
choose_per_tournament
:: Number of individuals to choose in each tournament. Must be smaller than k
. The special value 0
sets this to the group_size
hint given to the $operate()
-call (but at most k
). This is equal to n_select
when used as survival-selector in mies_survival_plus()
/mies_survival_comma()
,
and equal to n_indivs_in
of a Recombinator
used in mies_generate_offspring()
.
Initialized to 1.
sample_unique
:: character(1)
Whether to sample individuals globally unique ("global"
, selected individuals are removed from the population after each tournament),
unique within groups ("groups"
, individuals are replaced when group_size
individuals were sampled), unique per tournament ("tournament"
, individuals are replaced
after each tournament), or not unique at all ("no"
, individuals are sampled with replacement within tournaments).
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 the first nrow(values) * floor(group_size / nrow(values))
or nrow(values) * floor(n_select / nrow(values))
individuals
are chosen deterministically by selecting every individual with the same frequency, followed by tournament selection for the remaining required individuals.
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
-> miesmuschel::SelectorScalar
-> SelectorTournament
new()
Initialize the SelectorTournament
object.
SelectorTournament$new(scalor = ScalorSingleObjective$new())
scalor
(Scalor
)Scalor
to use to generate scalar values from multiple objectives, if multi-objective optimization is performed.
Initialized to ScalorSingleObjective
: Doing single-objective optimization normally, throwing an error if used
in multi-objective setting: In that case, a Scalor
needs to be explicitly chosen.
sb = sel("tournament", k = 4)
p = ps(x = p_dbl(-5, 5))
# dummy data; note that SelectorBest does not depend on data content
data = data.frame(x = rep(0, 7))
fitnesses = c(1, 5, 2, 3, 0, 4, 6)
sb$prime(p)
sb$operate(data, fitnesses, 2)
#> [1] 7 7
sb$operate(data, fitnesses, 4, group_size = 2)
#> [1] 7 6 2 7