Improve alternative route speed?

When using alternative_route algorithm, the route takes 7-15 seconds which is “too long” for my customers.

I cannot keep ch.disable=false, because the alternative route is terrible.

Is there any way (memory settings?) to speed up algorithm=alternative_route&ch.disable=true?

Which alternative route is terrible? Did you try landmarks?

I was unaware of landmarks, but I’m going to try it now that you mention it. I assume it can do alternative routes? Edit: Answer is Yes according to : A new "hybrid" mode: ALT = A* with landmarks

I didn’t check the demo route till now, but it actually takes the best route. Mine doesn’t for some reason.
On my server, best route is given as an alternative which is OK with me. The reason I can’t is that if I enable alternative routes, with distances over 50 miles and near cities, it takes so long that users think the app is broken. Thus I had to disable alternative. Now they cry the route isn’t ideal. I can’t win :pensive:

Either way it would be nice to provide alternative routes at a reasonable speed like 1-2 seconds for a 80 mile/128 kilometer route. Hopefully landmarks can do that.

DEMO, “BEST” ROUTE:
https://graphhopper.com/maps/?point=36.260134%2C-98.479582&point=35.754692%2C-98.772191&locale=en-US&vehicle=car&weighting=fastest&elevation=false&turn_costs=false&use_miles=false&layer=Omniscale

MINE (edited):
https://graphhopper.com/maps/?point=36.260134%2C-98.479582&point=35.840559%2C-98.42308&point=35.754692%2C-98.772191&locale=en-US&vehicle=car&weighting=fastest&elevation=false&turn_costs=false&use_miles=false&layer=Omniscale

“TERRIBLE” ALT ROUTE GIVEN WITH CH.DISABLE=FALSE
https://graphhopper.com/maps/?point=36.260134%2C-98.479582&point=36.144667%2C-98.934288&point=35.923393%2C-98.973427&point=35.754692%2C-98.772191&locale=en-US&vehicle=car&weighting=fastest&elevation=false&turn_costs=false&use_miles=false&layer=Omniscale

Yes it works with landmarks. Just make sure not to confuse landmarks=ALT(“A-Star,Landmarks,Triangular inequality”) with alternative routes.

Thanks for providing this example. Alternative route calculations use some heuristics so the outcome might be bad sometimes. In any case its helpful to collect such examples when trying to improve. You can also try to increase alternative_route.max_paths to get more alternatives and sort/filter them by distance or something.

I added a profile to the profiles_lm, and then with a request I disabled ch. Is there more needed? It doesn’t seem to be working. I tried various requests parameters but no success.

config.yml

  profiles_lm:
    - profile: car

request log

/route?
INFO  c.g.resources.RouteResource - point=36.2689248,-98.4798009&point=35.841421485359,-98.755128097001&vehicle=car&locale=en&points_encoded=false&routing.lm.disable=false&ch.disable=true&algorithm=alternative_route en_US Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 [36.2689248,-98.4798009, 35.841421485359,-98.755128097001], took: 17.0ms, algo: alternative_route, profile: car, weighting: , vehicle: car, alternatives: 1, distance0: 98731.04476888648, weight0: 5689.829001183669, time0: 95min, points0: 454, debugInfo: idLookup:4.92058E-4s; simplify (565->565)

It looks like you got a fast response:

What do you mean “It doesn’t seem to be working”? Do you mean you get only one route? What happens when you try different routes (change start/end markers)? Also try disable.lm=true to disable landmarks. With this you should get the same result as before, but a slower response.

It wasn’t providing alternative routes, but it’s all working now. I was using v1, and updated to v2. It provides alternatives at light speed. Plus the “best” route according to my user is now being used. Seems that Graphhopper development is going just as fast :smiley:

Thanks for helping me with this @easbar ! :+1:

1 Like

Glad to hear its working for you :+1:

I discovered the reason it worked is because I used short_fastest instead of fastest. It seems to use the actual fastest route according to customers and other routing engines.

“Best”
https://graphhopper.com/maps/?point=36.260134%2C-98.479582&point=35.754692%2C-98.772191&locale=en-US&vehicle=car&weighting=short_fastest&elevation=false&ch.disable=true&algorithm=alternative_route
vs
“Not the Best”
https://graphhopper.com/maps/?point=36.260134%2C-98.479582&point=35.754692%2C-98.772191&locale=en-US&vehicle=car&weighting=fastest&elevation=false&ch.disable=true&algorithm=alternative_route

I did find one where the alternative route took a residential road instead of going a bit further and using secondary/tertiary roads which seemed more logical. Obviously that’s what it’s supposed to do, but I’m hoping to modify it.

I looked at weighting.md and ShortFastestWeighting.java to see if I could slightly adjust it, but some of my brain cells popped when I tried :confounded:

I wonder if you might point me in the right direction? How would I get it to prefer higher road classifications which is actually faster due to turns/speed limits?

I also tried messing with short_fastest.distance_factor, but it never took a different route. I tried setting it to 0.0, 1.0 and everything in between. I couldn’t get it to choose the tertiary road.

routingExamples

Powered by Discourse