Sample the vector.name variable such that the number of ones has a given distribution.

initSelector(
  individuals,
  vector.name = "selector.selection",
  distribution = function() floor(runif(1, 0, length(individuals[[1]][[vector.name]]) +
    1)),
  soften.op = NULL,
  soften.op.strategy = NULL,
  soften.op.repeat = 1,
  reject.condition = function(x) !any(x)
)

Arguments

individuals

[list of named lists] the individuals to initialize.

vector.name

[character(1)] the variable name, whose entries are sampled.

distribution

[function] function that returns a random integer from 0 to the length of each individual's vector.name slot. Defaults to the uniform distribution from 1 to length().

soften.op

[ecr_mutator] an optional mutator to apply to the vector.name variable.

soften.op.strategy

function an optional function that can set the soften.op's parameters. See combine.operators strategy parameters. Ignored if soften.op is not given.

soften.op.repeat

[integer(1)] how often to repeat soften.op application. Ignored if soften.op is not given.

reject.condition

[function | NULL] reject condition as a function applied to newly generated values of vector.name. If set to NULL, no rejection is done.

Value

list of named lists the individuals with initialized [[vector.name]].

Examples

library(mlrCPO) # Initialize parameter set and sample candidates ps <- pSS( maxdepth: integer[1, 30], minsplit: integer[2, 30], cp: numeric[0.001, 0.999], selector.selection: logical^5) initials <- sampleValues(ps, 15, discrete.names = TRUE) # Resample logical vector selector.selection of initials # with binomial distribution initSelector(initials, distribution = function() rbinom(n = 5, size = 5, prob = 0.5))
#> [[1]] #> [[1]]$maxdepth #> [1] 24 #> #> [[1]]$minsplit #> [1] 30 #> #> [[1]]$cp #> [1] 0.6221245 #> #> [[1]]$selector.selection #> [1] TRUE FALSE TRUE FALSE TRUE #> #> #> [[2]] #> [[2]]$maxdepth #> [1] 17 #> #> [[2]]$minsplit #> [1] 29 #> #> [[2]]$cp #> [1] 0.3653071 #> #> [[2]]$selector.selection #> [1] FALSE TRUE FALSE FALSE FALSE #> #> #> [[3]] #> [[3]]$maxdepth #> [1] 17 #> #> [[3]]$minsplit #> [1] 20 #> #> [[3]]$cp #> [1] 0.1904093 #> #> [[3]]$selector.selection #> [1] FALSE TRUE FALSE TRUE TRUE #> #> #> [[4]] #> [[4]]$maxdepth #> [1] 27 #> #> [[4]]$minsplit #> [1] 19 #> #> [[4]]$cp #> [1] 0.7219674 #> #> [[4]]$selector.selection #> [1] TRUE FALSE TRUE FALSE FALSE #> #> #> [[5]] #> [[5]]$maxdepth #> [1] 22 #> #> [[5]]$minsplit #> [1] 28 #> #> [[5]]$cp #> [1] 0.01718915 #> #> [[5]]$selector.selection #> [1] TRUE TRUE TRUE FALSE FALSE #> #> #> [[6]] #> [[6]]$maxdepth #> [1] 26 #> #> [[6]]$minsplit #> [1] 3 #> #> [[6]]$cp #> [1] 0.4601082 #> #> [[6]]$selector.selection #> [1] TRUE TRUE FALSE TRUE TRUE #> #> #> [[7]] #> [[7]]$maxdepth #> [1] 6 #> #> [[7]]$minsplit #> [1] 30 #> #> [[7]]$cp #> [1] 0.6448207 #> #> [[7]]$selector.selection #> [1] FALSE TRUE TRUE FALSE FALSE #> #> #> [[8]] #> [[8]]$maxdepth #> [1] 19 #> #> [[8]]$minsplit #> [1] 7 #> #> [[8]]$cp #> [1] 0.07269482 #> #> [[8]]$selector.selection #> [1] FALSE TRUE FALSE TRUE TRUE #> #> #> [[9]] #> [[9]]$maxdepth #> [1] 27 #> #> [[9]]$minsplit #> [1] 2 #> #> [[9]]$cp #> [1] 0.3822231 #> #> [[9]]$selector.selection #> [1] TRUE FALSE TRUE FALSE FALSE #> #> #> [[10]] #> [[10]]$maxdepth #> [1] 16 #> #> [[10]]$minsplit #> [1] 22 #> #> [[10]]$cp #> [1] 0.09271459 #> #> [[10]]$selector.selection #> [1] TRUE TRUE TRUE FALSE TRUE #> #> #> [[11]] #> [[11]]$maxdepth #> [1] 14 #> #> [[11]]$minsplit #> [1] 10 #> #> [[11]]$cp #> [1] 0.2698073 #> #> [[11]]$selector.selection #> [1] TRUE TRUE FALSE FALSE FALSE #> #> #> [[12]] #> [[12]]$maxdepth #> [1] 21 #> #> [[12]]$minsplit #> [1] 11 #> #> [[12]]$cp #> [1] 0.3997436 #> #> [[12]]$selector.selection #> [1] TRUE TRUE TRUE FALSE FALSE #> #> #> [[13]] #> [[13]]$maxdepth #> [1] 7 #> #> [[13]]$minsplit #> [1] 22 #> #> [[13]]$cp #> [1] 0.9804208 #> #> [[13]]$selector.selection #> [1] TRUE TRUE FALSE TRUE TRUE #> #> #> [[14]] #> [[14]]$maxdepth #> [1] 23 #> #> [[14]]$minsplit #> [1] 26 #> #> [[14]]$cp #> [1] 0.009492271 #> #> [[14]]$selector.selection #> [1] FALSE FALSE FALSE FALSE TRUE #> #> #> [[15]] #> [[15]]$maxdepth #> [1] 5 #> #> [[15]]$minsplit #> [1] 12 #> #> [[15]]$cp #> [1] 0.9741666 #> #> [[15]]$selector.selection #> [1] TRUE FALSE TRUE TRUE FALSE #> #>