R/RecombinatorSequential.R
dict_recombinators_sequential.Rd
Recombinator
that wraps multiple other Recombinator
s given during construction and uses them for mutation in sequence.
When subsequent Recombinator
s have mismatching n_indivs_out
/ n_indivs_in
, then RecombinatorSequential
tries to
match them by running them multiple times. If e.g. recombinators[[1]]$n_indivs_out
is 2 and recombinators[[2]]$n_indivs_in
is 1, then
recombinators[[2]]
is run twice, once for each output of recombinators[[1]]
.
When the allow_lcm_packing
argument is FALSE
, then an error is given if neither n_indivs_out
of a Recombinator
divides n_indivs_in
of the
following Recombinator
, nor n_indivs_in
of the latter divides n_indivs_out
of the former even when considering that the former is run multiple times.
If allow_lcm_packing
is TRUE
, then both recombinators are run multiple times, according to the lowest common multiple ("lcm")
of the two.
However, allow_lcm_packing
can lead to very large values of n_indivs_in
/ n_indivs_out
, so it may instead be preferred to add RecombinatorNull
objects
with fitting n_indivs_in
/ n_indivs_out
values to match subsequent recombinators.
This operator has the configuration parameters of the Recombinator
s that it wraps: The configuration parameters of the operator given to the recombinators
construction
argument are prefixed with "recombinator_1"
, "recombinator_2"
, ... up to "recombinator_#"
, where #
is length(recombinators)
.
Additional configuration parameters:
shuffle_between
:: logical(1)
Whether to reorder values
between invocations of recombinators. Initialized to TRUE
.
Supported Param
classes are the set intersection of supported classes of the Recombinator
s given in recombinators
.
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_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_cmpmaybe
,
dict_recombinators_maybe
,
dict_recombinators_proxy
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorSequential
recombinators
(list
of Recombinator
)Recombinator
s being wrapped. These operators get run sequentially in order.
allow_lcm_packing
(logical(1)
)
Whether to allow lowest common multiple packing.
new()
Initialize the RecombinatorSequential
object.
RecombinatorSequential$new(recombinators, allow_lcm_packing = FALSE)
recombinators
(list
of Recombinator
)Recombinator
s to wrap. The operations are run in order given to recombinators
.
The constructed object gets a clone of this argument. The $recombinators
field will reflect this value.
allow_lcm_packing
(logical(1)
)
Whether to allow lowest common multiple packing. Default FALSE
.
The $allow_lcm_packing
field will reflect this value.
prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to recombinator
and recombinator_not
during construction.
param_set
(ParamSet
)
Passed to MiesOperator
$prime()
.
invisible self
.
set.seed(1)
ds = data.frame(a = c(0, 1), b = c(0, 1))
p = ps(a = p_dbl(0, 1), b = p_dbl(0, 1))
convex = rec("cvxpair", lambda = 0.7)
swap = rec("swap")
convex_then_swap = rec("sequential", list(convex, swap))
ds
#> a b
#> 1 0 0
#> 2 1 1
convex$prime(p)$operate(ds)
#> a b
#> 1 0.3 0.3
#> 2 0.7 0.7
swap$prime(p)$operate(ds)
#> a b
#> 1 1 1
#> 2 0 0
convex_then_swap$prime(p)$operate(ds)
#> a b
#> 1 0.7 0.7
#> 2 0.3 0.3