Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarex committed May 8, 2018
1 parent 37e3777 commit 0f09c28
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 33 deletions.
20 changes: 15 additions & 5 deletions include/engine/routing_algorithms/many_to_many.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct NodeBucket
{
NodeID middle_node;
NodeID parent_node;
bool from_clique_arc;
unsigned column_index; // a column in the weight/duration matrix
unsigned column_index : 31; // a column in the weight/duration matrix
unsigned from_clique_arc : 1;
EdgeWeight weight;
EdgeDuration duration;

Expand All @@ -32,8 +32,18 @@ struct NodeBucket
unsigned column_index,
EdgeWeight weight,
EdgeDuration duration)
: middle_node(middle_node), parent_node(parent_node), from_clique_arc(from_clique_arc),
column_index(column_index), weight(weight), duration(duration)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
from_clique_arc(from_clique_arc), weight(weight), duration(duration)
{
}

NodeBucket(NodeID middle_node,
NodeID parent_node,
unsigned column_index,
EdgeWeight weight,
EdgeDuration duration)
: middle_node(middle_node), parent_node(parent_node), column_index(column_index),
from_clique_arc(false), weight(weight), duration(duration)
{
}

Expand Down Expand Up @@ -75,7 +85,7 @@ struct NodeBucket
}
};
};
}
} // namespace

template <typename Algorithm>
std::pair<std::vector<EdgeDuration>, std::vector<EdgeDistance>>
Expand Down
22 changes: 1 addition & 21 deletions include/engine/routing_algorithms/routing_base_mld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,21 +446,6 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
// Get packed path as edges {from node ID, to node ID, from_clique_arc}
auto packed_path = retrievePackedPathFromHeap(forward_heap, reverse_heap, middle);

// if (!packed_path.empty())
// {
// std::cout << "packed_path: ";
// for (auto edge : packed_path)
// {
// std::cout << std::get<0>(edge) << ",";
// }
// std::cout << std::get<1>(packed_path.back());
// std::cout << std::endl;
// }
// else
// {
// std::cout << "no packed_path!" << std::endl;
// }

// Beware the edge case when start, middle, end are all the same.
// In this case we return a single node, no edges. We also don't unpack.
const NodeID source_node = !packed_path.empty() ? std::get<0>(packed_path.front()) : middle;
Expand Down Expand Up @@ -520,12 +505,7 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
unpacked_edges.insert(unpacked_edges.end(), subpath_edges.begin(), subpath_edges.end());
}
}
// std::cout << "unpacked_nodes: ";
// for (auto node : unpacked_nodes)
// {
// std::cout << node << ", ";
// }
// std::cout << std::endl;

return std::make_tuple(weight, std::move(unpacked_nodes), std::move(unpacked_edges));
}

Expand Down
2 changes: 0 additions & 2 deletions profiles/testbot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ function process_turn (profile, turn)
if turn.has_traffic_light then
turn.duration = turn.duration + profile.properties.traffic_light_penalty
end

io.write("after penalty turn.duration: ", turn.duration, "turn.weight: ", turn.weight, "\n")
end

return {
Expand Down
3 changes: 1 addition & 2 deletions src/engine/routing_algorithms/many_to_many_ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,10 @@ void backwardRoutingStep(const DataFacade<Algorithm> &facade,
const auto target_weight = query_heap.GetKey(node);
const auto target_duration = query_heap.GetData(node).duration;
const auto parent = query_heap.GetData(node).parent;
const bool INVALID_CLIQUE_ARC_TYPE = false;

// Store settled nodes in search space bucket
search_space_with_buckets.emplace_back(
node, parent, INVALID_CLIQUE_ARC_TYPE, column_index, target_weight, target_duration);
node, parent, column_index, target_weight, target_duration);

relaxOutgoingEdges<REVERSE_DIRECTION>(
facade, node, target_weight, target_duration, query_heap, phantom_node);
Expand Down
7 changes: 4 additions & 3 deletions src/engine/routing_algorithms/many_to_many_mld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,19 @@ oneToManySearch(SearchEngineData<Algorithm> &engine_working_data,
for (auto edge : facade.GetAdjacentEdgeRange(node))
{
const auto &data = facade.GetEdgeData(edge);
const auto to = facade.GetTarget(edge);
if ((DIRECTION == FORWARD_DIRECTION ? facade.IsForwardEdge(edge)
: facade.IsBackwardEdge(edge)) &&
!query_heap.WasInserted(facade.GetTarget(edge)))
!query_heap.WasInserted(to))
{
const auto turn_id = data.turn_id;
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : facade.GetTarget(edge);
const auto node_id = DIRECTION == FORWARD_DIRECTION ? node : to;
const auto edge_weight = initial_weight + facade.GetNodeWeight(node_id) +
facade.GetWeightPenaltyForEdgeID(turn_id);
const auto edge_duration = initial_duration + facade.GetNodeDuration(node_id) +
facade.GetDurationPenaltyForEdgeID(turn_id);

query_heap.Insert(facade.GetTarget(edge), edge_weight, {node, edge_duration});
query_heap.Insert(to, edge_weight, {node, edge_duration});
}
}
};
Expand Down

0 comments on commit 0f09c28

Please sign in to comment.