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

Fix two vias on oneway #1503

Merged
merged 4 commits into from
May 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions features/testbot/via.feature
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Feature: Via points
| 1,3,2 | ab,bc,cd,cd,de,ef,fa,ab,bc | 1600m +-1 | head,straight,straight,via,right,right,right,right,straight,destination |
| 3,2,1 | cd,de,ef,fa,ab,bc,bc,cd,de,ef,fa,ab | 2400m +-1 | head,right,right,right,right,straight,via,straight,right,right,right,right,destination |

@bug
Scenario: Via points on ring on the same oneway
# xa it to avoid only having a single ring, which cna trigger edge cases
Given the node map
Expand All @@ -97,6 +96,6 @@ Feature: Via points
| waypoints | route | distance | turns |
| 1,3 | ab | 200m +-1 | head,destination |
| 3,1 | ab,bc,cd,da,ab | 800m +-1 | head,right,right,right,right,destination |
| 1,2,3 | ab | 200m +-1 | head,destination |
| 1,3,2 | ab,bc,cd,da,ab | 1100m +-1 | head,right,right,right,right,destination |
| 3,2,1 | ab,bc,cd,da,ab,bc,cd,da,ab | 1600m +-1 | head,right,right,right,right,right,right,right,right,destination |
| 1,2,3 | ab,ab | 200m +-1 | head,via,destination |
| 1,3,2 | ab,ab,bc,cd,da,ab | 1100m +-1 | head,via,right,right,right,right,destination |
| 3,2,1 | ab,bc,cd,da,ab,ab,bc,cd,da,ab | 1800m | head,right,right,right,right,via,right,right,right,right,destination |
60 changes: 17 additions & 43 deletions routing_algorithms/shortest_path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,66 +92,42 @@ class ShortestPathRouting final

const bool allow_u_turn = current_leg > 0 && uturn_indicators.size() > current_leg &&
uturn_indicators[current_leg - 1];
EdgeWeight min_edge_offset = 0;
const EdgeWeight min_edge_offset =
std::min(phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());

// insert new starting nodes into forward heap, adjusted by previous distances.
if ((allow_u_turn || search_from_1st_node) &&
phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID)
{
forward_heap1.Insert(
phantom_node_pair.source_phantom.forward_node_id,
(allow_u_turn ? 0 : distance1) -
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
-phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.source_phantom.forward_node_id);
min_edge_offset =
std::min(min_edge_offset,
(allow_u_turn ? 0 : distance1) -
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " <<
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0
// : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
forward_heap2.Insert(
phantom_node_pair.source_phantom.forward_node_id,
(allow_u_turn ? 0 : distance1) -
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
-phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.source_phantom.forward_node_id);
min_edge_offset =
std::min(min_edge_offset,
(allow_u_turn ? 0 : distance1) -
phantom_node_pair.source_phantom.GetForwardWeightPlusOffset());
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " <<
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << (allow_u_turn ? 0
// : distance1) - phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
// phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
}
if ((allow_u_turn || search_from_2nd_node) &&
phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID)
{
forward_heap1.Insert(
phantom_node_pair.source_phantom.reverse_node_id,
(allow_u_turn ? 0 : distance2) -
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
-phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.source_phantom.reverse_node_id);
min_edge_offset =
std::min(min_edge_offset,
(allow_u_turn ? 0 : distance2) -
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
// SimpleLogger().Write(logDEBUG) << "fwd-a2 insert: " <<
// phantom_node_pair.source_phantom.reverse_node_id <<
// ", w: " << (allow_u_turn ? 0 : distance2) -
// phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
// phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
forward_heap2.Insert(
phantom_node_pair.source_phantom.reverse_node_id,
(allow_u_turn ? 0 : distance2) -
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
-phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.source_phantom.reverse_node_id);
min_edge_offset =
std::min(min_edge_offset,
(allow_u_turn ? 0 : distance2) -
phantom_node_pair.source_phantom.GetReverseWeightPlusOffset());
// SimpleLogger().Write(logDEBUG) << "fwd-b2 insert: " <<
// phantom_node_pair.source_phantom.reverse_node_id <<
// ", w: " << (allow_u_turn ? 0 : distance2) -
// phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
// phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
}

// insert new backward nodes into backward heap, unadjusted.
Expand All @@ -161,9 +137,7 @@ class ShortestPathRouting final
phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(),
phantom_node_pair.target_phantom.forward_node_id);
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
// phantom_node_pair.target_phantom.forward_node_id <<
// ", w: " <<
// phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
// phantom_node_pair.target_phantom.forward_node_id << ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
}

if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID)
Expand All @@ -172,9 +146,7 @@ class ShortestPathRouting final
phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(),
phantom_node_pair.target_phantom.reverse_node_id);
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
// phantom_node_pair.target_phantom.reverse_node_id <<
// ", w: " <<
// phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
// phantom_node_pair.target_phantom.reverse_node_id << ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
}

// run two-Target Dijkstra routing step.
Expand Down Expand Up @@ -300,11 +272,13 @@ class ShortestPathRouting final
if (start_id_of_leg1 != last_id_of_packed_legs1)
{
packed_legs1 = packed_legs2;
distance1 = distance2;
BOOST_ASSERT(start_id_of_leg1 == temporary_packed_leg1.front());
}
else if (start_id_of_leg2 != last_id_of_packed_legs2)
{
packed_legs2 = packed_legs1;
distance2 = distance1;
BOOST_ASSERT(start_id_of_leg2 == temporary_packed_leg2.front());
}
}
Expand Down Expand Up @@ -332,8 +306,8 @@ class ShortestPathRouting final
BOOST_ASSERT(search_from_1st_node != search_from_2nd_node);
}

distance1 = local_upper_bound1;
distance2 = local_upper_bound2;
distance1 += local_upper_bound1;
distance2 += local_upper_bound2;
++current_leg;
}

Expand Down