Mutator that wraps multiple other Mutators given during construction and uses them for mutation in sequence.

Configuration Parameters

This operator has the configuration parameters of the Mutators that it wraps: The configuration parameters of the operator given to the mutators construction argument are prefixed with "mutator_1", "mutator_2", ... up to "mutator_#", where # is length(mutators).

Supported Operand Types

Supported Param classes are the set intersection of supported classes of the Mutators given in mutators.

Dictionary

This Mutator can be created with the short access form mut() (muts() to get a list), or through the the dictionary dict_mutators in the following way:

# preferred:
mut("sequential", <mutators>)
muts("sequential", <mutators>)  # takes vector IDs, returns list of Mutators

# long form:
dict_mutators$get("sequential", <mutators>)

Super classes

miesmuschel::MiesOperator -> miesmuschel::Mutator -> MutatorSequential

Active bindings

mutators

(list of Mutator)
Mutators being wrapped. These operators get run sequentially in order.

Methods

Inherited methods


Method new()

Initialize the MutatorSequential object.

Usage

MutatorSequential$new(mutators)

Arguments

mutators

(list of Mutator)
Mutators to wrap. The operations are run in order given to mutators. The constructed object gets a clone of this argument. The $mutators field will reflect this value.


Method prime()

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

Usage

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

MutatorSequential$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

set.seed(1)

# dataset:
#  - x1 is mutated around +- 10
#  - x2 influences sdev of mutation of x1
ds = data.frame(x1 = 0, x2 = c(.01, 0.1, 1))
p = ps(x1 = p_dbl(-10, 10), x2 = p_dbl(0, 10))

# operator that only mutates x1, with sdev given by x2
gauss_x1 = mut("combine",
  operators = list(
    x1 = mut("gauss", sdev_is_relative = FALSE),
    x2 = mut("null")
  ),
  adaptions = list(x1.sdev = function(x) x$x2)
)

gauss_x1$prime(p)
gauss_x1$operate(ds)  # see how x1[1] changes little, x1[3] changes a lot
#>             x1   x2
#> 1 -0.006264538 0.01
#> 2  0.018364332 0.10
#> 3 -0.835628612 1.00

# operator that mutates x1  with sdev given by x2, as well as x2. However,
# the value that x2 takes after mutation does not influence the value that
# the mutator of x1 "sees" -- although x2 is mutated to extreme values,
# mutation of x1 happens as in `gauss_x1`.
gauss_x1_x2 = mut("combine",
  operators = list(
    x1 = mut("gauss", sdev_is_relative = FALSE),
    x2 = mut("gauss", sdev = 100)
  ),
  adaptions = list(x1.sdev = function(x) x$x2)
)

gauss_x1_x2$prime(p)
gauss_x1_x2$operate(ds)  # see how x1 changes in similar ways to above
#>            x1 x2
#> 1  0.01595281 10
#> 2 -0.08204684 10
#> 3  0.73832471 10

# operator that mutates sequentially: first x2, and then x1 with sdev given
# by x2. The value that x2 takes after mutation *does* influence the value
# that the mutator of x1 "sees": x1 is mutated either to a large degree,
# or not at all.

gauss_x2_then_x1 = mut("sequential", list(
    mut("combine",
      operators = list(
        x1 = mut("null"),
        x2 = mut("gauss", sdev = 100)
      )
    ),
    mut("combine",
      operators = list(
        x1 = mut("gauss", sdev_is_relative = FALSE),
        x2 = mut("null")
      ),
      adaptions = list(x1.sdev = function(x) x$x2)
    )
))

gauss_x2_then_x1$prime(p)
gauss_x2_then_x1$operate(ds)
#>           x1 x2
#> 1   0.000000  0
#> 2  -6.212406 10
#> 3 -10.000000 10