Add duration to edges and use it in table plugin
This commit is contained in:
committed by
Patrick Niklaus
parent
c059d15cb9
commit
25baf51a2c
@@ -12,21 +12,24 @@ namespace contractor
|
||||
struct ContractorEdgeData
|
||||
{
|
||||
ContractorEdgeData()
|
||||
: weight(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
: weight(0), duration(0), id(0), originalEdges(0), shortcut(0), forward(0), backward(0),
|
||||
is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
ContractorEdgeData(EdgeWeight weight,
|
||||
EdgeWeight duration,
|
||||
unsigned original_edges,
|
||||
unsigned id,
|
||||
bool shortcut,
|
||||
bool forward,
|
||||
bool backward)
|
||||
: weight(weight), id(id), originalEdges(std::min((unsigned)1 << 28, original_edges)),
|
||||
shortcut(shortcut), forward(forward), backward(backward), is_original_via_node_ID(false)
|
||||
: weight(weight), duration(duration), id(id),
|
||||
originalEdges(std::min((unsigned)1 << 28, original_edges)), shortcut(shortcut),
|
||||
forward(forward), backward(backward), is_original_via_node_ID(false)
|
||||
{
|
||||
}
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration;
|
||||
unsigned id;
|
||||
unsigned originalEdges : 28;
|
||||
bool shortcut : 1;
|
||||
|
||||
@@ -134,6 +134,7 @@ class GraphContractor
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.source, "Source id invalid");
|
||||
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_edge.target, "Target id invalid");
|
||||
new_edge.data.weight = data.weight;
|
||||
new_edge.data.duration = data.duration;
|
||||
new_edge.data.shortcut = data.shortcut;
|
||||
if (!data.is_original_via_node_ID && !orig_node_id_from_new_node_id_map.empty())
|
||||
{
|
||||
@@ -241,6 +242,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@@ -251,6 +253,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges +
|
||||
in_data.originalEdges,
|
||||
node,
|
||||
@@ -294,6 +297,7 @@ class GraphContractor
|
||||
const NodeID target = contractor_graph->GetTarget(out_edge);
|
||||
if (target == node)
|
||||
continue;
|
||||
|
||||
const EdgeWeight path_weight = in_data.weight + out_data.weight;
|
||||
const EdgeWeight weight = dijkstra.GetKey(target);
|
||||
if (path_weight < weight)
|
||||
@@ -310,6 +314,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(source,
|
||||
target,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
@@ -319,6 +324,7 @@ class GraphContractor
|
||||
inserted_edges.emplace_back(target,
|
||||
source,
|
||||
path_weight,
|
||||
in_data.duration + out_data.duration,
|
||||
out_data.originalEdges + in_data.originalEdges,
|
||||
node,
|
||||
SHORTCUT_ARC,
|
||||
|
||||
@@ -33,6 +33,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
|
||||
edges.emplace_back(input_edge.source,
|
||||
input_edge.target,
|
||||
std::max(input_edge.weight, 1),
|
||||
input_edge.duration,
|
||||
1,
|
||||
input_edge.edge_id,
|
||||
false,
|
||||
@@ -42,6 +43,7 @@ std::vector<ContractorEdge> adaptToContractorInput(InputEdgeContainer input_edge
|
||||
edges.emplace_back(input_edge.target,
|
||||
input_edge.source,
|
||||
std::max(input_edge.weight, 1),
|
||||
input_edge.duration,
|
||||
1,
|
||||
input_edge.edge_id,
|
||||
false,
|
||||
|
||||
@@ -16,11 +16,15 @@ struct QueryEdge
|
||||
NodeID target;
|
||||
struct EdgeData
|
||||
{
|
||||
EdgeData() : id(0), shortcut(false), weight(0), forward(false), backward(false) {}
|
||||
explicit EdgeData()
|
||||
: id(0), shortcut(false), weight(0), duration(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <class OtherT> EdgeData(const OtherT &other)
|
||||
{
|
||||
weight = other.weight;
|
||||
duration = other.duration;
|
||||
shortcut = other.shortcut;
|
||||
id = other.id;
|
||||
forward = other.forward;
|
||||
@@ -31,9 +35,10 @@ struct QueryEdge
|
||||
// node. Otherwise we see the edge based node to access node data.
|
||||
NodeID id : 31;
|
||||
bool shortcut : 1;
|
||||
EdgeWeight weight : 30;
|
||||
bool forward : 1;
|
||||
bool backward : 1;
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration : 30;
|
||||
std::uint32_t forward : 1;
|
||||
std::uint32_t backward : 1;
|
||||
} data;
|
||||
|
||||
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
|
||||
@@ -51,9 +56,9 @@ struct QueryEdge
|
||||
bool operator==(const QueryEdge &right) const
|
||||
{
|
||||
return (source == right.source && target == right.target &&
|
||||
data.weight == right.data.weight && data.shortcut == right.data.shortcut &&
|
||||
data.forward == right.data.forward && data.backward == right.data.backward &&
|
||||
data.id == right.data.id);
|
||||
data.weight == right.data.weight && data.duration == right.data.duration &&
|
||||
data.shortcut == right.data.shortcut && data.forward == right.data.forward &&
|
||||
data.backward == right.data.backward && data.id == right.data.id);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class TableAPI final : public BaseAPI
|
||||
row_end_iterator,
|
||||
json_row.values.begin(),
|
||||
[](const EdgeWeight duration) {
|
||||
if (duration == INVALID_EDGE_WEIGHT)
|
||||
if (duration == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
}
|
||||
|
||||
@@ -369,8 +369,10 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Find the node-based-edge that this belongs to, and directly
|
||||
// calculate the forward_weight, forward_offset, reverse_weight, reverse_offset
|
||||
|
||||
EdgeWeight forward_offset = 0, forward_weight = 0, forward_duration = 0;
|
||||
EdgeWeight reverse_offset = 0, reverse_weight = 0, reverse_duration = 0;
|
||||
EdgeWeight forward_weight_offset = 0, forward_weight = 0;
|
||||
EdgeWeight reverse_weight_offset = 0, reverse_weight = 0;
|
||||
EdgeWeight forward_duration_offset = 0, forward_duration = 0;
|
||||
EdgeWeight reverse_duration_offset = 0, reverse_duration = 0;
|
||||
|
||||
const std::vector<EdgeWeight> forward_weight_vector =
|
||||
datafacade.GetUncompressedForwardWeights(data.packed_geometry_id);
|
||||
@@ -383,7 +385,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
for (std::size_t i = 0; i < data.fwd_segment_position; i++)
|
||||
{
|
||||
forward_offset += forward_weight_vector[i];
|
||||
forward_weight_offset += forward_weight_vector[i];
|
||||
forward_duration_offset += forward_duration_vector[i];
|
||||
}
|
||||
forward_weight = forward_weight_vector[data.fwd_segment_position];
|
||||
forward_duration = forward_duration_vector[data.fwd_segment_position];
|
||||
@@ -393,7 +396,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1;
|
||||
i++)
|
||||
{
|
||||
reverse_offset += reverse_weight_vector[i];
|
||||
reverse_weight_offset += reverse_weight_vector[i];
|
||||
reverse_duration_offset += reverse_duration_vector[i];
|
||||
}
|
||||
reverse_weight =
|
||||
reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1];
|
||||
@@ -415,10 +419,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
|
||||
forward_weight,
|
||||
reverse_weight,
|
||||
forward_weight_offset,
|
||||
reverse_weight_offset,
|
||||
forward_duration,
|
||||
reverse_duration,
|
||||
forward_offset,
|
||||
reverse_offset,
|
||||
forward_duration_offset,
|
||||
reverse_duration_offset,
|
||||
point_on_segment,
|
||||
input_coordinate},
|
||||
current_perpendicular_distance};
|
||||
|
||||
@@ -63,8 +63,8 @@ struct Hint
|
||||
friend std::ostream &operator<<(std::ostream &, const Hint &);
|
||||
};
|
||||
|
||||
static_assert(sizeof(Hint) == 64 + 4, "Hint is bigger than expected");
|
||||
constexpr std::size_t ENCODED_HINT_SIZE = 92;
|
||||
static_assert(sizeof(Hint) == 72 + 4, "Hint is bigger than expected");
|
||||
constexpr std::size_t ENCODED_HINT_SIZE = 104;
|
||||
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
|
||||
"ENCODED_HINT_SIZE does not match size of Hint");
|
||||
}
|
||||
|
||||
@@ -51,10 +51,12 @@ struct PhantomNode
|
||||
unsigned name_id,
|
||||
EdgeWeight forward_weight,
|
||||
EdgeWeight reverse_weight,
|
||||
EdgeWeight forward_weight_offset,
|
||||
EdgeWeight reverse_weight_offset,
|
||||
EdgeWeight forward_duration,
|
||||
EdgeWeight reverse_duration,
|
||||
EdgeWeight forward_offset,
|
||||
EdgeWeight reverse_offset,
|
||||
EdgeWeight forward_duration_offset,
|
||||
EdgeWeight reverse_duration_offset,
|
||||
unsigned packed_geometry_id_,
|
||||
bool is_tiny_component,
|
||||
unsigned component_id,
|
||||
@@ -65,12 +67,13 @@ struct PhantomNode
|
||||
extractor::TravelMode backward_travel_mode)
|
||||
: forward_segment_id(forward_segment_id), reverse_segment_id(reverse_segment_id),
|
||||
name_id(name_id), forward_weight(forward_weight), reverse_weight(reverse_weight),
|
||||
forward_duration(forward_duration), reverse_duration(reverse_duration),
|
||||
forward_offset(forward_offset), reverse_offset(reverse_offset),
|
||||
packed_geometry_id(packed_geometry_id_), component{component_id, is_tiny_component},
|
||||
location(std::move(location)), input_location(std::move(input_location)),
|
||||
fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode),
|
||||
backward_travel_mode(backward_travel_mode)
|
||||
forward_weight_offset(forward_weight_offset),
|
||||
reverse_weight_offset(reverse_weight_offset), forward_duration(forward_duration),
|
||||
reverse_duration(reverse_duration), forward_duration_offset(forward_duration_offset),
|
||||
reverse_duration_offset(reverse_duration_offset), packed_geometry_id(packed_geometry_id_),
|
||||
component{component_id, is_tiny_component}, location(std::move(location)),
|
||||
input_location(std::move(input_location)), fwd_segment_position(fwd_segment_position),
|
||||
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -78,8 +81,9 @@ struct PhantomNode
|
||||
: forward_segment_id{SPECIAL_SEGMENTID, false},
|
||||
reverse_segment_id{SPECIAL_SEGMENTID, false},
|
||||
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_duration(INVALID_EDGE_WEIGHT),
|
||||
reverse_duration(INVALID_EDGE_WEIGHT), forward_offset(0), reverse_offset(0),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_weight_offset(0), reverse_weight_offset(0),
|
||||
forward_duration(MAXIMAL_EDGE_DURATION), reverse_duration(MAXIMAL_EDGE_DURATION),
|
||||
forward_duration_offset(0), reverse_duration_offset(0),
|
||||
packed_geometry_id(SPECIAL_GEOMETRYID), component{INVALID_COMPONENTID, false},
|
||||
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||
@@ -89,13 +93,25 @@ struct PhantomNode
|
||||
EdgeWeight GetForwardWeightPlusOffset() const
|
||||
{
|
||||
BOOST_ASSERT(forward_segment_id.enabled);
|
||||
return forward_offset + forward_weight;
|
||||
return forward_weight_offset + forward_weight;
|
||||
}
|
||||
|
||||
EdgeWeight GetReverseWeightPlusOffset() const
|
||||
{
|
||||
BOOST_ASSERT(reverse_segment_id.enabled);
|
||||
return reverse_offset + reverse_weight;
|
||||
return reverse_weight_offset + reverse_weight;
|
||||
}
|
||||
|
||||
EdgeWeight GetForwardDuration() const
|
||||
{
|
||||
BOOST_ASSERT(forward_segment_id.enabled);
|
||||
return forward_duration + forward_duration_offset;
|
||||
}
|
||||
|
||||
EdgeWeight GetReverseDuration() const
|
||||
{
|
||||
BOOST_ASSERT(reverse_segment_id.enabled);
|
||||
return reverse_duration + reverse_duration_offset;
|
||||
}
|
||||
|
||||
bool IsBidirected() const { return forward_segment_id.enabled && reverse_segment_id.enabled; }
|
||||
@@ -106,8 +122,8 @@ struct PhantomNode
|
||||
(reverse_segment_id.id < number_of_nodes)) &&
|
||||
((forward_weight != INVALID_EDGE_WEIGHT) ||
|
||||
(reverse_weight != INVALID_EDGE_WEIGHT)) &&
|
||||
((forward_duration != INVALID_EDGE_WEIGHT) ||
|
||||
(reverse_duration != INVALID_EDGE_WEIGHT)) &&
|
||||
((forward_duration != MAXIMAL_EDGE_DURATION) ||
|
||||
(reverse_duration != MAXIMAL_EDGE_DURATION)) &&
|
||||
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
|
||||
}
|
||||
|
||||
@@ -124,17 +140,21 @@ struct PhantomNode
|
||||
explicit PhantomNode(const OtherT &other,
|
||||
EdgeWeight forward_weight,
|
||||
EdgeWeight reverse_weight,
|
||||
EdgeWeight forward_weight_offset,
|
||||
EdgeWeight reverse_weight_offset,
|
||||
EdgeWeight forward_duration,
|
||||
EdgeWeight reverse_duration,
|
||||
EdgeWeight forward_offset,
|
||||
EdgeWeight reverse_offset,
|
||||
EdgeWeight forward_duration_offset,
|
||||
EdgeWeight reverse_duration_offset,
|
||||
const util::Coordinate location,
|
||||
const util::Coordinate input_location)
|
||||
: forward_segment_id{other.forward_segment_id},
|
||||
reverse_segment_id{other.reverse_segment_id}, name_id{other.name_id},
|
||||
forward_weight{forward_weight}, reverse_weight{reverse_weight},
|
||||
forward_duration{forward_duration}, reverse_duration{reverse_duration},
|
||||
forward_offset{forward_offset}, reverse_offset{reverse_offset},
|
||||
forward_weight_offset{forward_weight_offset},
|
||||
reverse_weight_offset{reverse_weight_offset}, forward_duration{forward_duration},
|
||||
reverse_duration{reverse_duration}, forward_duration_offset{forward_duration_offset},
|
||||
reverse_duration_offset{reverse_duration_offset},
|
||||
packed_geometry_id{other.packed_geometry_id},
|
||||
component{other.component.id, other.component.is_tiny}, location{location},
|
||||
input_location{input_location}, fwd_segment_position{other.fwd_segment_position},
|
||||
@@ -148,10 +168,12 @@ struct PhantomNode
|
||||
unsigned name_id;
|
||||
EdgeWeight forward_weight;
|
||||
EdgeWeight reverse_weight;
|
||||
EdgeWeight forward_weight_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight reverse_weight_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight forward_duration;
|
||||
EdgeWeight reverse_duration;
|
||||
EdgeWeight forward_offset;
|
||||
EdgeWeight reverse_offset;
|
||||
EdgeWeight forward_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
EdgeWeight reverse_duration_offset; // TODO: try to remove -> requires path unpacking changes
|
||||
unsigned packed_geometry_id;
|
||||
struct ComponentType
|
||||
{
|
||||
@@ -169,7 +191,7 @@ struct PhantomNode
|
||||
extractor::TravelMode backward_travel_mode;
|
||||
};
|
||||
|
||||
static_assert(sizeof(PhantomNode) == 64, "PhantomNode has more padding then expected");
|
||||
static_assert(sizeof(PhantomNode) == 72, "PhantomNode has more padding then expected");
|
||||
|
||||
using PhantomNodePair = std::pair<PhantomNode, PhantomNode>;
|
||||
|
||||
@@ -199,10 +221,12 @@ inline std::ostream &operator<<(std::ostream &out, const PhantomNode &pn)
|
||||
<< "name: " << pn.name_id << ", "
|
||||
<< "fwd-w: " << pn.forward_weight << ", "
|
||||
<< "rev-w: " << pn.reverse_weight << ", "
|
||||
<< "fwd-o: " << pn.forward_weight_offset << ", "
|
||||
<< "rev-o: " << pn.reverse_weight_offset << ", "
|
||||
<< "fwd-d: " << pn.forward_duration << ", "
|
||||
<< "rev-d: " << pn.reverse_duration << ", "
|
||||
<< "fwd-o: " << pn.forward_offset << ", "
|
||||
<< "rev-o: " << pn.reverse_offset << ", "
|
||||
<< "fwd-do: " << pn.forward_duration_offset << ", "
|
||||
<< "rev-do: " << pn.reverse_duration_offset << ", "
|
||||
<< "geom: " << pn.packed_geometry_id << ", "
|
||||
<< "comp: " << pn.component.is_tiny << " / " << pn.component.id << ", "
|
||||
<< "pos: " << pn.fwd_segment_position << ", "
|
||||
|
||||
@@ -138,7 +138,7 @@ class AlternativeRouting final : private BasicRoutingInterface
|
||||
else
|
||||
{
|
||||
// check whether there is a loop present at the node
|
||||
const auto loop_weight = super::GetLoopWeight(facade, node);
|
||||
const auto loop_weight = super::GetLoopWeight<false>(facade, node);
|
||||
const EdgeWeight new_weight_with_loop = new_weight + loop_weight;
|
||||
if (loop_weight != INVALID_EDGE_WEIGHT &&
|
||||
new_weight_with_loop <= *upper_bound_to_shortest_path_weight)
|
||||
|
||||
@@ -23,15 +23,16 @@ namespace routing_algorithms
|
||||
class ManyToManyRouting final : public BasicRoutingInterface
|
||||
{
|
||||
using super = BasicRoutingInterface;
|
||||
using QueryHeap = SearchEngineData::QueryHeap;
|
||||
using QueryHeap = SearchEngineData::ManyToManyQueryHeap;
|
||||
SearchEngineData &engine_working_data;
|
||||
|
||||
struct NodeBucket
|
||||
{
|
||||
unsigned target_id; // essentially a row in the weight matrix
|
||||
EdgeWeight weight;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight weight)
|
||||
: target_id(target_id), weight(weight)
|
||||
EdgeWeight duration;
|
||||
NodeBucket(const unsigned target_id, const EdgeWeight weight, const EdgeWeight duration)
|
||||
: target_id(target_id), weight(weight), duration(duration)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -56,7 +57,8 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
const unsigned number_of_targets,
|
||||
QueryHeap &query_heap,
|
||||
const SearchSpaceWithBuckets &search_space_with_buckets,
|
||||
std::vector<EdgeWeight> &result_table) const;
|
||||
std::vector<EdgeWeight> &weights_table,
|
||||
std::vector<EdgeWeight> &durations_table) const;
|
||||
|
||||
void BackwardRoutingStep(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
const unsigned column_idx,
|
||||
@@ -67,6 +69,7 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
inline void RelaxOutgoingEdges(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
const NodeID node,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
QueryHeap &query_heap) const
|
||||
{
|
||||
for (auto edge : facade->GetAdjacentEdgeRange(node))
|
||||
@@ -77,20 +80,22 @@ class ManyToManyRouting final : public BasicRoutingInterface
|
||||
{
|
||||
const NodeID to = facade->GetTarget(edge);
|
||||
const EdgeWeight edge_weight = data.weight;
|
||||
const EdgeWeight edge_duration = data.duration;
|
||||
|
||||
BOOST_ASSERT_MSG(edge_weight > 0, "edge_weight invalid");
|
||||
const EdgeWeight to_weight = weight + edge_weight;
|
||||
const EdgeWeight to_duration = duration + edge_duration;
|
||||
|
||||
// New Node discovered -> Add to Heap + Node Info Storage
|
||||
if (!query_heap.WasInserted(to))
|
||||
{
|
||||
query_heap.Insert(to, to_weight, node);
|
||||
query_heap.Insert(to, to_weight, {node, to_duration});
|
||||
}
|
||||
// Found a shorter Path -> Update weight
|
||||
else if (to_weight < query_heap.GetKey(to))
|
||||
{
|
||||
// new parent
|
||||
query_heap.GetData(to).parent = node;
|
||||
query_heap.GetData(to) = {node, to_duration};
|
||||
query_heap.DecreaseKey(to, to_weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
@@ -77,8 +78,26 @@ class BasicRoutingInterface
|
||||
const bool force_loop_forward,
|
||||
const bool force_loop_reverse) const;
|
||||
|
||||
template <bool UseDuration>
|
||||
EdgeWeight GetLoopWeight(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
NodeID node) const;
|
||||
NodeID node) const
|
||||
{
|
||||
EdgeWeight loop_weight = UseDuration ? MAXIMAL_EDGE_DURATION : INVALID_EDGE_WEIGHT;
|
||||
for (auto edge : facade->GetAdjacentEdgeRange(node))
|
||||
{
|
||||
const auto &data = facade->GetEdgeData(edge);
|
||||
if (data.forward)
|
||||
{
|
||||
const NodeID to = facade->GetTarget(edge);
|
||||
if (to == node)
|
||||
{
|
||||
const auto value = UseDuration ? data.duration : data.weight;
|
||||
loop_weight = std::min(loop_weight, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return loop_weight;
|
||||
}
|
||||
|
||||
template <typename RandomIter>
|
||||
void UnpackPath(const std::shared_ptr<const datafacade::BaseDataFacade> facade,
|
||||
|
||||
@@ -17,24 +17,41 @@ struct HeapData
|
||||
/* explicit */ HeapData(NodeID p) : parent(p) {}
|
||||
};
|
||||
|
||||
struct ManyToManyHeapData : HeapData
|
||||
{
|
||||
EdgeWeight duration;
|
||||
ManyToManyHeapData(NodeID p, EdgeWeight duration) : HeapData(p), duration(duration) {}
|
||||
};
|
||||
|
||||
struct SearchEngineData
|
||||
{
|
||||
using QueryHeap = util::
|
||||
BinaryHeap<NodeID, NodeID, EdgeWeight, HeapData, util::UnorderedMapStorage<NodeID, int>>;
|
||||
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
||||
|
||||
using ManyToManyQueryHeap = util::BinaryHeap<NodeID,
|
||||
NodeID,
|
||||
EdgeWeight,
|
||||
ManyToManyHeapData,
|
||||
util::UnorderedMapStorage<NodeID, int>>;
|
||||
|
||||
using ManyToManyHeapPtr = boost::thread_specific_ptr<ManyToManyQueryHeap>;
|
||||
|
||||
static SearchEngineHeapPtr forward_heap_1;
|
||||
static SearchEngineHeapPtr reverse_heap_1;
|
||||
static SearchEngineHeapPtr forward_heap_2;
|
||||
static SearchEngineHeapPtr reverse_heap_2;
|
||||
static SearchEngineHeapPtr forward_heap_3;
|
||||
static SearchEngineHeapPtr reverse_heap_3;
|
||||
static ManyToManyHeapPtr many_to_many_heap;
|
||||
|
||||
void InitializeOrClearFirstThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearSecondThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearThirdThreadLocalStorage(const unsigned number_of_nodes);
|
||||
|
||||
void InitializeOrClearManyToManyThreadLocalStorage(const unsigned number_of_nodes);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ struct EdgeBasedEdge
|
||||
const NodeID target,
|
||||
const NodeID edge_id,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
const bool forward,
|
||||
const bool backward);
|
||||
|
||||
@@ -29,11 +30,12 @@ struct EdgeBasedEdge
|
||||
NodeID source;
|
||||
NodeID target;
|
||||
NodeID edge_id;
|
||||
EdgeWeight weight : 30;
|
||||
EdgeWeight weight;
|
||||
EdgeWeight duration : 30;
|
||||
std::uint32_t forward : 1;
|
||||
std::uint32_t backward : 1;
|
||||
};
|
||||
static_assert(sizeof(extractor::EdgeBasedEdge) == 16,
|
||||
static_assert(sizeof(extractor::EdgeBasedEdge) == 20,
|
||||
"Size of extractor::EdgeBasedEdge type is "
|
||||
"bigger than expected. This will influence "
|
||||
"memory consumption.");
|
||||
@@ -41,14 +43,7 @@ static_assert(sizeof(extractor::EdgeBasedEdge) == 16,
|
||||
// Impl.
|
||||
|
||||
inline EdgeBasedEdge::EdgeBasedEdge()
|
||||
: source(0), target(0), edge_id(0), weight(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <class EdgeT>
|
||||
inline EdgeBasedEdge::EdgeBasedEdge(const EdgeT &other)
|
||||
: source(other.source), target(other.target), edge_id(other.data.via),
|
||||
weight(other.data.distance), forward(other.data.forward), backward(other.data.backward)
|
||||
: source(0), target(0), edge_id(0), weight(0), duration(0), forward(false), backward(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,10 +51,11 @@ inline EdgeBasedEdge::EdgeBasedEdge(const NodeID source,
|
||||
const NodeID target,
|
||||
const NodeID edge_id,
|
||||
const EdgeWeight weight,
|
||||
const EdgeWeight duration,
|
||||
const bool forward,
|
||||
const bool backward)
|
||||
: source(source), target(target), edge_id(edge_id), weight(weight), forward(forward),
|
||||
backward(backward)
|
||||
: source(source), target(target), edge_id(edge_id), weight(weight), duration(duration),
|
||||
forward(forward), backward(backward)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ struct SegmentBlock
|
||||
OSMNodeID this_osm_node_id;
|
||||
double segment_length;
|
||||
EdgeWeight segment_weight;
|
||||
// TODO MKR add duration if needed
|
||||
};
|
||||
#pragma pack(pop)
|
||||
static_assert(sizeof(SegmentBlock) == 20, "SegmentBlock is not packed correctly");
|
||||
|
||||
@@ -84,6 +84,7 @@ static const NameID INVALID_NAMEID = std::numeric_limits<NameID>::max();
|
||||
static const NameID EMPTY_NAMEID = 0;
|
||||
static const unsigned INVALID_COMPONENTID = 0;
|
||||
static const EdgeWeight INVALID_EDGE_WEIGHT = std::numeric_limits<EdgeWeight>::max();
|
||||
static const EdgeWeight MAXIMAL_EDGE_DURATION = std::numeric_limits<EdgeWeight>::max();
|
||||
static const TurnPenalty INVALID_TURN_PENALTY = std::numeric_limits<TurnPenalty>::max();
|
||||
|
||||
using DatasourceID = std::uint8_t;
|
||||
|
||||
Reference in New Issue
Block a user