Variation operators#

Variation operators on expressions.

Classical operators (Koza, 1992; Poli, Langdon and McPhee, 2008):

Semantic operator: semantic_crossover() is the semantic similarity-based crossover of Uy et al. (2011): the swapped subtrees must behave similarly, but not identically, on the training samples.

Every operator returns a new expression and leaves its parents unchanged; size and depth limits are checked by the caller (within_limits()).

Crossover and mutation operators on expression trees.

Functions#

choose_node(expr, rng[, p_internal])

Index of a random node; an internal node with probability p_internal.

within_limits(expr[, max_depth, max_size])

True if the expression respects the depth and size limits.

subtree_crossover(p1, p2, rng[, p_internal])

Child of p1 with a random subtree replaced by a random subtree of p2.

subtree_mutation(p, pset, rng[, max_depth])

Replace a random subtree by a grown tree of depth at most max_depth.

point_mutation(p, pset, rng[, rate])

Replace every node with probability rate (default 1/size, at least one node).

hoist_mutation(p, rng)

Replace a random subtree by one of its own subtrees (Kinnear's hoist).

shrink_mutation(p, pset, rng)

Replace a random internal subtree by a terminal.

insert_mutation(p, pset, rng)

Insert a random function above a random subtree (the subtree becomes one argument).

constant_mutation(p, rng[, sigma, rate])

Multiply parameters by \(1+\sigma\epsilon\) and add \(\sigma\epsilon'\), \(\epsilon,\epsilon'\sim N(0,1)\).

semantic_crossover(p1, p2, X, rng[, lower, ...])

Semantic similarity-based crossover (SSC) of Uy et al. (2011).