Evolutionary Algorithms

A genetic algorithm and an evolution strategy, tuned to compete on benchmark problems.

This one was run as a class competition. Everyone tackled the same benchmark problems and the point was to squeeze out the best result you could. My partner and I wrote two optimisers from scratch and spent most of our time tuning them. Pair project for the Evolutionary Algorithms course at Leiden University.

The genetic algorithm converging on one of the benchmark problems.

Links · 💻 Code · 📄 Report

The two optimisers

The first is a genetic algorithm for binary problems, with tournament selection, uniform crossover, bit flip mutation and elitism. What makes it more than a textbook version is a memetic twist. When the search stalls it first runs a local hill climber on the best solution, and only if that fails does it throw part of the population away and restart. We ran it on two hard binary benchmark problems, low autocorrelation binary sequences and n queens.

The second is a diagonal CMA-ES for continuous problems, which adapts the size of its search steps along each axis as it goes. We ran that on the Katsuura function.

Tuning

Rather than guess the settings, we tuned the genetic algorithm with Optuna under a fixed budget, letting it search for the population size, the crossover and mutation rates and so on that gave the best combined score. The convergence and spread of the final runs are in the report.