How geographic algorithms helped a logistics company optimise its delivery process.

In this article, BB’s Machine Learning Developer, Nico Lutz, describes how he built an algorithm that keeps scheduled deliveries running smoothly while adding new, cost-effective routes.
When a Norwegian B2B logistics company, partnered with Bakken & Bæck in 2022, it marked the beginning of a major digital transformation. Together, the teams set out to design and build a custom Transport Management System (TMS) that would replace their existing tools with a unified platform for next-generation digital services.
The company has built its service on reliability and consistency—some clients even write exact delivery times into their contracts. To meet that expectation, drivers follow fixed routes so customers get the same driver at the same time every day. But this model comes with a challenge: there’s no ready-made software that can add new deliveries without disrupting the schedule. BB addressed this challenge with routing optimisation algorithms.

Routing optimisation algorithms
Routing optimisation algorithms work in the following way. Imagine a food delivery company that picks up from restaurants and delivers to hungry individuals. The algorithm factors in elements such as distance, real-time traffic conditions, delivery time windows, and vehicle capacity to create optimised paths that enhance productivity. The algorithm can then be left to move resources where they are most needed. This approach streamlines operations across industries and platforms that we use every day, from Google Maps to shipping services.
Solving the dynamic stop insertion problem
The first step was to create a process for inputting geographic data in a unified way. Once we had the correct data, we used route-optimisation models to address the “dynamic stop insertion” problem: determining which extra stops drivers could reliably make between scheduled drop-offs.
We used the Travelling Salesman Problem, and more specifically its variant, the Vehicle Routing Problem with Time Windows (VRPTW), to find the shortest feasible routes for multiple vehicles subject to timing constraints. We found that “dynamic stop insertion” would require a VRPTW variant: inserting new stops into fixed routes with minimal added travel time while preserving all existing time windows.
We then used distance and time matrices from Open Source Routing Machine (OSRM), a tool similar to Google Maps, to compute all possible routes between points A and B and provide the travel time or distance for each route. Our algorithm then evaluated each new stop one by one, considering all possible insertion points in the existing routes. For each stop, it selects the position that incurs the least additional travel time while ensuring that all time window constraints remain valid.
Scaling the greedy heuristics approach
This step-by-step, “greedy heuristic” approach treats each stop independently rather than optimising all stops at once, providing a simple, practical solution that doesn’t require complex tuning. To scale this approach effectively, we added a few practical shortcuts to reduce computational complexity. First, the algorithm ignores clearly unsuitable routes. For example, a delivery in Oslo wouldn’t be considered for routes serving Buskerud. The system also checks for duplicate addresses, so we don’t waste time inserting stops that are already on a route.
BB’s approach to this project worked particularly well in Norway’s challenging geography, where dispersed populations can make traditional route-optimisation approaches less effective.
The new TMS system has now been live for over a year. It includes a driver app, internal tools, and an enterprise platform to manage routes, deliveries, and staff. Hundreds of drivers now use the new app every day, demonstrating that legacy companies with manual processes can use automation to transform into a next-generation digital service.