Expand description
Cartesian Genetic Programming.
CGP encodes a directed acyclic computation graph on a fixed
rows × cols grid. Each node stores (function_id, input_0, input_1),
plus the final output gene picks which node produces the output.
The genotype is a fixed-length integer vector, so populations are
Tensor<B, 2, Int> and fit the tensor abstraction cleanly.
§Evolutionary engine
Canonical CGP uses a (1 + λ) Evolution Strategy with point
mutation and no crossover. This module re-implements just that
engine directly — not via crate::algorithms::es_classical — so
the mutation logic can be specialized to the CGP genome semantics
(constrained feed-forward connections, function_id range, …).
§Function set
The v1 function set is fixed at construction time:
| id | op | arity | formula |
|---|---|---|---|
| 0 | add | 2 | a + b |
| 1 | sub | 2 | a − b |
| 2 | mul | 2 | a · b |
| 3 | protected_div | 2 | a / b (or a if ` |
| 4 | sin | 1 | sin(a) |
| 5 | cos | 1 | cos(a) |
| 6 | tanh | 1 | tanh(a) |
| 7 | const 1.0 | 0 | 1.0 |
§Phenotype evaluation
Evaluation runs on the host because the per-node dispatch is not a good fit for dense tensor ops; node values are computed in topological order (left-to-right across the grid columns). Genotype storage stays on-device to match the other strategies.
§Reference
- Miller (2011), Cartesian Genetic Programming (Natural Computing Series).
Structs§
- Cartesian
Genetic Programming - Classical Cartesian GP with
(1 + λ)ES. - CgpConfig
- Static configuration for a
CartesianGeneticProgrammingrun. - CgpState
- Generation state for
CartesianGeneticProgramming.
Constants§
- FUNCTION_
ARITIES - Fixed v1 function set: arity of each opcode.
- NUM_
FUNCTIONS - Number of opcodes in the v1 function set.
Functions§
- evaluate_
cgp - Evaluates a CGP genotype at a set of input rows.