R/RecombinatorProxy.R
dict_recombinators_proxy.Rd
Recombinator that performs the operation in its operation
configuration parameter. This is useful, e.g., to make
OptimizerMies
's recombination operation fully parametrizable.
operation
:: Recombinator
Operation to perform. Must be set by the user.
This is primed when $prime()
of RecombinatorProxy
is called, and also when $operate()
is called, to make changing
the operation as part of self-adaption possible. However, if the same operation gets used inside multiple RecombinatorProxy
objects, then it is recommended to $clone(deep = TRUE)
the object before assigning them to operation
to avoid
frequent re-priming.
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:
Other recombinators:
OperatorCombination
,
Recombinator
,
RecombinatorPair
,
dict_recombinators_cmpmaybe
,
dict_recombinators_convex
,
dict_recombinators_cvxpair
,
dict_recombinators_maybe
,
dict_recombinators_null
,
dict_recombinators_sbx
,
dict_recombinators_sequential
,
dict_recombinators_swap
,
dict_recombinators_xonary
,
dict_recombinators_xounif
Other recombinator wrappers:
OperatorCombination
,
dict_recombinators_cmpmaybe
,
dict_recombinators_maybe
,
dict_recombinators_sequential
miesmuschel::MiesOperator
-> miesmuschel::Recombinator
-> RecombinatorProxy
new()
Initialize the RecombinatorProxy
object.
RecombinatorProxy$new(n_indivs_in = 2, n_indivs_out = n_indivs_in)
n_indivs_in
(integer(1)
)
Number of individuals to consider at the same time. When operating, the number of input individuals must be divisible by this number.
Furthermore, the Recombinator
assigned to the operation
configuration parameter must have an n_indivs_in
that is a divisor of this number.
Default 2.
The $n_indivs_in
field will reflect this value.
n_indivs_out
(integer(1)
)
Number of individuals that result for each n_indivs_in
lines of input. Must be at most n_indivs_in
.
The ratio of $n_indivs_in
to $n_indivs_out
of the Recombinator
assigned to the operation
configuration parameter must be the same as
n_indivs_in
to n_indivs_out
of this object.
Default equal to n_indivs_in
.
The $n_indivs_out
field will reflect this value.
prime()
See MiesOperator
method. Primes both this operator, as well as the operator given to the operation
configuration parameter.
Note that this modifies the $param_set$values$operation
object.
param_set
(ParamSet
)
Passed to MiesOperator
$prime()
.
invisible self
.
set.seed(1)
rp = rec("proxy", operation = rec("xounif"))
p = ps(x = p_int(-5, 5), y = p_dbl(-5, 5), z = p_lgl())
data = data.frame(x = 1:4, y = 0:3, z = rep(TRUE, 4))
rp$prime(p)
rp$operate(data) # default operation: null
#> x y z
#> 1 2 1 TRUE
#> 2 1 0 TRUE
#> 3 3 3 TRUE
#> 4 4 2 TRUE
rp$param_set$values$operation = rec("xounif", p = 0.5)
rp$operate(data)
#> x y z
#> 1 1 0 TRUE
#> 2 2 1 TRUE
#> 3 4 3 TRUE
#> 4 3 2 TRUE