Recombinator that wraps multiple other Recombinators given during construction and uses them for mutation in sequence.

When subsequent Recombinators 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.

Configuration Parameters

This operator has the configuration parameters of the Recombinators 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 Operand Types

Supported Param classes are the set intersection of supported classes of the Recombinators given in recombinators.

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("sequential", <recombinators>)
recs("sequential", <recombinators>)  # takes vector IDs, returns list of Recombinators

# long form:
dict_recombinators$get("sequential", <recombinators>)

Super classes

miesmuschel::MiesOperator -> miesmuschel::Recombinator -> RecombinatorSequential

Active bindings

recombinators

(list of Recombinator)
Recombinators being wrapped. These operators get run sequentially in order.

allow_lcm_packing

(logical(1))
Whether to allow lowest common multiple packing.

Methods

Inherited methods


Method new()

Initialize the RecombinatorSequential object.

Usage

RecombinatorSequential$new(recombinators, allow_lcm_packing = FALSE)

Arguments

recombinators

(list of Recombinator)
Recombinators 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.


Method prime()

See MiesOperator method. Primes both this operator, as well as the wrapped operators given to recombinator and recombinator_not during construction.

Usage

RecombinatorSequential$prime(param_set)

Arguments

param_set

(ParamSet)
Passed to MiesOperator$prime().

Returns

invisible self.


Method clone()

The objects of this class are cloneable with this method.

Usage

RecombinatorSequential$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

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