Idea
Create functionality to provide users with optimized routes for completing desired streets
Imagined Interface
-Separate map interface
-User can select a general area, or specific streets
-Toggle option to require hitting all selected streets or only the currently incomplete streets of those selected
-Option to define starting point
-Toggle option for requiring end point to be the same as starting point, or not
Imagined Output
-Map with proposed paths drawn over it
-List of directions
Challenges
-This is an extremely complex issue⊠CPP is known to be NP-hard
-Complexity of finding optimal solution increases exponentially with node/street counts: some upper limit would almost definitely be needed
-Besides the upfront time for UI development & solution scripting, the ongoing computational demands to provide solutions for users would be significant
-The whole topic may be entirely tangential to what CityStrides is, and what the community wants
Nonetheless, thought there may be some other users here who have wondered about this so I wanted to start a thread to discuss.
(fun fact, it was in applying this problem in one of Vancouverâs parks that ultimately introduced me to CityStrides! Thanks, @supermitch)
@ccottell mentioned the ideas of TSP/CPP in a recent thread, but was focused on UI changes that would help compare completed iterations of cities, not actually solving how best to do them.
Continuing the discussion from Time based filtering and challenges:
I like that your idea includes an imagined interface - this helps a lot!
Iâve been researching third party tooling/software that I might be able to use to achieve this. It was a little while ago, now, but I did get a (not incredibly functional) proof-of-concept working with Mapbox Directions.
One hurdle I have is that each Streetâs Nodes arenât in âorderâ, so thereâs no default first/last Node or an inherently ordered ânextâ Node from any given Node. So I couldnât toss a bunch of Nodes at the routing engine and say âgive me a route from [starting point], past all of these nodes, and back to [ending point]â. One approach I tried was to use first/last Nodes, but that ended up with the same trouble â although â Iâve had another idea of splitting my Streets up into pieces (in the database/not in a way thatâs visible to users), because thatâs how OpenStreetMap stores them. Those pieces may have better-defined starts/ends, so that approach could solve the problem (or at least help).
Its a real challenge because the main difficulty of street coverage is to find an optimal path and optimize the running distance.
I am using the beta CPP Solver released as a QGIS plugin. I donât think that tool can be used at a larger scale but maybe the released code can help in some way.
This solver needs to create a layer, so I first download the streets of my city boundaries with the useful QuickOSM plugin that create the overpass query and download data directly a s a layer in QGIS (highway=â*â)
Then I select the linestrings layer,
in this layer, I use the selection tool to select an area
Now I launch the CPP Solver (use a small area because it can be time consuming)
Then I can select the layer
and right click to export the CPP layer in GPX Format
Now I have just to download the route to my watch with the upload tool
I think this confirms my idea of using the pieces of streets that OSM stores. Iâll check out that code - thanks.
I havenât used QGIS yet, but itâs interesting how similar your process is to the overall CityStrides process. If you have access to the underlying Overpass query, you might benefit from: Overpass Street Query
I agree with you that OSM and the street query are the main reliable source of data.
as a novice in overpass, for my personal use i used the query generated by the point and click âQuickOSM pluginâ which has a lot of garbage : cycleways, pathways, private ways
I will try to figure out how to use the citystrides overpass query to retrieve my area streets in QGIS to proof the experimental CPP solver. Overpass Turbo is a great tool to convert your Overpass query in xml for my proof of concept
I have updated OSM data by setting a name on the small road parts around the roundabout.
Now the topology should be better and results to a better generated route (i.e. smaller)
Note that if you plan to use an algorithm like the CPP Solver the efficiency of the results (i.e. the lengh of the generated route compared to the length of the streets) will rely on a very good topology and a good acquisition on crossing data. I had a quick look at the python code, although I am not a programmer i saw it uses a networkx package function to calculate things like âmaxcardinalityâ of nodes" so a higher cardinality should maybe results to more efficient routes.
Also to avoid long calculation time , a good Idea would be to have a strong selection of the streets limited to a certain distance. : the user could point a starting mark and an approximative run distance, then a first pass could select a set of streets in the area : uncovered streets could have a better weight, also choosing nodes could result in a better execution of the solver and a minimum of distance overhead.
My tests convinced me that maybe a solver may need more highways than your standard overpass streets query and a slightly different query with more highways types like âfootwaysâ or âpathwaysâ that can provide the necessary links or path to have an efficient route.
Without those links, you would be missing nodes and therefore âcardinalityâ resulting in larger distance :
(in example above, the railway would be difficult to cross without exluded âhighwaysâ and generate longer running routes.
@christophe.cr92 Holy Smokes! This is definitely more information & ideas than I thought I would get out starting this thread. Iâm currently downloading QGIS, and at some point will try checking out the plugin you mentioned as well. Thank you!!
@christophe.cr92 I really like the idea of using a starting mark and run distance, and letting the program figure out where to go/ how to do it, thatâs an interesting inversion of the problem Iâve never considered.
Obviously in the example you provided there were quite a few edits required in OSM- have you often found this to be the case? I wonder if using this generally requires fixes like that. I guess maybe the cost of having that functionality is improving OSM all over our desired runs
Yes citystriding runs requires so much attention to memorize the streets you have covered, i went to the conclusion that Osm itself coupled with a small algorithm (have a look at the CCP code it looks so pure and simple) could make the process of covering a maximum number of street in a minimum distance easily.
There is no need to update Osm , i did it because my first attempt to build a route was based on the citystride streets list query.
i tested a different query to build the route: a less restrictive overpass query that retrieves small pathes, roundabouts, bridgeways that citystrides excludes in his query (in my example excluding pathways with noname)
At this point i imagine the following process
point a starting point , a distance
query a list or uncovered streets, put a Weight on them
query highways to improve connecting points ignored by citystrides
(By quey i mean overpass query)
The main concern is to improve connections points between streets without generating to much secondary or residential ways : sometimes you need to cross a railway for example but that path is not covered by citystrides . That bridge could save a lot of distance.
Oh yes and you can download the quickosm plugin which helps to retrieve data from Osm with overpass quey (you can cut and paste the official query and play with exclusions, itâs a good starting point)
Itâs amazing the progress i made in building a gpx route in a few days with that method
Interesting idea, I read that Ricky Gates used some sort of algorithm from the post office to help plan. On a personal idea part of the challenge for me is to figure out my own approach to this
It then will then solve the Chinese Postman Problem and then do an optimization to get the minimum number of U-turns of that given Euler Circuit. It then generates a gpx file for you and also print a map.
I had a similar question to Dave Morinâs OP here, but the subsequent discussion went over my head pretty quickly⊠Iâm wondering if there have been any developments towards a tool for dummies like me to use to plan optimized routes?
Over the [UK] lockdown I got interested in this [running] challenge and as mathematicians and software engineer I come up with this web app: http://www.everystreetchallenge.com which tries to solve the CPP on OpenStreetMap. Hopefully it will solve some of your problems, even though it is not perfect as it considers only public streets accessible for cars.
Thanks for sharing. Iâll definitely be giving this a go. Even if it doesnât account for footpath-shortcuts Iâm sure itâll still be a lot more efficient (and less time consuming) than my current route planning!
Yeah, the footpaths are a real hassle. I could turn layer walk on but unfortunately there are many more problems with having it, e.g. many town consider a road with footpath on both sides as 2 separates streets.
I am happy and open to suggestions how to make the algorithm better
If you are super super interested in the algorithm I wrote some rough theoretical summary [1] and there is a GitHub repo with an algorithm sketch [2].