Numeric Values between various individuals are recombined via component-wise convex combination (or weighted mean). The number of individuals
over which the convex combination is taken must be determined during construction as n_indivs_in
.
The number of output individuals is always 1, i.e. n_indivs_in
are used to create one output value. When using this
recombinator in a typical EA setting, e.g. with mies_generate_offspring
, it is therefore recommended to use a parent-selector
where the expected quality of selected parents does not depend on the number of parents selected when n_indivs_in
is large:
sel("tournament")
is preferred to sel("best")
.
lambda
:: numeric
| matrix
Combination weights; these are normalized to sum to 1 internally.
Must either be a vector of length n_indivs_in
, or a matrix with n_indivs_in
rows and as many columns as there
are components in the values being operated on. Must be non-negative, at least one value per column must be greater than zero, but it is not
necessary that they sum to 1.
Initialized to rep(1, n_indivs_in)
, i.e. equal weights to all individuals being operated on.
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_cvxpair
,
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
-> RecombinatorConvex
new()
Initialize the RecombinatorConvex
object.
RecombinatorConvex$new(n_indivs_in = 2)
set.seed(1)
rcvx = rec("convex", n_indivs_in = 3)
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 3
#> x y z
#> 1 1 1 1
#> 2 4 4 4
rcvx = rec("convex", 3, lambda = c(0, 1, 2))$prime(p)
rcvx$operate(data) # for groups of 3, take 1/3 of 2nd and 2/3 of 3rd row
#> x y z
#> 1 1.666667 1.666667 1.666667
#> 2 4.666667 4.666667 4.666667
lambda = matrix(c(0, 1, 2, 1, 1, 1, 1, 0, 0), ncol = 3)
lambda
#> [,1] [,2] [,3]
#> [1,] 0 1 1
#> [2,] 1 1 0
#> [3,] 2 1 0
rcvx = rec("convex", 3, lambda = lambda)$prime(p)
rcvx$operate(data) # componentwise different operation
#> x y z
#> 1 1.666667 1 0
#> 2 4.666667 4 3