Skip to main content

Module function_set

Module function_set 

Source
Expand description

Shared opcode contract for tree- and graph-structured genetic programming.

Both Cartesian Genetic Programming (crate::algorithms::gp_cgp) and Gene Expression Programming (crate::algorithms::gep) evaluate programs built from the same primitive set: a small table of arithmetic and transcendental functions plus a constant. FunctionSet is the minimal contract those families share — it describes the function opcodes only.

§What is not here

Terminals (variables drawn from an input row, problem constants) are deliberately absent from this trait. CGP wires its inputs through the graph connection genes, and GEP resolves them in its tree evaluator (crate::algorithms::gep::ExpressionTree::eval); neither needs the function set to carry terminal state. Keeping terminals out of FunctionSet means the CGP retrofit adds no dead methods — the GEP-only terminal layer lives in crate::algorithms::gep::Alphabet.

§Symbol id-space

A Symbol is an i32 opcode id. Function ids occupy 0..num_functions(). GEP extends this with variable and constant ids above the function range (see Alphabet); CGP uses only the function ids. i32 is mandatory because populations are stored as Burn integer tensors (Tensor<B, 2, Int>), whose element type is i32.

Structs§

ArithmeticFunctionSet
The canonical v1 arithmetic function set shared by CGP and GEP.
Symbol
A program symbol: an i32 opcode id.

Traits§

FunctionSet
The function-opcode contract shared by CGP and GEP.