Avoiding repetition (out-and-backs)
Published 2020-02-02
As a runner myself, one of the things I like least on my runs (apart from busy roads) is repetition, or "out-and-backs" as they're commonly known. So when I built Trail Router, I had in the back of my mind that I'd like to be able to specify a preference for avoiding repetition in my routes.
This feature is now available! Just go to the settings menu (click on the cog) and check the 'Avoid repetition' box.
Here's a before and after example of what it does:
Before (left) and after (right). The route on the right was generated with the 'Avoid repetition' option checked. Click to expand.
The screenshot on the left shows a 15km round-trip route from Epping tube station in London. It follows the main path through Epping Forest, which is indeed a very nice route, but you can see that it's created a pure out-and-back route, so is quite repetitive. The screenshot on the right shows the same 15km round-trip route request from Epping tube station, but this time with the 'Avoid repetition' option checked. This route is slightly longer, but still takes nice paths through Epping Forest and - crucially - avoids repetition.
Implementing this feature turned out to be easier said than done. Trail Router will naturally prefer the 'greenest' path, and when creating a round-trip route it's quite common that the suggested route is an out-and-back. Technically this is correct, as it's giving you the greenest route, but it's also frustrating if you like variety. The solution was to modify the core of the routing algorithm to dynamically add a penalty weight for a path (or 'edge' as it's called internally) once it's been chosen. This means that it is less likely to be chosen again on the return leg (but it doesn't completely prevent it, e.g. if it's the only viable option).
Avoiding repetition is now enabled by default. You can disable it in the settings menu if you prefer.
Happy repetition-free running!