Four strings of five bits, scored by $f(x) = x^2$, are paired up, cut, and their pieces swapped. In one generation the best score rises from 576 to 729, because two of the children join good pieces that no single parent held. Run to the end from another random start, a population of four loses a bit value for good and settles one bit short of the optimum. This unit sets out when a population that recombines its members searches better than a single hill climber, and what makes it fail.
A genetic algorithm (GA) searches with a population of candidates, each encoded as a string, classically of bits, and improves it one generation at a time. Selection gives better candidates more offspring. Crossover builds each offspring from pieces of two parents, and mutation changes a few positions at random. John Holland developed the method in the 1960s and 1970s as a model of adaptation, and David Goldberg's 1989 textbook made it the best-known evolutionary algorithm. Since then genetic algorithms have been applied to scheduling, design, routing, and parameter tuning, often with representations far from Holland's bit strings.
A population changes what search can do. Hill climbing keeps one candidate and stops at the first local optimum it reaches. A population can hold candidates in several regions of the search space at once, and crossover can combine good parts found by different candidates. Both advantages are conditional:
- selection that is too strong collapses the population onto one region before it has explored;
- crossover helps only when the encoding places related parts of a solution near each other, and when the problem can be solved by combining parts.
Most of this topic is about those conditions, in four steps: the algorithm and its encoding; selection and the operators; what the schema theorem explains, and how constraints are handled; and two of the course's assignments, retested by repeated runs.
Three examples run through the unit: Goldberg's $x^2$ problem on 5-bit strings, small enough to work by hand; OneMax, from the foundations, whose optimum is known; and De Jong's test functions, whose real-valued variables must be encoded in bits.
The unit builds on the evolutionary algorithm loop and on natural selection for computer scientists, which introduces the selection recursion, takeover, and genetic drift.
Articles
The algorithm
- The simple genetic algorithm: specifies the canonical GA completely and measures where it falls short. The $x^2$ example by hand, a run that converges prematurely, and three weaknesses measured on OneMax.
- Binary encoding and Gray codes: sets out how a real number is written as bits, and shows that the code changes which candidates a mutation can reach. Precision, Hamming cliffs, the reflected Gray code, and a 30-seed comparison on two De Jong functions, where Gray coding helped on one and not on the other.
Operators and selection
- Selection pressure and premature convergence: measures how strongly each selection scheme favors the best, and describes what happens when a scheme favors them too much. The common selection schemes, takeover time checked against simulation, elitism, and niching.
- Crossover and mutation operators: shows how the standard operators make valid children, and how each one sets the distance between children and parents. Binary, real-coded and permutation operators, from one-point crossover to BLX-α, SBX, PMX, order and cycle crossover, with an interactive demo.
Theory and constraints
- Holland's schema theorem: states Holland's account, that short, good patterns of bits spread and combine, as a lower bound on a pattern's expected count, and shows that the bound holds but does not explain why a GA works. The theorem derived and checked on the $x^2$ example, the building block hypothesis, and why later theory found them incomplete.
- Constraint handling in evolutionary algorithms: sets out what a GA can do with a child that violates a constraint. Penalties, Deb's feasibility rules, stochastic ranking, repair and decoders, compared on a standard problem.
From my course work
- A binary GA on De Jong's test functions: shows which conclusions of single runs hold up over repeated runs. The single runs showed that the algorithm worked, and were not enough to compare encodings or rank the functions. The course's second assignment, De Jong's original definitions, and the results repeated over 30 seeds, with the multimodal F5 added.
- A genetic algorithm for bin packing: traces a gap of about four times the optimum to the encoding and objective, not the instances. The course's third assignment extended with a lower bound, First Fit Decreasing, and a permutation encoding with a first-fit decoder.
Related topics
Genetic algorithms extend the single-candidate search of local search, and their behavior depends on the fitness landscape their encoding and operators induce. Multi-objective optimization adapts selection to several objectives at once. Genetic programming applies the same loop to programs. Evolution strategies take a different route to real-valued optimization, adapting the mutation distribution itself.
What comes next
A genetic algorithm ranks candidates by one fitness value, but many problems have conflicting objectives, such as cost against strength, and no single best answer. The next topic, multi-objective optimization, begins with Pareto dominance.
References
- Eiben, A. E., and Smith, J. E. (2015). Introduction to Evolutionary Computing, 2nd ed. Springer. record · 35 pages
- Goldberg, D. E. (1989). Genetic Algorithms in Search, Optimization, and Machine Learning. Addison-Wesley. record · 6 pages
- Holland, J. H. (1975). Adaptation in Natural and Artificial Systems. University of Michigan Press. record · 5 pages
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 16 Nov 2026 · 4 revisions