Genetic algorithms
A genetic algorithm searches for good answers the way breeding does. It keeps a population of candidates, mixes the fitter ones and repeats over many generations.
A genetic algorithm is a way of searching for a good answer that copies natural selection. It keeps a population of candidate answers. Each candidate is a string of values called genes, sometimes called a chromosome. A fitness function gives every candidate a score. Fitter candidates are more likely to become parents. Their genes are mixed by crossover and nudged by random mutation, and the children form the next generation. Over many generations the population tends to move towards better answers.
The method needs no slope, only a score. That helps when the score jumps, is noisy or comes from a simulation. For NASA’s Space Technology 5 mission, researchers used evolutionary algorithms, the family genetic algorithms belong to, to design an antenna. The result had an odd, organic shape that expert designers would probably not have drawn. It took about three person-months to design and build, against about five for a conventional antenna. Researchers at Uber AI Labs used a simple genetic algorithm to set the weights of deep neural networks that play Atari games.
The field traces back to John H. Holland, whose book MIT Press calls the one that started it. Today, Python libraries such as DEAP and PyGAD let a programmer plug in their own fitness function. The price is patience. A genetic algorithm usually needs many evaluations, and it offers no promise of reaching the best answer.
Some problems cannot be solved by following a slope downhill.
Follow one generation of a toy problem.
- 1 · encodeWrite each candidate answer as a string of values, called genes, and fill a first population with random strings.
- 2 · scoreA fitness function gives every candidate a number that says how good it is.
- 3 · selectCandidates with better fitness are more likely to be chosen as parents, though chance still plays a part.
- 4 · crossoverTwo parents are combined into children, for example by cutting both at the same point and swapping the ends.
- 5 · mutateA few genes change at random, then the new generation is scored and the loop repeats.
The algorithm never needs to know why a candidate is good. It only needs a fitness score for each one.
| Who | What they ask | What it works with |
|---|---|---|
| Spacecraft antenna team | “What wire shape meets our signal and size targets?” | Antenna designs, each scored in an electromagnetic simulator |
| Reinforcement learning researcher | “Can this game-playing network be trained without gradients?” | The network's weights, treated as one long string of genes |
| Machine learning engineer | “Which settings give this model its best score?” | Candidate settings, each scored by training and testing a model |
| Student learning the method | “How fast can a population reach a string of all 1s?” | The OneMax toy problem in the DEAP library |
- Works when the score cannot be differentiated, for example when it jumps, is noisy or is highly nonlinear.
- Keeps a whole population of candidates, and that variety lets it search a larger region than one guess would.
- Can find designs people would not draw, such as NASA's oddly shaped ST5 antenna.
- Can train neural network weights. One study evolved networks with over four million parameters.
- It usually needs many fitness evaluations, which is slow when each one runs a simulation.
- It may or may not reach the best answer, or even a locally best one.
- A person still chooses the encoding, the fitness function and settings such as crossover and mutation rates.
- It is not always better than gradient methods. In one deep learning study it won on some games and lost on others.
Sources used
This explainer is written in original language. The links below support its factual claims.
- docsWhat Is the Genetic Algorithm?, MathWorks (Global Optimization Toolbox documentation) · read 27 Sept 2026
- docsGenetic Algorithm Terminology, MathWorks (Global Optimization Toolbox documentation) · read 27 Sept 2026
- docsOne Max Problem (DEAP documentation), DEAP project · read 27 Sept 2026
- paperAutomated Antenna Design with Evolutionary Algorithms, NASA Technical Reports Server (Hornby et al., AIAA Space 2006) · read 27 Sept 2026
- paperDeep Neuroevolution: Genetic Algorithms Are a Competitive Alternative for Training Deep Neural Networks for Reinforcement Learning, Such et al., Uber AI Labs (arXiv) · read 27 Sept 2026
- docsPyGAD: Python Genetic Algorithm, PyGAD project · read 27 Sept 2026
- docspygad Module, PyGAD project · read 27 Sept 2026
- officialAdaptation in Natural and Artificial Systems, The MIT Press · read 27 Sept 2026