← All projects

Evolutionary Sport Pools Optimizer

Evolutionary AlgorithmsNumPyOptimization

In amateur sports leagues, teams are split into regional pools, and each team plays everyone in its pool. A bad split means hours of extra driving every other weekend, something I know well as a volleyball player in Bordeaux (the most isolated city in all of France, as you can see on the map below). So I wrote a small genetic algorithm, in NumPy only, to find pools that minimize the total distance traveled.

How it works

You give the optimizer a list of city names, the number of pools and a population size. GPS coordinates are fetched automatically (with geopy) and turned into a pairwise distance matrix. Each chromosome is an array assigning every city to a pool (with a max of 12 teams per pool), and its fitness is the sum of distances between all teams of the same pool.

At each iteration:

cities = ['Nantes', 'Toulouse', 'Talence', 'Tours', ...]
opt = EvoPoolOpt(cities_list=cities, nb_pools=6, nb_chromosomes=100)
opt.optimize(num_iterations=50_000)
opt.display_map_pools_configuration(opt.best_chromosome)

Result

Map of France with clubs colored by their assigned pool, forming compact regional groups
Optimized pools for the 2022/2023 French National 3 volleyball division (one color per pool).

The final split forms compact regional groups. The repo includes a notebook reproducing this real use case.

Code