Skip to main content

Module operators

Module operators 

Source
Expand description

GEP genetic operators, all valid by construction (no repair pass).

Every operator preserves the head/tail position-class invariant and the fixed chromosome length, so any offspring still decodes to a complete expression tree. Operators act on host-side &mut [Symbol] chromosomes: the population tensor is pulled to host once per generation (alongside the host-side roulette selection it shares the round-trip with), the operators run, and the result is re-uploaded.

  • Point mutation is locus-class aware — the single operator that needs a sampling constraint. Head loci draw any symbol; tail loci draw terminals only, keeping the tail invariant intact.
  • IS / RIS transposition rewrite only the head (fixed length, tail untouched); any symbol is legal in the head, so they cannot break validity.
  • One-/two-point crossover swap class-aligned segments between two equal-layout parents, so a tail locus always exchanges with a tail locus.

Functions§

is_transposition
Insertion-Sequence (IS) transposition: copies a short sequence and inserts it at a non-root head locus, shifting the rest of the head right and dropping the overflow off the head end. The tail is untouched.
one_point_crossover
One-point crossover: swaps the suffixes of two equal-length parents at a random cut. Class-aligned, so the tail stays terminal-only.
point_mutation
Applies per-gene point mutation in place, respecting locus classes.
ris_transposition
Root-Insertion-Sequence (RIS) transposition: finds a function symbol in the head, copies the sequence starting there to head position 0, shifts right, and drops the overflow. Guarantees the root becomes a function. The tail is untouched.
two_point_crossover
Two-point crossover: swaps the middle segment between two random cuts. Class-aligned, so the tail stays terminal-only.