-
Notifications
You must be signed in to change notification settings - Fork 658
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
Conversation
…omputing the transmission cost
…shouldnt involve time
…shapes when fail occurs
src/meili/routing.cc
Outdated
@@ -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_)) { |
There was a problem hiding this comment.
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
src/meili/routing.cc
Outdated
@@ -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_)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
src/meili/routing.cc
Outdated
@@ -572,18 +574,21 @@ find_shortest_path(baldr::GraphReader& reader, | |||
if (endtile == nullptr) { | |||
continue; |
There was a problem hiding this comment.
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).
Why moving the max cost check out from |
@ptpt indeed, i had it that way and it was simpler: daf4687#diff-ce82e081c326c4ceefc3894638159018L54 but @dnesbitt61 said that wrt the future:
|
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments.
src/meili/map_matching.cc
Outdated
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/meili/routing.cc
Outdated
@@ -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) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
🚢 |
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 thetime
,accuracy
andradius
readings out of theshape
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 themax_route_time_factor
set to5