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

Allow abitrary edge weights #2399

Merged
merged 8 commits into from
Jan 27, 2017
Merged

Allow abitrary edge weights #2399

merged 8 commits into from
Jan 27, 2017

Conversation

TheMarex
Copy link
Member

@TheMarex TheMarex commented May 12, 2016

This PR aims to finally implement #77.

Where we are now:

  • ExtractionWay has a new property weight_per_meter that we pull through the whole pipeline to the server. It is exposed over the fields named weight (analogous to duration).
  • ProfileProperties has a new property weight_name

TODO

  • This needs a rebase, probably conflicts with the Datafacade changes.
  • weight_per_meter is a wrong name. This was an oversight from my part: It actually encodes weight_per_second (analogous to speed being meters_per_second) We need to rename this. /cc @karenzshea
  • We need to integrate Profile version #3487 to check the profile version:
    • The interface between ScriptingEnvironment and EdgeBasedGraphFactory here needs to work with both API version
    • The interface between ScriptingEnvironment and ExtractionContainers here also needs to work with both API version.
    • Profile API version 0: We expect the current implementation of turn_function and segment_function and silently fallback to weight = duration (this needs wrapper code in ScriptingEnvironment::ProcessTurn and ScriptingEnvironment::ProcessSegment)
    • Profile API version 1: We expect turn_function and segment_function to follow the scheme already implemented in this PR

@TheMarex TheMarex changed the title Allow abitrary edge weights [not ready] Allow abitrary edge weights May 12, 2016
@danpat
Copy link
Member

danpat commented May 12, 2016

Capturing from chat:

what we really want from this is to not need to worry any more about what metric we put in and still get correct durations.

  • Let's worry about memory consumption later - let's see how useful this feature turns out first before we optimize.
  • The duration data needs to support turn penalties. If we do time-as-weight routing, we need to support them there too. We can store them at the end of the GetUncompressedWeights array, it'll add 4 bytes for each compressed geometry.
  • Let's only support a weight_per_distance value from the user, rather than arbitrary total values. Everything gets scaled by the length of the road.
  • The way_function can return two values per way - speed and weight_per_distance (note that both these fields are per-distance measurements).
  • The turn_function can return two values - time_penalty and weight_penalty

For traffic data imports, let's look at some use cases:

  • if we're doing fastest-time routing, we will need to update both the routing weight and the stored durations
  • if we're doing shortest-distance routing, but adjusting durations for traffic, we need to update the stored durations, but not the weight
  • if we're trying to support "minimize toll costs" in a situation where tolls are changing constantly (dynamic pricing), but without traffic data, we would need to update the weights, but not the durations

The last case is a bit of a stretch, I couldn't think of a better example. But the point is that we probably need to be able to update both with the CSV import. I think we could do:

  • update the CSV file to have 4 columns, nodeA,nodeB,speed,weight_per_distance
  • supply a second CSV file with nodeA,nodeB,weight_per_distance

I think if we simply don't supply data, we can efficiently skip either the duration and/or weight updates.

@emiltin
Copy link
Contributor

emiltin commented May 12, 2016

wow, this has been a long time coming! it will be very useful for bike routing

@TheMarex
Copy link
Member Author

nodeA,nodeB,speed,weight_per_distance

We can update the data with regard to the names given in the csv header column.

@TheMarex TheMarex added this to the 6.0 milestone May 23, 2016
@TheMarex TheMarex force-pushed the feature/edge_weights branch 3 times, most recently from 92bdb88 to b03c3a6 Compare June 12, 2016 19:20
@TheMarex TheMarex force-pushed the feature/edge_weights branch from 45f9d06 to d6754a6 Compare June 22, 2016 11:20
@@ -154,7 +154,7 @@ class GraphContractor
for (auto diter = input_edge_list.dbegin(); diter != dend; ++diter)
{
BOOST_ASSERT_MSG(static_cast<unsigned int>(std::max(diter->weight, 1)) > 0,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't max(weight,1) always >0, especially since we cast to an unsigned?

@TheMarex TheMarex force-pushed the feature/edge_weights branch from e6181c5 to cf3eee4 Compare July 1, 2016 12:54
@@ -71,7 +71,9 @@ struct ExtractorConfig
rtree_nodes_output_path = basepath + ".osrm.ramIndex";
rtree_leafs_output_path = basepath + ".osrm.fileIndex";
edge_segment_lookup_path = basepath + ".osrm.edge_segment_lookup";
edge_penalty_path = basepath + ".osrm.edge_penalties";
turn_duration_penalties_path = basepath + ".osrm.turn_weight_penalties";
turn_weight_penalties_path = basepath + ".osrm.turn_duration_penalties";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the values are swapped:
turn_weight_penalties → turn_duration_penalties and vice versa

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch 👍

@TheMarex TheMarex force-pushed the feature/edge_weights branch from 3d11c97 to a06f134 Compare August 1, 2016 09:30
@TheMarex
Copy link
Member Author

TheMarex commented Aug 1, 2016

Things to do here:

  • Split interleaved CompressedGeometryContainer serialization into separate vectors
  • Only load the duration vector if weight doesn't contain the same values (safes memory consumption)
  • Make duration values in osrm-contract updatable

duration_penalty += profile_properties.traffic_signal_penalty;
}

if (use_turn_function)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use_turn_function is not defined, may the changeset it is incomplete?

@oxidase
Copy link
Contributor

oxidase commented Aug 17, 2016

Hi, i have almost finished rebase of the PR to master, but some parts are missing. If it is interesting, i can create a duplicate PR with rebased patches.

@TheMarex
Copy link
Member Author

@oxidase Let me just give your contributor access so you can push directly to this branch.

This was referenced Aug 18, 2016
@TheMarex TheMarex changed the title [not ready] Allow abitrary edge weights [wip] Allow abitrary edge weights Aug 19, 2016
@oxidase oxidase force-pushed the feature/edge_weights branch from 6a4a2a4 to f316d03 Compare August 21, 2016 15:29
@oxidase
Copy link
Contributor

oxidase commented Aug 21, 2016

Please review a forced rebase of the branch to master. I have modified some commits, changed some properties in profiles and changed TurnPenalty to int16_t to make all tests green.

@oxidase oxidase force-pushed the feature/edge_weights branch from e186963 to 8d1f156 Compare January 26, 2017 21:27
@oxidase
Copy link
Contributor

oxidase commented Jan 26, 2017

@TheMarex updated and rebased the brach, but in some places i did not make changes:

  • traffic_light_penalty is still used in turn_function to have old behavior, because TODO fix is required
  • MAX_WEIGHT_NAME_LENGTH is still a value in enum
  • forward_heap_3 and reverse_heap_3 are still in use
  • FIXME is still there but now related only the situation when source and target phantoms on one edge

@oxidase oxidase force-pushed the feature/edge_weights branch from 8d1f156 to 28589e7 Compare January 26, 2017 21:45
@oxidase oxidase force-pushed the feature/edge_weights branch 2 times, most recently from 28b1c6e to 02880cf Compare January 26, 2017 22:16
@TheMarex
Copy link
Member Author

traffic_light_penalty is still used in turn_function to have old behavior, because TODO fix is required

You are right, I confused myself with my own changelog entry. Currently it is:

  • traffic_light_penalty is deprecated. traffic light penalties now need to be set over in the node function in result.weight_penalty and result.duration_penalty fields

Correct however would be:

  • properties.traffic_light_penalty is deprecated. Traffic light penalties now need to be set over in the turn function. Each turn with a traffic light is marked with ExtractionTurn::has_traffic_light = true.

This looks good to me. I think we can merge this (wow so weird).

@oxidase
Copy link
Contributor

oxidase commented Jan 26, 2017

looks like std::size_t is not integral type? will change to static constexpr int MAX_WEIGHT_NAME_LENGTH = 255;

@oxidase oxidase force-pushed the feature/edge_weights branch from 02880cf to f6dca2b Compare January 26, 2017 23:01
@djschilling
Copy link

Thanks for all the effort you are putting into this.
This pull request getting merged is really great for us.

@danpat
Copy link
Member

danpat commented Jan 27, 2017

@djschilling @emiltin and anyone else who has been watching this ticket - we've merge into master but feedback on this feature would be really helpful. Anyone who has the time to test it out, please do and open tickets with any problems/confusion you encounter.

@djschilling
Copy link

We are using an earlier state of the pull request since the start of the year and it does exactly what it should.
We use it to correctly handle access:destination tags, by putting a high weight to access:destination ways.

One thing that we encountered is a performance loose from about 40%. Its not critical for us, but i think its worth mentioning.
I have no time now to test the currently merged version, so feedback from someone else would probably be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.