Discrete components are mutated by sampling from a uniform distribution, either from all possible values of each component, or from all values except the original value.

Since the information loss is very high, this should in most cases be combined with MutatorCmpMaybe.

Configuration Parameters

  • can_mutate_to_same :: logical(1)
    Whether to sample from entire range of each parameter (TRUE) or from all values except the current value (FALSE). Initialized to TRUE.

Supported Operand Types

Supported Param classes are: ParamLgl, ParamFct

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("unif")
muts("unif")  # takes vector IDs, returns list of Mutators

# long form:
dict_mutators$get("unif")

Super classes

miesmuschel::MiesOperator -> miesmuschel::Mutator -> miesmuschel::MutatorDiscrete -> MutatorDiscreteUniform

Methods

Inherited methods


Method new()

Initialize the MutatorDiscreteUniform object.


Method clone()

The objects of this class are cloneable with this method.

Usage

MutatorDiscreteUniform$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

set.seed(1)
mdu = mut("unif")
p = ps(x = p_lgl(), y = p_fct(c("a", "b", "c")))
data = data.frame(x = rep(TRUE, 5), y = rep("a", 5),
  stringsAsFactors = FALSE)  # necessary for R <= 3.6

mdu$prime(p)
mdu$operate(data)
#>       x y
#> 1  TRUE c
#> 2  TRUE b
#> 3  TRUE c
#> 4  TRUE b
#> 5 FALSE c

mdu$param_set$values$can_mutate_to_same = FALSE
mdu$operate(data)
#>       x y
#> 1 FALSE b
#> 2 FALSE b
#> 3 FALSE c
#> 4 FALSE c
#> 5 FALSE b