mutateFunc
mutates a function $f$ by recursively replacing inner function labels in
$f$ with probability mutatefuncprob
.
mutateSubtree
mutates a function by recursively replacing inner nodes with
newly grown subtrees of maximum depth maxsubtreedepth
.
mutateNumericConst
mutates a function by perturbing each numeric (double) constant $c$
with probability mutateconstprob
by setting $c := c + rnorm(1, mean = mu, sd = sigma)$.
Note that constants of other typed than double
(e.g integer
s) are not affected.
mutateFunc(func, funcset, mutatefuncprob = 0.1, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateSubtree(func, funcset, inset, conset, mutatesubtreeprob = 0.1, maxsubtreedepth = 5, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateNumericConst(func, mutateconstprob = 0.1, breedingFitness = function(individual) TRUE, breedingTries = 50, mu = 0, sigma = 1)
mutateFuncTyped(func, funcset, mutatefuncprob = 0.1, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateSubtreeTyped(func, funcset, inset, conset, mutatesubtreeprob = 0.1, maxsubtreedepth = 5, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateNumericConstTyped(func, mutateconstprob = 0.1, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateChangeLabel(func, funcset, inset, conset, strength = 1, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateInsertSubtree(func, funcset, inset, conset, strength = 1, subtreeDepth = 2, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateDeleteSubtree(func, funcset, inset, conset, strength = 1, subtreeDepth = 2, constprob = 0.2, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateChangeDeleteInsert(func, funcset, inset, conset, strength = 1, subtreeDepth = 2, constprob = 0.2, iterations = 1, changeProbability = 1/3, deleteProbability = 1/3, insertProbability = 1/3, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateDeleteInsert(func, funcset, inset, conset, strength = 1, subtreeDepth = 2, constprob = 0.2, iterations = 1, deleteProbability = 0.5, insertProbability = 0.5, breedingFitness = function(individual) TRUE, breedingTries = 50)
mutateFuncFast(funcbody, funcset, mutatefuncprob = 0.1)
mutateSubtreeFast(funcbody, funcset, inset, constmin, constmax, insertprob, deleteprob, subtreeprob, constprob, maxsubtreedepth)
mutateNumericConstFast(funcbody, mutateconstprob = 0.1, mu = 0, sigma = 1)
body(func)
.rnorm(1)
to it.mutateChangeLabel
operator.mutateDeleteSubtree
operator.mutateInsertSubtree
operator.geneticProgramming
for details.mutateFuncTyped
, mutateSubtreeTyped
, and mutateNumericConstTyped
are
variants of the above functions that only create well-typed result expressions.mutateFuncFast
, mutateSubtreeFast
, mutateNumericConstFast
are variants
of the above untyped mutation function implemented in C. They offer a considerably faster
execution speed for the price of limited flexibility. These variants take function bodies
as arguments (obtain these via R's body
function) and return function bodies as results.
To turn a function body into a function, use RGP's makeClosure
tool function.
The second set of mutation operators features a more orthogonal design, with each individual
operator having a only a small effect on the genotype. Mutation strength is controlled by
the integral strength
parameter.
mutateChangeLabel
Selects a node (inner node or leaf) by uniform random sampling and replaces
the label of this node by a new label of matching type.
mutateInsertSubtree
Selects a leaf by uniform random sampling and replaces it with a matching
subtree of the exact depth of subtreeDepth
.
mutateDeleteSubtree
Selects a subree of the exact depth of subtreeDepth
by uniform random
sampling and replaces it with a matching leaf.
mutateChangeDeleteInsert
Either applies mutateChangeLabel
, mutateInsertSubtree
,
or mutateDeleteSubtree
. The probability weights for selecting an operator can be supplied
via the ...Probability arguments (probability weights are normalized to a sum of 1).
mutateDeleteInsert
Either applies mutateDeleteSubtree
or mutateInsertSubtree
. The
probability weights for selecting an operator can be supplied via the ...Probability arguments
(probability weights are normalized to a sum of 1).
The above functions automatically create well-typed result expressions when used in a strongly
typed GP run.
All RGP mutation operators have the S3 class c("mutationOperator", "function")
.