Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route found is not optimal. #6853

Closed
N40 opened this issue Apr 30, 2024 · 3 comments
Closed

Route found is not optimal. #6853

N40 opened this issue Apr 30, 2024 · 3 comments
Labels

Comments

@N40
Copy link

N40 commented Apr 30, 2024

Issue

Abstract:

A route is obviously not optimal with regards to its arrival orientation. A obviously better routing option is not chosen.
Adding an arrival bearing or adding an additional step decreases the duration.

Example

Screenshot 2024-04-30 at 08 14 26

Steps to reproduce

See Links above

Specifications

/

@N40 N40 added the Bug Report label Apr 30, 2024
@jcoupey
Copy link

jcoupey commented Apr 30, 2024

You're only reporting route duration values, but internally OSRM miminizes weight, which can differ from duration. The purpose of weight is to be able to apply penalties in the profile while not messing with actual travel times.

What you're seeing is that for the route you get, duration and weight are identical, while for the alternatives weight is much higher despite duration being smaller.

So it is definitely not an OSRM bug, it's more related to the weighting decisions inside the routing profile. This is what would need investigating if you think the profile can be improved in some way. Maybe worth looking closely at the debug map around that area.

@danpat
Copy link
Member

danpat commented Apr 30, 2024

I think the main issue here is around what to do when a point is dropped close to an intersection.

Screenshot 2024-04-30 at 2 33 28 am

A few things are confounding each other here:

  1. OSRM finds the distance to the nearest edges and sorts them by distance, and picks the nearest.
  2. It doesn't care about precision - if the math says it's 0.01mm closer, it'll pick that. If there are several edges that are equi-distant, then the one picked depends on the packing order in the R-Tree that we searched, which is effectively random.
  3. This coordinate looks to be dropped near an intersection - mapping precision is not in the sub-mm range.
  4. It's working out that OSRM thinks it is closest to the outgoing road heading south-east.
  5. By default, u-turns are not performed at waypoints in the car profile.

There are a few ways to address the problem:

  1. Move the coordinate a bit so it's not so close to an ambiguous point.
  2. Add continue_straight=false to your API calls (although you'll still get some funny instructions about turning left, etc along the way)
  3. In theory, OSRM could do some special handling when we snap very close to the start of an edge - we could add several nearby edges as potential candidates for the destination. This old ticket kind of describes the problem and what needs to get implemented: Make route selection consistent #3991
  4. If this happens to you a lot, and your routes are short, try using the /matching API instead along with the waypoints= parameter - it kind of performs the logic in (3) and you can probably get OK results.

@N40
Copy link
Author

N40 commented May 2, 2024

@jcoupey Thanks for the hint to investigate the weight

I found out that there is a 3000ish weight surplus due to a single road being entered. Here is an example where a detour an alternative detour is thus viable.

http://router.project-osrm.org/route/v1/driving/10.908039808273315,49.89198032006379;10.908088088035583,49.89192848119509

Screenshot 2024-05-02 at 10 29 37

I suppose that either of

access = permissive
highway = service
vehicle = destination

is causing the penalty.

I will look into using weight='duration' as profile.

Thank you!

@N40 N40 closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants