| dict_selectors_random {miesmuschel} | R Documentation |
Random Selector
Description
Random selector that disregards fitness and individual values and selects individuals randomly. Depending on the configuration parameter replace,
it samples with or without replacement.
Configuration Parameters
-
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; ifgroup_size(whensample_uniqueis"groups") orn_select(whensample_uniqueis"global") is greater thannrow(values), then individuals are selected with as few repeats as possible. Initialized to"groups".
Supported Operand Types
Supported Domain classes are: p_lgl ('ParamLgl'), p_int ('ParamInt'), p_dbl ('ParamDbl'), p_fct ('ParamFct')
Dictionary
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:
# preferred:
sel("random")
sels("random") # takes vector IDs, returns list of Selectors
# long form:
dict_selectors$get("random")
Super classes
miesmuschel::MiesOperator -> miesmuschel::Selector -> SelectorRandom
Methods
Public methods
Inherited methods
Method new()
Initialize the SelectorRandom object.
Usage
SelectorRandom$new()
Method clone()
The objects of this class are cloneable with this method.
Usage
SelectorRandom$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
See Also
Other selectors:
Selector,
SelectorScalar,
dict_selectors_best,
dict_selectors_maybe,
dict_selectors_null,
dict_selectors_proxy,
dict_selectors_sequential,
dict_selectors_tournament
Examples
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)
sr$operate(data, fitnesses, 2)
sr$operate(data, fitnesses, 2)
sr$operate(data, fitnesses, 4)
sr$operate(data, fitnesses, 4)
sr$operate(data, fitnesses, 4)