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)

Arguments

keep_complement

(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.

Value

an object of class Recombinator: rec("cmpmaybe", rec("swap")).

Supported Operand Types

Supported Param classes are: ParamLgl, ParamInt, ParamDbl, ParamFct

Dictionary

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:

# preferred:
rec("xounif")
recs("xounif")  # takes vector IDs, returns list of Recombinators

# long form:
dict_recombinators$get("xounif")

Examples

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