EVOLUTIONARY ALGORITHMS: GENETIC PROGRAMMING (GP)
Core idea: Instead of hand-coding a solution, evolve it.
Treat programs like DNA. Breed, mutate, select. Survival of the fittest code.
From Quantum Walks we used interference to find paths.
From GP we use selection + variation to find programs.
CORE TECHNIQUES TO BUILD GP ALGORITHMS
REPRESENTATION
Technique: Encode a program as a tree.
Nodes = functions
Leaves = terminals
Why: Trees naturally represent expressions and code.
FITNESS FUNCTION
Technique: Score how well a program solves the problem.
Why: This is "natural selection". No gradient needed.
GENETIC OPERATORS
Crossover: Swap subtrees between 2 parent programs.
Mutation: Randomly change a node. → , or →
Selection: Tournament, roulette. Keep best performers.
EVOLUTION LOOP
EXAMPLES
EXAMPLE 1: SYMBOLIC REGRESSION
Problem: Find formula that fits data. Given points , discover $y = x^2 + 2x + 1$
Classical: Assume form, do regression.
GP:
Population: Random trees like , ,
Fitness: 1 / MSE on data points
After 50 generations: Evolves
Result: Discovers the law without being told the form.
Used in: Science discovery, finance modeling.
EXAMPLE 2: ANT TRAIL PROBLEM
Problem: Evolve program for ant to eat all food on a grid.
Primitives: , , ,
Fitness: # food pellets eaten in 600 steps
Evolution:
Gen 1: Ant spins in circles
Gen 20: Ant follows simple trail
Gen 100: Ant uses to backtrack efficiently
Result: Emergent strategy, no human programmed the path.
Used in: Robotics, path planning.
EXAMPLE 3: CIRCUIT DESIGN
Problem: Evolve a low-pass filter circuit from components .
Representation: Tree = circuit topology
Fitness: How close frequency response is to target
Evolution: GP invents weird topologies humans wouldn't try.
Result: NASA used GP to evolve an antenna for ST5 satellite. 10x better than human design.
Used in: Hardware design, drug discovery.
EXAMPLE 4: GAME AI / STRATEGY
Problem: Evolve trading bot or game player.
Representation: Program = decision tree
Fitness: Profit over 1 year of market data
Evolution: Mutations add/remove rules. Crossover combines good strategies.
Result: Bots discover strategies like "buy dips" on their own.
Used in: Algo trading, StarCraft AI, game NPCs.
GP vs OTHER METHODS
| Method | How it learns | Needs | Strength |
| Gradient Descent | Follows slope | Differentiable | Fast, smooth |
| Quantum Walk | Interference | Quantum hardware | Search speedup |
| Helmholtz | Generate + Recognize | Data | Unsupervised model |
| Genetic Programming | Evolve + Select | Fitness function | Can invent new structure |
KEY TAKEAWAY
GP is "programming by breeding".
You don't tell it how. You tell it what good looks like via fitness.
It explores the space of programs, keeps what works, discards what doesn't.
Like Isaias: chaos + selection = new structure.
Like Helmholtz: generate + test = better model.
Like Quantum Walks: try many paths + amplify good ones.
来源:Benjamin Iken · x.com