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

Use Timestamp Information to Limit the Route Between States in the HMM #840

Merged
merged 16 commits into from
Jul 24, 2017

Conversation

kevinkreiser
Copy link
Member

the whole point of this is that it fixes #620

given a trace with time information at each point, we can in a similar way to what is done with max_route_distance_factor, disallow the adding of edge labels to the route if the route is too long in estimated time with respect to the actual time given in the measurements. basically we prune the route search space to not entertain paths that traveled too much distance or time much time with some factor of the original time and distance traveled between two measurements.

there are a couple of other things in this pr as well...

the first is that i've updated the trace_* actions to parse the time, accuracy and radius readings out of the shape parameter. this is still not supported within encoded shapes but can be added in the future. its useful for the tests, which i need to add more to convince myself that we really are excluding impossibly fast paths. although...

the other change i had to make was for the traffic segment matcher tests. since it cares about times by default adding the max_route_time_factor meant the absurdly fast times i was putting into those tests broke them. i had to multiply the numbers by 100 to get those tests to pass with the max_route_time_factor set to 5

@@ -38,7 +38,8 @@ bool LabelSet::put(const baldr::GraphId& nodeid, const baldr::GraphId& edgeid,
// Create a new label and push it to the queue
if (it == node_status_.end()) {
const uint32_t idx = labels_.size();
if (sortcost < max_cost_) {
// We only add the labels if we are under the limits for distance and for time or time limit is 0
if (cost.cost < max_dist_ && (max_time_ == 0.f || cost.secs < max_time_)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the important part, we dont let the path expand if the distance or time is unreasonable

@@ -84,7 +85,8 @@ bool LabelSet::put(uint16_t dest,
// Create a new label and push it to the queue
if (it == dest_status_.end()) {
const uint32_t idx = labels_.size();
if (sortcost < max_cost_) {
// We only add the labels if we are under the limits for distance and for time or time limit is 0
if (cost.cost < max_dist_ && (max_time_ == 0.f || cost.secs < max_time_)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

same here

@@ -572,18 +574,21 @@ find_shortest_path(baldr::GraphReader& reader,
if (endtile == nullptr) {
continue;
Copy link
Member

Choose a reason for hiding this comment

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

consider putting endtile (and check for null) inside conditional for adding label. The vast majority case is that the label will not be added due to exceeding cost or time threshold, and very small chance of endtile being null (and saving computation of cost).

@ptpt
Copy link
Collaborator

ptpt commented Jul 21, 2017

Why moving the max cost check out from LabelSet::put? It might be simpler if you initialize LabelSet with the max cost max_time_ == 0.f ? max_dist_ : max_time_ in https://github.com/valhalla/valhalla/blob/master/src/meili/map_matching.cc#L49.

@kevinkreiser
Copy link
Member Author

@ptpt indeed, i had it that way and it was simpler: daf4687#diff-ce82e081c326c4ceefc3894638159018L54

but @dnesbitt61 said that wrt the future:

wondering if the decision whether to add a label should be in routing rather than pushed down to Labelset...just thinking that maybe LabelSet should be a low-level library for storing labels and updating the priority_queue and that the routing class should be where the decision to add a label is made? Not sure if we could/would move LabelSet to be a shared common library between meili and thor, but embedding meili specific logic may make that more difficult.`

@ptpt
Copy link
Collaborator

ptpt commented Jul 21, 2017

I see. Make sense to keep it outside. Having this logic in LabelSet is also fine if we think of it as a queue with capacity.

Copy link
Collaborator

@ptpt ptpt left a comment

Choose a reason for hiding this comment

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

Some comments.

@@ -46,11 +51,12 @@ State::route(const std::vector<const State*>& states,
}

// Route
labelset_ = std::make_shared<LabelSet>(std::ceil(max_route_distance));
labelset_ = std::make_shared<LabelSet>(max_route_distance);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here should be passing max_route_time as well if it is available.

Copy link
Member Author

Choose a reason for hiding this comment

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

i did that in a previous commit, but then i reverted it since i moved the check of the max time out of the labelset. how would i make use of it if i pass in max_route_distance?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry false alarm. It should be max_route_distance, because the sort cost in the queue is always distance.

@@ -15,12 +15,11 @@ namespace valhalla {

namespace meili {

LabelSet::LabelSet(const float max_cost, const float bucket_size) {
LabelSet::LabelSet(const float max_dist, const float bucket_size) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here LabelSet only cares about cost regardless it is distance or time, max_cost would be a more proper name than max_dist.

Copy link
Member Author

Choose a reason for hiding this comment

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

i only changed it because on one of the commits i was still passing in time and it seemed odd to name one cost and one time. so i named them both what they were, dist and time. now that its just dist again i can rename it back to cost.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok i did that!

&destinations, &search_radius, &search_rad2, &costing, &travelmode, &label_cost,
&label_turn_cost, &turn_cost_table, &heuristic, &expand]
(const baldr::GraphId& node, const uint32_t label_idx, const bool from_transition) {
expand = [&](const baldr::GraphId& node, const uint32_t label_idx, const bool from_transition) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@ptpt
Copy link
Collaborator

ptpt commented Jul 21, 2017

🚢

@dnesbitt61
Copy link
Member

:shipit:

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

Successfully merging this pull request may close these issues.

map matching score using time values
3 participants