This function builds a simple wrapper around an evolutionary operator, i.e., mutator, recombinator or selector and defines its parameters. The result is a function that does not longer depend on the parameters. E.g., fun = setup(mutBitflip, p = 0.3)
initializes a bitflip mutator with mutation probability 0.3. Thus, the following calls have the same behaviour: fun(c(1, 0, 0)) and mutBitflip(fun(c(1, 0, 0), p = 0.3). Basically, this type of preinitialization is only neccessary if operators with additional parameters shall be initialized in order to use the black-box ecr.
setup(operator,...)
Arguments
operator: [ecr_operator]
Evolutionary operator.
...: [any]
Furhter parameters for operator.
Returns
[function] Wrapper evolutionary operator with parameters x and ....
Examples
# initialize bitflip mutator with p = 0.3bf = setup(mutBitflip, p =0.3)# sample binary stringx = sample(c(0,1),100, replace =TRUE)set.seed(1)# apply preinitialized functionprint(bf(x))set.seed(1)# apply raw functionprint(mutBitflip(x, p =0.3))# overwrite preinitialized values with mutatectrl = initECRControl(fitness.fun =function(x) sum(x), n.objectives =1L)# here we define a mutation probability of 0.3ctrl = registerECROperator(ctrl,"mutate", setup(mutBitflip, p =0.3))# here we overwrite with 1, i.e., each bit is flippedprint(x)print(mutate(ctrl, list(x), p.mut =1, p =1)[[1]])