alogos.systems.pige.neighborhood

Neighborhood functions to generate nearby genotypes for piGE.

Functions

int_replacement(grammar, genotype, parameters=None)

Systematically change a chosen number of int codons.


Detailed object descriptions

alogos.systems.pige.neighborhood.int_replacement(grammar, genotype, parameters=None)[source]

Systematically change a chosen number of int codons.

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 int codons.

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

    • neighborhood_only_terminals (bool) : If True, only replace codons that represent terminals.

    • max_expansions (bool) : Maximum number of nonterminal expansions used in a derivation.

    • max_wraps (bool) : Maximum number of wraps of the genotype that can be used in a derivation.

    • stack_mode (str) : Mode by which new nonterminals are added to the stack of all nonterminals that were not yet expanded.

      Possible values:

      • "start": At the beginning of the stack.

      • "end": At the end of the stack.

      • "inplace": At the position where the nonterminal was located that was rewritten and led to the new nonterminal.

Returns:

neighbors (list of Genotype objects)