R/RecombinatorConvexPair.R
dict_recombinators_cvxpair.Rd
Numeric Values between various individuals are recombined via component-wise convex combination (or weighted mean). Exactly two
individuals are being recombined, and the lambda
configuration parameter determines the relative weight of the first
individual in each pair for the first result, and the relative weight of the second indivudual for the complement, if
initialized with keep_complement
set to TRUE
.
lambda
:: numeric
Combination weight. If keep_complement
is TRUE
, then two individuals are returned for each pair of input individuals:
one corresponding to lambda * <1st individual> + (1-lambda) * <2nd individual>
, and one corresponding to
(1-lambda) * <1st individual> + lambda * <2nd individual>
(i.e. the complement). Otherwise, only the first of these two
is generated.
Must either be a scalar, or a vector with length equal to the number of
components in the values being operated on. Must be between 0 and 1.
Initialized to 0.5.
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_maybe
,
dict_recombinators_null
,
dict_recombinators_proxy
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> miesmuschel::RecombinatorPair
-> RecombinatorConvexPair
new()
Initialize the RecombinatorConvexPair
object.
RecombinatorConvexPair$new(keep_complement = TRUE)
set.seed(1)
rcvx = rec("cvxpair")
p = ps(x = p_dbl(-5, 5), y = p_dbl(-5, 5), z = p_dbl(-5, 5))
data = data.frame(x = 0:5, y = 0:5, z = 0:5)
rcvx$prime(p)
rcvx$operate(data) # mean of groups of 2
#> x y z
#> 1 0.5 0.5 0.5
#> 2 0.5 0.5 0.5
#> 3 2.5 2.5 2.5
#> 4 2.5 2.5 2.5
#> 5 4.5 4.5 4.5
#> 6 4.5 4.5 4.5
# with the default value of lambda = 0.5, the default of
# keep_complement = TRUE means that pairs of equal values are generated;
# consider setting keep_complement = FALSE int that case.
rcvx$param_set$values$lambda = 0.1
rcvx$operate(data)
#> x y z
#> 1 0.9 0.9 0.9
#> 2 0.1 0.1 0.1
#> 3 2.9 2.9 2.9
#> 4 2.1 2.1 2.1
#> 5 4.9 4.9 4.9
#> 6 4.1 4.1 4.1