Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoshkaj committed Apr 20, 2018
1 parent 3648f0c commit 0e2092a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 57 deletions.
2 changes: 1 addition & 1 deletion cucumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module.exports = {
verify: '--strict --tags ~@stress --tags ~@todo --tags ~@mld-only -f progress --require features/support --require features/step_definitions',
todo: '--strict --tags @todo --require features/support --require features/step_definitions',
all: '--strict --require features/support --require features/step_definitions',
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@ch --require features/support --require features/step_definitions -f progress'
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@ch --require features/support --require features/step_definitions'
};
3 changes: 2 additions & 1 deletion features/testbot/distance_matrix.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Feature: Basic Distance Matrix
Given the profile "testbot"
And the partition extra arguments "--small-component-size 1 --max-cell-sizes 2,4,8,16"

@ch
Scenario: Testbot - Travel distance matrix of minimal network only
Given the node map
"""
Expand Down Expand Up @@ -145,7 +146,7 @@ Feature: Basic Distance Matrix
| c | 200 |
| d | 299.9 |

@ch

Scenario: Testbot - Travel distance matrix of small grid
Given the node map
"""
Expand Down
6 changes: 5 additions & 1 deletion include/engine/routing_algorithms/many_to_many.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ namespace engine
{
namespace routing_algorithms
{

namespace
{
struct NodeBucket
Expand Down Expand Up @@ -74,6 +73,11 @@ struct NodeBucket
}
};
};
inline std::ostream &operator<<(std::ostream &out, const NodeBucket &bucket) {
out << "middle_node: " << bucket.middle_node << " parent_node: " << bucket.parent_node << " column_index: " << bucket.column_index << " weight: " << bucket.weight << " duration: " << bucket.duration << std::endl;
return out;
}

}

template <typename Algorithm>
Expand Down
101 changes: 47 additions & 54 deletions src/engine/routing_algorithms/many_to_many_mld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ void retrievePackedPathFromSearchSpace(NodeID middle_node_id,
std::vector<NodeID> &packed_leg)
{

// for(auto bucket = search_space_with_buckets.begin(); bucket < search_space_with_buckets.end(); ++bucket) {
// std::cout << *bucket;
// }

// [ 0 1 2 3 ]
// [ [m0,p=m3],[m1,p=m2],[m2,p=m1], [m3,p=2]]

Expand Down Expand Up @@ -488,6 +492,7 @@ void retrievePackedPathFromSearchSpace(NodeID middle_node_id,
while (bucket_list.first->parent_node != current_node_id &&
bucket_list.first != search_space_with_buckets.end())
{
std::cout << *bucket_list.first;
current_node_id = bucket_list.first->parent_node;

packed_leg.emplace_back(current_node_id);
Expand Down Expand Up @@ -515,25 +520,9 @@ void calculateDistances(typename SearchEngineData<mld::Algorithm>::ManyToManyQue
{
std::vector<NodeID> packed_leg;

(void)facade;
(void)source_phantom;
(void)phantom_nodes;

// std::cout << "middle_nodes_table: ";
// for (auto middle_node_id = middle_nodes_table.begin();
// middle_node_id != middle_nodes_table.end();
// ++middle_node_id)
// {
// std::cout << *middle_node_id << ", ";
// }
// std::cout << std::endl;

// TODO: CREATE UNIT TESTS FOR EACH OF THE RETRIEVING PACK PATH FUNCTIONS
// 1. Recreate packed path
// 2. Unpack path
// 3. Offset the durations
(void)facade;(void)query_heap;
(void)phantom_nodes;(void)source_phantom;

std::cout << "do I get to before path unpacking?" << std::endl;
for (unsigned column_idx = 0; column_idx < number_of_targets; ++column_idx)
{
const auto location = DIRECTION == FORWARD_DIRECTION
Expand All @@ -547,64 +536,63 @@ void calculateDistances(typename SearchEngineData<mld::Algorithm>::ManyToManyQue
distances_table[location] = 0.0;
continue;
}
// const auto &target_phantom = phantom_nodes[target_index];
const auto &target_phantom = phantom_nodes[target_index];
NodeID middle_node_id = middle_nodes_table[location];

// std::cout << "source_phantom f id: " << source_phantom.forward_segment_id.id << " "
// << "source_phantom r id: " << source_phantom.reverse_segment_id.id << std::endl;
// std::cout << "target_phantom f id: " << target_phantom.forward_segment_id.id << " "
// << "target_phantom r id: " << target_phantom.reverse_segment_id.id << std::endl;
std::cout << "target_phantom f id: " << target_phantom.forward_segment_id.id << " r id: " << target_phantom.reverse_segment_id.id << std::endl;

if (middle_node_id == SPECIAL_NODEID) // takes care of one-ways
{
distances_table[location] = INVALID_EDGE_DISTANCE;
continue;
}
// if (middle_node_id == SPECIAL_NODEID) // takes care of one-ways
// {
// distances_table[location] = INVALID_EDGE_DISTANCE;
// continue;
// }

// from_clique_arc tells you if you are not on the base graph

std::cout << "middle_node_id: " << middle_node_id << std::endl;
// std::cout << "middle_node_id: " << middle_node_id << std::endl;

using PackedEdge = std::tuple</*from*/ NodeID, /*to*/ NodeID, /*from_clique_arc*/ bool>;
// https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/routing_algorithms/routing_base_mld.hpp#L363
// the bool tells you -- is this an overlay edge or not?
// using PackedEdge = std::tuple</*from*/ NodeID, /*to*/ NodeID, /*from_clique_arc*/ bool>;
// // https://github.com/Project-OSRM/osrm-backend/blob/master/include/engine/routing_algorithms/routing_base_mld.hpp#L363
// // the bool tells you -- is this an overlay edge or not?

using PackedPath = std::vector<PackedEdge>;
// using PackedPath = std::vector<PackedEdge>;

// Step 1: Find path from source to middle node
PackedPath packed_path_from_source_to_middle =
mld::retrievePackedPathFromSingleManyToManyHeap<DIRECTION>(
query_heap,
middle_node_id); // packed_leg_from_source_to_middle
// // Step 1: Find path from source to middle node
// PackedPath packed_path_from_source_to_middle =
// mld::retrievePackedPathFromSingleManyToManyHeap<DIRECTION>(
// query_heap,
// middle_node_id); // packed_leg_from_source_to_middle

std::cout << "packed_path_from_source_to_middle.size(): "
<< packed_path_from_source_to_middle.size() << std::endl;
std::cout << "packed_path_from_source_to_middle: "
<< packed_path_from_source_to_middle.size() << std::endl;
for (auto packed_edge : packed_path_from_source_to_middle)
{
std::cout << "packed_edge_from: " << std::get<0>(packed_edge)
<< " packed_edge_to: " << std::get<1>(packed_edge)
<< " packed_edge_from_clique_arc: " << std::get<2>(packed_edge) << std::endl;
}
std::cout << std::endl;
// std::cout << "packed_path_from_source_to_middle.size(): "
// << packed_path_from_source_to_middle.size() << std::endl;
// std::cout << "packed_path_from_source_to_middle: "
// << packed_path_from_source_to_middle.size() << std::endl;
// for (auto packed_edge : packed_path_from_source_to_middle)
// {
// std::cout << "packed_edge_from: " << std::get<0>(packed_edge)
// << " packed_edge_to: " << std::get<1>(packed_edge)
// << " packed_edge_from_clique_arc: " << std::get<2>(packed_edge) << std::endl;
// }
// std::cout << std::endl;

std::reverse(packed_leg.begin(), packed_leg.end());
// std::reverse(packed_leg.begin(), packed_leg.end());

packed_leg.push_back(middle_node_id);
// packed_leg.push_back(middle_node_id);

// Step 2: Find path from middle to target node
retrievePackedPathFromSearchSpace(middle_node_id,
column_idx,
search_space_with_buckets,
packed_leg); // packed_leg_from_middle_to_target

std::cout << "packed_leg: ";
std::cout << "packed_leg_from_middle_to_target: ";
for (auto node_id : packed_leg)
{
std::cout << "node_id: " << node_id << ", ";
std::cout << node_id << ", ";
}
std::cout << std::endl;
std::cout << std::endl << std::endl;

// WHY IS EVERYTHIN OVER HERE A PHANTOM NODE TARGET OF ID 1????

// call site for figuring out what node level to start at
// https://github.com/Project-OSRM/osrm-backend/blob/faff2c774d09a7227c77ae4fa40d22d54bb00b45/include/engine/routing_algorithms/routing_base_mld.hpp#L145
Expand Down Expand Up @@ -697,6 +685,10 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,

if (calculate_distance)
{

std::cout << "source_phantom f id: " << source_phantom.forward_segment_id.id << " "
<< "source_phantom r id: " << source_phantom.reverse_segment_id.id << std::endl;

distances_table.resize(number_of_entries, INVALID_EDGE_DISTANCE);
calculateDistances<DIRECTION>(query_heap,
facade,
Expand All @@ -711,6 +703,7 @@ manyToManySearch(SearchEngineData<Algorithm> &engine_working_data,
distances_table,
middle_nodes_table);
}
std::cout << std::endl;
}

return std::make_pair(durations_table, distances_table);
Expand Down

0 comments on commit 0e2092a

Please sign in to comment.