Skip to main content

Module tree

Module tree 

Source
Expand description

Tree genomes for genetic programming

This module provides tree-based genomes for symbolic regression and genetic programming applications.

§Deep trees and stack safety

Every traversal in this module uses an explicit work stack instead of recursion, so no operation overflows the call stack even for pathologically deep trees. This covers the read-side traversals (TreeNode::depth, TreeNode::size, TreeGenome::evaluate, and the position collectors backing TreeNode::positions/TreeNode::terminal_positions/ TreeNode::function_positions), the crate::operators point-mutation traversal, AND teardown: TreeNode implements a stack-safe Drop (EV-60) that frees an arbitrarily deep tree iteratively, so even dropping a deep tree implicitly (never calling TreeGenome::dismantle) cannot overflow the stack. The Drop impl moves each node’s children out with mem::take — which is permitted under Drop, unlike moving a field out by value (E0509) — so the operator layer must likewise use mem::take/in-place mutation rather than by-value destructuring of an owned TreeNode. TreeGenome::dismantle and drop_node_iteratively remain as explicit, self-documenting entry points but are no longer required for correctness.

Structs§

TreeGenome
Tree genome for genetic programming

Enums§

ArithmeticFunction
Standard arithmetic functions for symbolic regression
ArithmeticTerminal
Standard arithmetic terminals for symbolic regression
TreeNode
A node in a GP tree

Traits§

Function
Trait for function nodes in GP trees
Terminal
Trait for terminal nodes in GP trees
TreeGenomeType
Trait for tree genome types (marker trait for operators)

Functions§

drop_node_iteratively
Free a tree node and all of its descendants without deep recursion.