GP Crossover

cx_one_point(ind1, ind2)

Randomly selects a crossover point in each individual and exchanges each subtree with the point as the root between each individual.

Parameters
Returns

Two mated individuals.

Return type

GPMates

cx_one_point_leaf_biased(ind1, ind2, term_prob)

Randomly selects a crossover point in each individual and exchanges each subtree with the point as the root between each individual.

Parameters
  • ind1 (GPIndividual) – The first individual to mate.

  • ind2 (GPIndividual) – The second individual to mate.

  • term_prob (float) – The probability of selecting a terminal node as the crossover point.

Returns

Two mated individuals.

Return type

GPMates

cx_semantic(ind1, ind2, prim_set, min_depth=2, max_depth=6, gen_func=gen_grow)

Perform a semantic crossover on the given individuals.

Parameters
  • ind1 (list) – The first individual to be mated.

  • ind2 (list) – The second individual to be mated.

  • prim_set (PrimitiveSetTyped) – Primitive set from which primitives are selected.

  • gen_func (Callable) – The function which generates the random tree.

  • min_depth (int) – Minimum depth of the random tree.

  • max_depth (int) – Maximum depth of the random tree.

Returns

Two mated individuals.

Return type

tuple[list, list]