alogos.systems.cfggp.neighborhood

Neighborhood functions to generate nearby genotypes for CFG-GP.

Functions

subtree_replacement(grammar, genotype, parameters=None)

Systematically change a chosen number of nodes.


Detailed object descriptions

alogos.systems.cfggp.neighborhood.subtree_replacement(grammar, genotype, parameters=None)[source]

Systematically change a chosen number of nodes.

Parameters:
  • grammar (Grammar)

  • genotype (Genotype)

  • parameters (dict or ParameterCollection, optional) – Following keyword-value pairs are considered by this function:

    • neighborhood_distance (int) : The distance from the original genotype to a new genotype in terms of replaced subtrees.

    • neighborhood_max_size (int) : Maximum number of neighbor genotypes to generate.

    • neighborhood_only_terminals (bool) : If True, only replace nodes with terminals in them.

Returns:

neighbors (list of Genotype objects)