diff --git a/Contractor/GeometryCompressor.cpp b/Contractor/GeometryCompressor.cpp index 9691a6f44..c2b7c16d8 100644 --- a/Contractor/GeometryCompressor.cpp +++ b/Contractor/GeometryCompressor.cpp @@ -81,7 +81,7 @@ void GeometryCompressor::SerializeInternalVector(const std::string & path) const // write indices array unsigned prefix_sum_of_list_indices = 0; - for(unsigned i = 0; i < m_compressed_geometries.size(); ++i ) + for (unsigned i = 0; i < m_compressed_geometries.size(); ++i) { geometry_out_stream.write( (char*)&prefix_sum_of_list_indices, diff --git a/DataStructures/PhantomNodes.h b/DataStructures/PhantomNodes.h index bb8fa267b..e7389474d 100644 --- a/DataStructures/PhantomNodes.h +++ b/DataStructures/PhantomNodes.h @@ -59,14 +59,26 @@ struct PhantomNode int GetForwardWeightPlusOffset() const { - SimpleLogger().Write(logDEBUG) << "->fwd_offset: " << forward_offset << ", weight: " << forward_weight; - return reverse_offset + forward_weight; + if (SPECIAL_NODEID == forward_node_id) + { + return 0; + } + // SimpleLogger().Write(logDEBUG) << "->fwd_offset: " << forward_offset << ", weight: " << forward_weight; + const int result = (forward_offset + forward_weight); + // SimpleLogger().Write(logDEBUG) << "forward queue weight: " << result; + return result; } int GetReverseWeightPlusOffset() const { - SimpleLogger().Write(logDEBUG) << "->rev_offset: " << reverse_offset << ", weight: " << reverse_weight; - return forward_offset + reverse_weight; + if (SPECIAL_NODEID == reverse_node_id) + { + return 0; + } + // SimpleLogger().Write(logDEBUG) << "->rev_offset: " << reverse_offset << ", weight: " << reverse_weight; + const int result = (reverse_offset + reverse_weight); + // SimpleLogger().Write(logDEBUG) << "reverse queue weight: " << result; + return result; } void Reset() @@ -103,8 +115,6 @@ struct PhantomNode (forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT) ) && - // (ratio >= 0.) && - // (ratio <= 1.) && (name_id != std::numeric_limits::max() ); } @@ -141,6 +151,31 @@ struct PhantomNodes { return source_phantom == target_phantom; } + + bool ComputeForwardQueueOffset() const + { + if (source_phantom.forward_node_id == target_phantom.forward_node_id) + { + const int forward_queue_weight = source_phantom.GetForwardWeightPlusOffset(); + const int reverse_queue_weight = target_phantom.GetForwardWeightPlusOffset(); + const int weight_diff = (forward_queue_weight - reverse_queue_weight); + SimpleLogger().Write(logDEBUG) << "fwd queue offset: " << std::max(0, weight_diff); + return 0;//std::max(0, weight_diff); + } + return 0; + } + + bool ComputeReverseQueueOffset() const + { + if (source_phantom.reverse_node_id == target_phantom.reverse_node_id) + { + const int forward_queue_weight = source_phantom.GetReverseWeightPlusOffset(); + const int reverse_queue_weight = target_phantom.GetReverseWeightPlusOffset(); + const int weight_diff = (forward_queue_weight - reverse_queue_weight); + return 0;//std::max(0, weight_diff); + } + return 0; + } }; inline std::ostream& operator<<(std::ostream &out, const PhantomNodes & pn) diff --git a/DataStructures/StaticRTree.h b/DataStructures/StaticRTree.h index 699603617..9047d5b7b 100644 --- a/DataStructures/StaticRTree.h +++ b/DataStructures/StaticRTree.h @@ -765,21 +765,21 @@ public: if (SPECIAL_NODEID != result_phantom_node.forward_node_id) { - result_phantom_node.forward_weight *= (ratio); + result_phantom_node.forward_weight *= ratio; } - if( SPECIAL_NODEID != result_phantom_node.reverse_node_id ) + if (SPECIAL_NODEID != result_phantom_node.reverse_node_id) { - result_phantom_node.reverse_weight *= 1.-ratio; + result_phantom_node.reverse_weight *= (1.-ratio); } - // result_phantom_node.ratio = ratio; SimpleLogger().Write(logDEBUG) << "result location: " << result_phantom_node.location << ", start: " << current_start_coordinate << ", end: " << current_end_coordinate; SimpleLogger().Write(logDEBUG) << "fwd node: " << result_phantom_node.forward_node_id << ", rev node: " << result_phantom_node.reverse_node_id; - SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight;// << ", ratio: " << result_phantom_node.ratio; - SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset;// << ", ratio: " << result_phantom_node.ratio; + SimpleLogger().Write(logDEBUG) << "fwd weight: " << result_phantom_node.forward_weight << ", rev weight: " << result_phantom_node.reverse_weight; + SimpleLogger().Write(logDEBUG) << "fwd offset: " << result_phantom_node.forward_offset << ", rev offset: " << result_phantom_node.reverse_offset; SimpleLogger().Write(logDEBUG) << "bidirected: " << (result_phantom_node.isBidirected() ? "y" : "n"); SimpleLogger().Write(logDEBUG) << "name id: " << result_phantom_node.name_id; SimpleLogger().Write(logDEBUG) << "geom id: " << result_phantom_node.packed_geometry_id; + SimpleLogger().Write(logDEBUG) << "ratio: " << ratio; return found_a_nearest_edge; } diff --git a/Descriptors/DescriptionFactory.cpp b/Descriptors/DescriptionFactory.cpp index 2b8b41a71..45cc584da 100644 --- a/Descriptors/DescriptionFactory.cpp +++ b/Descriptors/DescriptionFactory.cpp @@ -61,7 +61,7 @@ double DescriptionFactory::GetBearing(const FixedPointCoordinate & A, const Fixe result -= 360.; } - SimpleLogger().Write(logDEBUG) << "bearing between " << A << " and " << B << " is " << result; + // SimpleLogger().Write(logDEBUG) << "bearing between " << A << " and " << B << " is " << result; return result; } @@ -72,8 +72,8 @@ void DescriptionFactory::SetStartSegment(const PhantomNode & source, const bool int rev_weight = source.reverse_weight; int fwd_offset = source.forward_offset; int rev_offset = source.reverse_offset; - SimpleLogger().Write(logDEBUG) << "df source, traversed in reverse: " << (source_traversed_in_reverse ? "y" : "n") << ", location: " << source.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; - SimpleLogger().Write(logDEBUG) << "duration of first segment: " << (source_traversed_in_reverse ? source.GetReverseWeightPlusOffset() : source.GetForwardWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "df source, traversed in reverse: " << (source_traversed_in_reverse ? "y" : "n") << ", location: " << source.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; + // SimpleLogger().Write(logDEBUG) << "duration of first segment: " << (source_traversed_in_reverse ? source.GetReverseWeightPlusOffset() : source.GetForwardWeightPlusOffset()); start_phantom = source; AppendSegment( source.location, @@ -87,8 +87,8 @@ void DescriptionFactory::SetEndSegment(const PhantomNode & target, const bool ta int rev_weight = target.reverse_weight; int fwd_offset = target.forward_offset; int rev_offset = target.reverse_offset; - SimpleLogger().Write(logDEBUG) << "df target, traversed in reverse: " << (target_traversed_in_reverse ? "y" : "n") << ", location: " << target.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; - SimpleLogger().Write(logDEBUG) << "duration of last segment: " << (target_traversed_in_reverse ? target.GetReverseWeightPlusOffset() : target.GetForwardWeightPlusOffset()); + // SimpleLogger().Write(logDEBUG) << "df target, traversed in reverse: " << (target_traversed_in_reverse ? "y" : "n") << ", location: " << target.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; + // SimpleLogger().Write(logDEBUG) << "duration of last segment: " << (target_traversed_in_reverse ? target.GetReverseWeightPlusOffset() : target.GetForwardWeightPlusOffset()); target_phantom = target; pathDescription.push_back( diff --git a/Descriptors/DescriptionFactory.h b/Descriptors/DescriptionFactory.h index 08e1cfb87..3d5f49bb6 100644 --- a/Descriptors/DescriptionFactory.h +++ b/Descriptors/DescriptionFactory.h @@ -115,7 +115,7 @@ public: for (unsigned i = 0; i < pathDescription.size(); ++i) { const std::string name = facade->GetEscapedNameForNameID(pathDescription[0].name_id); - SimpleLogger().Write(logDEBUG) << "df [" << i << "] name: " << name << ", duration: " << pathDescription[i].duration << ", length: " << pathDescription[i].length << ", coordinate: " << pathDescription[i].location; + // SimpleLogger().Write(logDEBUG) << "df [" << i << "] name: " << name << ", duration: " << pathDescription[i].duration << ", length: " << pathDescription[i].length << ", coordinate: " << pathDescription[i].location; } /*Simplify turn instructions diff --git a/Descriptors/JSONDescriptor.h b/Descriptors/JSONDescriptor.h index ba3f84594..559e8e2db 100644 --- a/Descriptors/JSONDescriptor.h +++ b/Descriptors/JSONDescriptor.h @@ -134,13 +134,13 @@ public: int rev_weight = phantom_nodes.source_phantom.reverse_weight; int fwd_offset = phantom_nodes.source_phantom.forward_offset; int rev_offset = phantom_nodes.source_phantom.reverse_offset; - SimpleLogger().Write(logDEBUG) << "json source: " << name << ", location: " << phantom_nodes.source_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; + // SimpleLogger().Write(logDEBUG) << "json source: " << name << ", location: " << phantom_nodes.source_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; name = facade->GetEscapedNameForNameID(phantom_nodes.target_phantom.name_id); fwd_weight = phantom_nodes.target_phantom.forward_weight; rev_weight = phantom_nodes.target_phantom.reverse_weight; fwd_offset = phantom_nodes.target_phantom.forward_offset; rev_offset = phantom_nodes.target_phantom.reverse_offset; - SimpleLogger().Write(logDEBUG) << "json target: " << name << ", location: " << phantom_nodes.target_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; + // SimpleLogger().Write(logDEBUG) << "json target: " << name << ", location: " << phantom_nodes.target_phantom.location << ", fwd_weight: " << fwd_weight << ", fwd_offset: " << fwd_offset << ", rev_weight: " << rev_weight << ", rev_offset: " << rev_offset; //TODO: replace the previous logic with this one. @@ -148,21 +148,21 @@ public: //check if first segment is non-zero std::string road_name; int source_duration = phantom_nodes.source_phantom.GetForwardWeightPlusOffset(); - SimpleLogger().Write(logDEBUG) << "-> source_traversed_in_reverse: " << (raw_route.source_traversed_in_reverse ? "y" : "n"); + // SimpleLogger().Write(logDEBUG) << "-> source_traversed_in_reverse: " << (raw_route.source_traversed_in_reverse ? "y" : "n"); if (!raw_route.source_traversed_in_reverse) { source_duration = phantom_nodes.source_phantom.GetReverseWeightPlusOffset(); } BOOST_ASSERT(source_duration >= 0); road_name = facade->GetEscapedNameForNameID(phantom_nodes.source_phantom.name_id); - if (source_duration > 0) - { - SimpleLogger().Write(logDEBUG) << "adding source \"" << road_name << "\" at " << phantom_nodes.source_phantom.location << ", duration: " << source_duration; - } - else - { - SimpleLogger().Write(logDEBUG) << "ignoring source \"" << road_name << "\""; - } + // if (source_duration > 0) + // { + // SimpleLogger().Write(logDEBUG) << "adding source \"" << road_name << "\" at " << phantom_nodes.source_phantom.location << ", duration: " << source_duration; + // } + // else + // { + // SimpleLogger().Write(logDEBUG) << "ignoring source \"" << road_name << "\""; + // } // TODO, for each unpacked segment add the leg to the description BOOST_ASSERT( raw_route.unpacked_path_segments.size() == raw_route.segmentEndCoordinates.size() ); @@ -170,14 +170,14 @@ public: for (unsigned i = 0; i < raw_route.unpacked_path_segments.size(); ++i) { const std::vector & leg_path = raw_route.unpacked_path_segments[i]; - const PhantomNodes & leg_phantoms = raw_route.segmentEndCoordinates[i]; - SimpleLogger().Write(logDEBUG) << " Describing leg from " << leg_phantoms.source_phantom.location << " and " << leg_phantoms.target_phantom.location; + // const PhantomNodes & leg_phantoms = raw_route.segmentEndCoordinates[i]; + // SimpleLogger().Write(logDEBUG) << " Describing leg from " << leg_phantoms.source_phantom.location << " and " << leg_phantoms.target_phantom.location; FixedPointCoordinate current_coordinate; BOOST_FOREACH(const PathData & path_data, leg_path) { current_coordinate = facade->GetCoordinateOfNode(path_data.node); road_name = facade->GetEscapedNameForNameID(path_data.name_id); - SimpleLogger().Write(logDEBUG) << " adding way point for \"" << road_name << "\" at " << current_coordinate << ", duration: " << path_data.durationOfSegment; + // SimpleLogger().Write(logDEBUG) << " adding way point for \"" << road_name << "\" at " << current_coordinate << ", duration: " << path_data.durationOfSegment; } } @@ -191,15 +191,15 @@ public: } BOOST_ASSERT(target_duration >= 0); - if (target_duration > 0) - { - SimpleLogger().Write(logDEBUG) << "adding target \"" << road_name << "\" at " << phantom_nodes.target_phantom.location << ", duration: " << target_duration; - } - else - { - SimpleLogger().Write(logDEBUG) << "ignoring target \"" << road_name << "\""; - } - SimpleLogger().Write(logDEBUG) << "-> target_traversed_in_reverse: " << (raw_route.target_traversed_in_reverse ? "y" : "n"); + // if (target_duration > 0) + // { + // SimpleLogger().Write(logDEBUG) << "adding target \"" << road_name << "\" at " << phantom_nodes.target_phantom.location << ", duration: " << target_duration; + // } + // else + // { + // SimpleLogger().Write(logDEBUG) << "ignoring target \"" << road_name << "\""; + // } + // SimpleLogger().Write(logDEBUG) << "-> target_traversed_in_reverse: " << (raw_route.target_traversed_in_reverse ? "y" : "n"); //END OF TODO diff --git a/RoutingAlgorithms/AlternativePathRouting.h b/RoutingAlgorithms/AlternativePathRouting.h index c7571403f..acadc9a44 100644 --- a/RoutingAlgorithms/AlternativePathRouting.h +++ b/RoutingAlgorithms/AlternativePathRouting.h @@ -49,21 +49,18 @@ class AlternativeRouting : private BasicRoutingInterface { typedef SearchEngineData::QueryHeap QueryHeap; typedef std::pair SearchSpaceEdge; - struct RankedCandidateNode { - RankedCandidateNode( - const NodeID node, - const int length, - const int sharing - ) : - node(node), - length(length), - sharing(sharing) + struct RankedCandidateNode + { + RankedCandidateNode(const NodeID node, const int length, const int sharing) + : node(node), length(length), sharing(sharing) { } NodeID node; int length; int sharing; - bool operator<(const RankedCandidateNode& other) const { + + bool operator<(const RankedCandidateNode& other) const + { return (2*length + sharing) < (2*other.length + other.sharing); } }; @@ -92,7 +89,7 @@ public: ) { // raw_route_data.lengthOfShortestPath = INVALID_EDGE_WEIGHT; // raw_route_data.lengthOfAlternativePath = INVALID_EDGE_WEIGHT; - SimpleLogger().Write(logDEBUG) << "not executing path search"; + // SimpleLogger().Write(logDEBUG) << "not executing path search"; return; } @@ -120,7 +117,7 @@ public: int upper_bound_to_shortest_path_distance = INVALID_EDGE_WEIGHT; NodeID middle_node = SPECIAL_NODEID; if(phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID ) { - SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); + SimpleLogger().Write(logDEBUG) << "fwd-a insert: " << phantom_node_pair.source_phantom.forward_node_id << ", w: " << -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(); forward_heap1.Insert( phantom_node_pair.source_phantom.forward_node_id, -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset(), @@ -128,7 +125,7 @@ public: ); } if(phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID ) { - SimpleLogger().Write(logDEBUG) << "fwd insert: " << phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); + SimpleLogger().Write(logDEBUG) << "fwd-b insert: " << phantom_node_pair.source_phantom.reverse_node_id << ", w: " << -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(); forward_heap1.Insert( phantom_node_pair.source_phantom.reverse_node_id, -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset(), @@ -137,7 +134,7 @@ public: } if(phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID ) { - SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.forward_node_id << ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(); + SimpleLogger().Write(logDEBUG) << "rev-a insert: " << phantom_node_pair.target_phantom.forward_node_id << ", w: " << phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(); reverse_heap1.Insert( phantom_node_pair.target_phantom.forward_node_id, phantom_node_pair.target_phantom.GetForwardWeightPlusOffset(), @@ -145,7 +142,7 @@ public: ); } if(phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID ) { - SimpleLogger().Write(logDEBUG) << "rev insert: " << phantom_node_pair.target_phantom.reverse_node_id << ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(); + SimpleLogger().Write(logDEBUG) << "rev-b insert: " << phantom_node_pair.target_phantom.reverse_node_id << ", w: " << phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(); reverse_heap1.Insert( phantom_node_pair.target_phantom.reverse_node_id, phantom_node_pair.target_phantom.GetReverseWeightPlusOffset(), @@ -153,14 +150,16 @@ public: ); } - const int forward_offset = super::ComputeEdgeOffset( - phantom_node_pair.source_phantom - ); - const int reverse_offset = super::ComputeEdgeOffset( - phantom_node_pair.target_phantom - ); + const int forward_offset = phantom_node_pair.ComputeForwardQueueOffset(); + // const int forward_offset = super::ComputeEdgeOffset( + // phantom_node_pair.source_phantom + // ); + const int reverse_offset = phantom_node_pair.ComputeReverseQueueOffset(); + // const int reverse_offset = super::ComputeEdgeOffset( + // phantom_node_pair.target_phantom + // ); - SimpleLogger().Write(logDEBUG) << "fwd_offset: " << forward_offset << ", reverse_offset: " << reverse_offset; + // SimpleLogger().Write(logDEBUG) << "fwd_offset: " << forward_offset << ", reverse_offset: " << reverse_offset; //search from s and t till new_min/(1+epsilon) > length_of_shortest_path while(0 < (forward_heap1.Size() + reverse_heap1.Size())){ @@ -188,9 +187,9 @@ public: } } - SimpleLogger().Write(logDEBUG) << "found " << via_node_candidate_list.size() << " unique via node candidates"; + // SimpleLogger().Write(logDEBUG) << "found " << via_node_candidate_list.size() << " unique via node candidates"; sort_unique_resize( via_node_candidate_list ); - SimpleLogger().Write(logDEBUG) << "found " << via_node_candidate_list.size() << " unique via node candidates"; + // SimpleLogger().Write(logDEBUG) << "found " << via_node_candidate_list.size() << " unique via node candidates"; std::vector packed_forward_path; std::vector packed_reverse_path; @@ -208,7 +207,7 @@ public: //TODO: leave early when no path found: - SimpleLogger().Write(logDEBUG) << "ub: " << upper_bound_to_shortest_path_distance; + // SimpleLogger().Write(logDEBUG) << "ub: " << upper_bound_to_shortest_path_distance; boost::unordered_map approximated_forward_sharing; boost::unordered_map approximated_reverse_sharing; @@ -251,8 +250,8 @@ public: } } - SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " << forward_search_space.size() << ", marked " << approximated_forward_sharing.size() << " nodes"; - SimpleLogger().Write(logDEBUG) << "rev_search_space size: " << reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << " nodes"; + // SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " << forward_search_space.size() << ", marked " << approximated_forward_sharing.size() << " nodes"; + // SimpleLogger().Write(logDEBUG) << "rev_search_space size: " << reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << " nodes"; std::vector preselected_node_list; BOOST_FOREACH(const NodeID node, via_node_candidate_list) { @@ -272,7 +271,7 @@ public: } } - SimpleLogger().Write() << preselected_node_list.size() << " passed preselection"; + // SimpleLogger().Write() << preselected_node_list.size() << " passed preselection"; std::vector & packed_shortest_path = packed_forward_path; std::reverse(packed_shortest_path.begin(), packed_shortest_path.end()); @@ -345,7 +344,7 @@ public: raw_route_data.unpacked_path_segments.front() ); raw_route_data.lengthOfShortestPath = upper_bound_to_shortest_path_distance; - SimpleLogger().Write(logDEBUG) << "upper_bound_to_shortest_path_distance: " << upper_bound_to_shortest_path_distance; + // SimpleLogger().Write(logDEBUG) << "upper_bound_to_shortest_path_distance: " << upper_bound_to_shortest_path_distance; } if( SPECIAL_NODEID != selected_via_node ) { @@ -372,7 +371,7 @@ public: ); raw_route_data.lengthOfAlternativePath = length_of_via_path; - SimpleLogger().Write(logDEBUG) << "length_of_via_path: " << length_of_via_path; + // SimpleLogger().Write(logDEBUG) << "length_of_via_path: " << length_of_via_path; } } @@ -635,7 +634,7 @@ private: ) const { const NodeID node = forward_heap.DeleteMin(); const int distance = forward_heap.GetKey(node); - const int scaled_distance = (distance-edge_expansion_offset)/(1.+VIAPATH_EPSILON); + const int scaled_distance = distance/(1.+VIAPATH_EPSILON); // SimpleLogger().Write(logDEBUG) << "node: " << node << ", distance: " << distance << ", ub: " << *upper_bound_to_shortest_path_distance << ", scaled_distance: " << scaled_distance; if( (INVALID_EDGE_WEIGHT != *upper_bound_to_shortest_path_distance) && @@ -650,12 +649,14 @@ private: std::make_pair(forward_heap.GetData( node ).parent, node) ); - if( reverse_heap.WasInserted(node) ) { + if (reverse_heap.WasInserted(node)) { search_space_intersection.push_back(node); const int new_distance = reverse_heap.GetKey(node) + distance; - if( new_distance < *upper_bound_to_shortest_path_distance ){ - if( new_distance >= 0 ) { + if (new_distance < *upper_bound_to_shortest_path_distance) + { + if ((new_distance + edge_expansion_offset) >= 0) + { *middle_node = node; *upper_bound_to_shortest_path_distance = new_distance; } diff --git a/RoutingAlgorithms/BasicRoutingInterface.h b/RoutingAlgorithms/BasicRoutingInterface.h index bd23bf37a..4071734c7 100644 --- a/RoutingAlgorithms/BasicRoutingInterface.h +++ b/RoutingAlgorithms/BasicRoutingInterface.h @@ -64,22 +64,27 @@ public: int * upper_bound, const int edge_expansion_offset, const bool forward_direction - ) const { + ) const + { const NodeID node = forward_heap.DeleteMin(); const int distance = forward_heap.GetKey(node); // SimpleLogger().Write() << (forward_direction ? "fwd" : "rev") << " settled (" << forward_heap.GetData( node ).parent << "," << node << ")=" << distance; - if(reverse_heap.WasInserted(node) ){ + if (reverse_heap.WasInserted(node)) + { const int new_distance = reverse_heap.GetKey(node) + distance; // SimpleLogger().Write(logDEBUG) << "new_distance: " << new_distance; - if(new_distance < *upper_bound ){ - if( new_distance >= 0 ) { + if(new_distance < *upper_bound ) + { + if( new_distance + edge_expansion_offset >= 0 ) + { *middle_node_id = node; *upper_bound = new_distance; } } } - if( (distance-edge_expansion_offset) > *upper_bound ){ + if (distance > *upper_bound) + { // SimpleLogger().Write() << "found path"; forward_heap.DeleteAll(); return; @@ -186,7 +191,7 @@ public: } } if( SPECIAL_EDGEID == smaller_edge_id ){ - SimpleLogger().Write() << "checking reverse"; + // SimpleLogger().Write() << "checking reverse"; for( EdgeID edge_id = facade->BeginEdges(edge.second); edge_id < facade->EndEdges(edge.second); @@ -236,7 +241,7 @@ public: const int start_index = ( unpacked_path.empty() ? ( ( start_traversed_in_reverse ) ? id_vector.size() - phantom_node_pair.source_phantom.fwd_segment_position - 1 : phantom_node_pair.source_phantom.fwd_segment_position ) : 0 ); const int end_index = id_vector.size(); std::string name = facade->GetEscapedNameForNameID(name_index); - SimpleLogger().Write(logDEBUG) << "compressed via segment " << name << " from [" << start_index << "," << end_index << "]"; + // SimpleLogger().Write(logDEBUG) << "compressed via segment " << name << " from [" << start_index << "," << end_index << "]"; BOOST_ASSERT( start_index >= 0 ); @@ -297,7 +302,7 @@ public: } } - SimpleLogger().Write(logDEBUG) << "fetching target segment from [" << start_index << "," << end_index << "]"; + // SimpleLogger().Write(logDEBUG) << "fetching target segment from [" << start_index << "," << end_index << "]"; BOOST_ASSERT( start_index >= 0 ); for( @@ -308,7 +313,7 @@ public: BOOST_ASSERT( i >= -1 ); if ( i >= 0 ) { - SimpleLogger().Write(logDEBUG) << "target [" << i << "]" << facade->GetCoordinateOfNode(id_vector[i]); + // SimpleLogger().Write(logDEBUG) << "target [" << i << "]" << facade->GetCoordinateOfNode(id_vector[i]); } unpacked_path.push_back( PathData( @@ -320,11 +325,11 @@ public: ); } } - BOOST_FOREACH(const PathData & path_data, unpacked_path) - { - std::string name = facade->GetEscapedNameForNameID(path_data.name_id); - SimpleLogger().Write(logDEBUG) << "{up} node: " << path_data.node << ", " << facade->GetCoordinateOfNode(path_data.node) << ", name: " << name; - } + // BOOST_FOREACH(const PathData & path_data, unpacked_path) + // { + // std::string name = facade->GetEscapedNameForNameID(path_data.name_id); + // SimpleLogger().Write(logDEBUG) << "{up} node: " << path_data.node << ", " << facade->GetCoordinateOfNode(path_data.node) << ", name: " << name; + // } // there is no equivalent to a node-based node in an edge-expanded graph. // two equivalent routes may start (or end) at different node-based edges @@ -341,7 +346,7 @@ public: if (unpacked_path[last_index].node == unpacked_path[second_to_last_index].node) { - SimpleLogger().Write(logDEBUG) << "{rm} node: " << unpacked_path.back().node; + // SimpleLogger().Write(logDEBUG) << "{rm} node: " << unpacked_path.back().node; unpacked_path.pop_back(); } BOOST_ASSERT(!unpacked_path.empty()); @@ -450,19 +455,19 @@ public: } } - int ComputeEdgeOffset(const PhantomNode & phantom_node) const { - int weight_offset = 0; - if (phantom_node.forward_node_id != SPECIAL_NODEID) - { - weight_offset += phantom_node.GetForwardWeightPlusOffset(); - } - if (phantom_node.reverse_node_id != SPECIAL_NODEID) - { - weight_offset += phantom_node.GetReverseWeightPlusOffset(); - } - return weight_offset; - // return phantom_node.forward_weight + (phantom_node.isBidirected() ? phantom_node.reverse_weight : 0); - } + // int ComputeOffset(const PhantomNode & phantom_node) const { + // int weight_offset = 0; + // if (phantom_node.forward_node_id != SPECIAL_NODEID) + // { + // weight_offset += phantom_node.GetForwardWeightPlusOffset(); + // } + // if (phantom_node.reverse_node_id != SPECIAL_NODEID) + // { + // weight_offset += phantom_node.GetReverseWeightPlusOffset(); + // } + // return weight_offset; + // // return phantom_node.forward_weight + (phantom_node.isBidirected() ? phantom_node.reverse_weight : 0); + // } }; diff --git a/RoutingAlgorithms/ShortestPathRouting.h b/RoutingAlgorithms/ShortestPathRouting.h index 8372d89e3..e605cec2e 100644 --- a/RoutingAlgorithms/ShortestPathRouting.h +++ b/RoutingAlgorithms/ShortestPathRouting.h @@ -159,12 +159,14 @@ public: ); } - const int forward_offset = super::ComputeEdgeOffset( - phantom_node_pair.source_phantom - ); - const int reverse_offset = super::ComputeEdgeOffset( - phantom_node_pair.target_phantom - ); + const int forward_offset = phantom_node_pair.ComputeForwardQueueOffset(); + // const int forward_offset = super::ComputeForwardOffset( + // phantom_node_pair.source_phantom + // ); + const int reverse_offset = -phantom_node_pair.ComputeReverseQueueOffset(); + // const int reverse_offset = super::ComputeReverseOffset( + // phantom_node_pair.target_phantom + // ); //run two-Target Dijkstra routing step. while(0 < (forward_heap1.Size() + reverse_heap1.Size() )){