Recombinator that chooses which operation to perform probabilistically. The Recombinator wraps two other Recombinators given during construction, and for each group of $n_indivs_in individuals, the operation to perform is sampled: with probability p (configuration parameter), the Recombinator given to the recombinator construction argument is applied, and with probability p - 1 the one given to recombinator_not is applied.

The values of $n_indivs_in and $n_indivs_out is set to the corresponding values of the wrapped Recombinators. Both recombinator and recombinator_not must currently have the same respective $n_indivs_in and $n_indivs_out values.

Configuration Parameters

This operator has the configuration parameters of the Recombinators that it wraps: The configuration parameters of the operator given to the recombinator construction argument are prefixed with "maybe.", the configuration parameters of the operator given to the recombinator_not construction argument are prefixed with "maybe_not.".

Additional configuration parameters:

  • p :: numeric(1)
    Probability per group of n_indivs_in individuals with which to apply the operator given to the recombinator construction argument. Must be set by the user.

Supported Operand Types

Supported Param classes are the set intersection of supported classes of recombinator and recombinator_not.

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("maybe", <recombinator> [, <recombinator_not>])
recs("maybe", <recombinator> [, <recombinator_not>])  # takes vector IDs, returns list of Recombinators

# long form:
dict_recombinators$get("maybe", <recombinator> [, <recombinator_not>])

Super classes

miesmuschel::MiesOperator -> miesmuschel::Recombinator -> RecombinatorMaybe

Active bindings

recombinator

(Recombinator)
Recombinator being wrapped. This operator gets run with probability p (configuration parameter).

recombinator_not

(Recombinator)
Alternative Recombinator being wrapped. This operator gets run with probability 1 - p (configuration parameter).

Methods

Inherited methods


Method new()

Initialize the RecombinatorMaybe object.

Usage

RecombinatorMaybe$new(recombinator, recombinator_not = NULL)

Arguments

recombinator

(Recombinator)
Recombinator to wrap. This operator gets run with probability p (Configuration parameter).
The constructed object gets a clone of this argument. The $recombinator field will reflect this value.

recombinator_not

(Recombinator)
Another Recombinator to wrap. This operator runs when recombinator is not chosen. By default, this is RecombinatorNull, i.e. no operation, with both n_indivs_in and n_indivs_out set to match recombinator. This does not work when recombinator has n_indivs_in < n_indivs_out, in which case this argument must be set explicitly.
With this default, the RecombinatorMaybe object applies the recombinator operation with probability p, and no operation at all otherwise.
The constructed object gets a clone of this argument. The $recombinator_not 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

RecombinatorMaybe$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

RecombinatorMaybe$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

set.seed(1)
rm = rec("maybe", rec("xounif", p = 1), p = 0.5)
p = ps(x = p_int(1, 8), y = p_dbl(1, 8), z = p_lgl())
data = data.frame(x = 1:8, y = 1:8, z = rep(TRUE, 4))

rm$prime(p)
rm$operate(data)
#>   x y    z
#> 1 2 2 TRUE
#> 2 1 1 TRUE
#> 3 4 4 TRUE
#> 4 3 3 TRUE
#> 5 5 5 TRUE
#> 6 6 6 TRUE
#> 7 8 8 TRUE
#> 8 7 7 TRUE

rm$param_set$values$p = 0.3
rm$operate(data)
#>   x y    z
#> 1 1 1 TRUE
#> 2 2 2 TRUE
#> 3 3 3 TRUE
#> 4 4 4 TRUE
#> 5 5 5 TRUE
#> 6 6 6 TRUE
#> 7 7 7 TRUE
#> 8 8 8 TRUE

rm2 = rec("maybe",
  recombinator = rec("xounif", p = 1),
  recombinator_not = rec("xounif", p = 0.5),
  p = 0.5
)

rm2$prime(p)
rm2$operate(data)
#>   x y    z
#> 1 2 1 TRUE
#> 2 1 2 TRUE
#> 3 4 4 TRUE
#> 4 3 3 TRUE
#> 5 6 6 TRUE
#> 6 5 5 TRUE
#> 7 8 8 TRUE
#> 8 7 7 TRUE