R/MutatorCmpMaybe.R
dict_mutators_cmpmaybe.Rd
Mutator
that chooses which operation to perform probabilistically. The Mutator
wraps two other Mutator
s given during construction,
and both of these operators are run. The ultimate result is sampled from the results of these operations independently for each
individuum and component: with probability p
(configuration parameter), the result from the Mutator
given to the mutator
construction argument is used, and with probability p - 1
the one given to mutator_not
is used.
This operator has the configuration parameters of the Mutator
s that it wraps: The configuration parameters of the operator given to the mutator
construction argument
are prefixed with "cmpmaybe."
, the configuration parameters of the operator given to the mutator_not
construction argument are prefixed with "cmpmaybe_not."
.
Additional configuration parameters:
p
:: numeric(1)
Probability per component with which to apply the operator given to the mutator
construction argument. Must be set by the user.
Supported Param
classes are the set intersection of supported classes of mutator
and mutator_not
.
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:
Other mutators:
Mutator
,
MutatorDiscrete
,
MutatorNumeric
,
OperatorCombination
,
dict_mutators_erase
,
dict_mutators_gauss
,
dict_mutators_maybe
,
dict_mutators_null
,
dict_mutators_proxy
,
dict_mutators_sequential
,
dict_mutators_unif
Other mutator wrappers:
OperatorCombination
,
dict_mutators_maybe
,
dict_mutators_proxy
,
dict_mutators_sequential
miesmuschel::MiesOperator
-> miesmuschel::Mutator
-> MutatorCmpMaybe
new()
Initialize the MutatorCmpMaybe
object.
MutatorCmpMaybe$new(mutator, mutator_not = MutatorNull$new())
mutator
(Mutator
)Mutator
to wrap. Component-wise results of this operator are used with probability p
(Configuration parameter).
The constructed object gets a clone of this argument.
The $mutator
field will reflect this value.
mutator_not
(Mutator
)
Another Mutator
to wrap. Results from this operator are used when mutator
is not chosen. By
default, this is MutatorNull
, i.e. no operation.
With this default, the
MutatorCmpMaybe
object applies the mutator
operation with probability p
, and
no operation at all otherwise.
The constructed object gets a clone of this argument.
The $mutator_not
field will reflect this value.
prime()
See MiesOperator
method. Primes both this operator, as well as the wrapped operators
given to mutator
and mutator_not
during construction.
param_set
(ParamSet
)
Passed to MiesOperator
$prime()
.
invisible self
.
set.seed(1)
mcm = mut("cmpmaybe", mut("gauss", sdev = 5), p = 0.5)
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5))
data = data.frame(x = rep(0, 5), y = rep(0, 5))
mcm$prime(p)
mcm$operate(data)
#> x y
#> 1 0 5
#> 2 -5 5
#> 3 0 -5
#> 4 5 0
#> 5 5 -5
mcm$param_set$values$p = 0.2
mcm$operate(data)
#> x y
#> 1 0 -0.8095132
#> 2 0 0.0000000
#> 3 0 0.0000000
#> 4 0 0.0000000
#> 5 -5 0.0000000
mcm2 = mut("cmpmaybe",
mutator = mut("gauss", sdev = 0.01),
mutator_not = mut("gauss", sdev = 10),
p = 0.5
)
mcm2$prime(p)
mcm2$operate(data)
#> x y
#> 1 -5 -0.010278773
#> 2 0 -0.005380504
#> 3 0 -0.041499456
#> 4 5 5.000000000
#> 5 -5 5.000000000