Case study · Algorithms

Rules-aware multi-leg route planning

Implemented · heavily tested (static) · local

Small trucking companies lose money when a high-paying load leaves a truck stranded far from its next job. The planning engine looks two and three loads ahead: it checks pickup times, empty miles and driver hours on every leg, then ranks complete routes by what the carrier actually keeps after fuel.

Overview

The planning engine is a Python 3.12 system with a hexagonal structure and almost no third-party dependencies. It builds two-leg routes through anchor markets and fills idle gaps with a third leg. Every candidate is evaluated against one continuous hours-of-service timeline, covering the 11-hour and 14-hour limits, and against a temporal-reachability rule that also decides which dates are worth searching.

Candidates are pruned into a nine-anchor beam that the type system enforces, so an unpruned set can never reach data acquisition, then ranked over named criteria in order rather than by an opaque weighted score. Market data arrives through a socket contract with a separate browser-automation system and a read-only stream of the board's own responses.

The RouteDawg backend reaches the engine through versioned JSON contracts. The codebase carries about 290 test files, and its load economics are mutation-tested in isolated extracts (36 of 36 targeted mutants caught, documented).