Ordinary programming starts with a human who understands the problem, designs an algorithm, and writes code. Genetic programming flips that order: you describe what a good program looks like, and then let a population of candidate programs fight for survival — the fittest survive, reproduce, and gradually improve.
The idea was developed into a full method by John Koza in his 1992 book Genetic Programming. The key insight is to represent programs as expression trees — branching structures where inner nodes are operations (, , , , , , …) and leaves are constants or input variables. A formula like becomes a tree with at the root, and as children of the left branch, and so on.
Once programs are trees, Darwin's toolkit applies directly:
- Selection: prefer trees whose output fits the target data better (lower error = higher fitness).
- Crossover: swap a random subtree from one parent into another, mixing "genetic material."
- Mutation: replace a random subtree with a freshly generated one, adding new building blocks.
Over hundreds of generations a population of random trees converges on formulas that would have been hard to design by hand — and sometimes discovers ones that surprise even the researchers.
Genetic programming lives in the broader family of evolutionary computation, and it shares deep roots with the search problems studied in P vs NP: finding the best tree in a vast search space is, in general, intractable.
Comments
Loading comments...