Values between two individuals are exchanged with component-wise independent probability.
This is a pseudo-class: It does not create a single R6-object of a class;
instead, it creates the object rec("cmpmaybe", rec("swap"), p = 0.5),
making use of the RecombinatorCmpMaybe and RecombinatorSwap operators.
RecombinatorCrossoverUniform(keep_complement = TRUE)(logical(1))
Whether the operation should keep both resulting individuals (TRUE), or only the first and discard
the complement (FALSE). Default TRUE.
The $keep_complement field will reflect this value.
an object of class Recombinator: rec("cmpmaybe", rec("swap")).
This Recombinator can be created with the short access form rec()
(recs() to get a list), or through the the dictionary
dict_recombinators in the following way:
Other recombinators:
OperatorCombination,
Recombinator,
RecombinatorPair,
dict_recombinators_cmpmaybe,
dict_recombinators_convex,
dict_recombinators_cvxpair,
dict_recombinators_maybe,
dict_recombinators_null,
dict_recombinators_proxy,
dict_recombinators_sbx,
dict_recombinators_sequential,
dict_recombinators_swap,
dict_recombinators_xonary
set.seed(1)
rx = rec("xounif")
print(rx)
#> rec("cmpmaybe", recombinator = rec("swap"), recombinator_not = rec("null",
#> n_indivs_in = 2))
#> $param_set:
#> id lower upper levels value
#> <char> <num> <num> <list> <list>
#> 1: p NA NA 0.5
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rx$prime(p)
rx$operate(data)
#> x y z
#> 1 1 1 0
#> 2 0 0 1
#> 3 2 3 2
#> 4 3 2 3
#> 5 4 4 4
#> 6 5 5 5
rx$param_set$values$p = 0.3
rx$operate(data)
#> x y z
#> 1 1 1 1
#> 2 0 0 0
#> 3 2 2 2
#> 4 3 3 3
#> 5 4 4 4
#> 6 5 5 5