Skip to content

Commit

Permalink
feat(thor): Adds runtime check of whether an edge is a deadend
Browse files Browse the repository at this point in the history
This allows for time dependence as well as resolving an issue
where a path only is a deadend in the reverse expansion of
bidirectional_astar.

Fixes valhalla#1982
  • Loading branch information
purew committed Nov 7, 2019
1 parent d2645a8 commit 8fab573
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 103 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* FIXED: Changed reachability computation to consider both directions of travel wrt candidate edges [#1965](https://github.com/valhalla/valhalla/pull/1965)
* FIXED: toss ways where access=private and highway=service and service != driveway. [#1960](https://github.com/valhalla/valhalla/pull/1960)
* FIXED: Fix search_cutoff check in loki correlate_node. [#2023](https://github.com/valhalla/valhalla/pull/2023)
* FIXED: Computes notion of a deadend at runtime in bidirectional a-star which fixes no-route with a complicated u-turn. [#1982](https://github.com/valhalla/valhalla/issues/1982)

* **Enhancement**
* ADDED: Establish pinpoint test pattern [#1969](https://github.com/valhalla/valhalla/pull/1969)
Expand Down
6 changes: 4 additions & 2 deletions src/baldr/graphtile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ iterable_t<const DirectedEdge> GraphTile::GetDirectedEdges(const GraphId& node)
return GetDirectedEdges(nodeinfo);
}
throw std::runtime_error(
"GraphTile NodeInfo index out of bounds 4: " + std::to_string(node.tileid()) + "," +
std::string(__FILE__) + ":" + std::to_string(__LINE__) +
" GraphTile NodeInfo index out of bounds: " + std::to_string(node.tileid()) + "," +
std::to_string(node.level()) + "," + std::to_string(node.id()) +
" nodecount= " + std::to_string(header_->nodecount()));
}
Expand All @@ -560,7 +561,8 @@ iterable_t<const DirectedEdge> GraphTile::GetDirectedEdges(const size_t idx) con
return iterable_t<const DirectedEdge>{edge, nodeinfo.edge_count()};
}
throw std::runtime_error(
"GraphTile NodeInfo index out of bounds 5: " + std::to_string(header_->graphid().tileid()) +
std::string(__FILE__) + ":" + std::to_string(__LINE__) +
" GraphTile NodeInfo index out of bounds 5: " + std::to_string(header_->graphid().tileid()) +
"," + std::to_string(header_->graphid().level()) + "," + std::to_string(idx) +
" nodecount= " + std::to_string(header_->nodecount()));
}
Expand Down
209 changes: 116 additions & 93 deletions src/thor/bidirectional_astar.cc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/thor/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ thor_worker_t::work(const std::list<zmq::message_t>& job,
// get time for start of request
auto s = std::chrono::system_clock::now();
auto& info = *static_cast<prime_server::http_request_info_t*>(request_info);
LOG_INFO("Got Thor Request foo" + std::to_string(info.id));
LOG_INFO("Got Thor Request " + std::to_string(info.id));
Api request;
try {
// crack open the original request
Expand Down
4 changes: 2 additions & 2 deletions test/bidirectional_astar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ int main() {
// Current workaround is to build tiles separately as a input artifact in CMake
// build_tiles(get_conf());

test::suite suite("bidirectional-a-star-whitelion");
test::suite suite("BidirectionalAStar");

//suite.test(TEST_CASE(test_deadend));
suite.test(TEST_CASE(test_deadend));
suite.test(TEST_CASE(test_oneway));
suite.test(TEST_CASE(test_oneway_wrong_way));

Expand Down
9 changes: 6 additions & 3 deletions valhalla/baldr/graphtile.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ class GraphTile {
return &nodes_[node.id()];
}
throw std::runtime_error(
"GraphTile NodeInfo index out of bounds 1: " + std::to_string(node.tileid()) + "," +
std::string(__FILE__) + ":" + std::to_string(__LINE__) +
" GraphTile NodeInfo index out of bounds: " + std::to_string(node.tileid()) + "," +
std::to_string(node.level()) + "," + std::to_string(node.id()) +
" nodecount= " + std::to_string(header_->nodecount()));
}
Expand All @@ -150,7 +151,8 @@ class GraphTile {
return &nodes_[idx];
}
throw std::runtime_error(
"GraphTile NodeInfo index out of bounds 2: " + std::to_string(header_->graphid().tileid()) +
std::string(__FILE__) + ":" + std::to_string(__LINE__) +
" GraphTile NodeInfo index out of bounds: " + std::to_string(header_->graphid().tileid()) +
"," + std::to_string(header_->graphid().level()) + "," + std::to_string(idx) +
" nodecount= " + std::to_string(header_->nodecount()));
}
Expand Down Expand Up @@ -263,7 +265,8 @@ class GraphTile {
return GetNodeTransitions(nodeinfo);
}
throw std::runtime_error(
"GraphTile NodeInfo index out of bounds 3: " + std::to_string(node.tileid()) + "," +
std::string(__FILE__) + ":" + std::to_string(__LINE__) +
" GraphTile NodeInfo index out of bounds: " + std::to_string(node.tileid()) + "," +
std::to_string(node.level()) + "," + std::to_string(node.id()) +
" nodecount= " + std::to_string(header_->nodecount()));
}
Expand Down
4 changes: 2 additions & 2 deletions valhalla/thor/bidirectional_astar.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class BidirectionalAStar : public PathAlgorithm {
/**
* Expand from the node along the forward search path.
*/
void ExpandForward(baldr::GraphReader& graphreader,
bool ExpandForward(baldr::GraphReader& graphreader,
const baldr::GraphId& node,
sif::BDEdgeLabel& pred,
const uint32_t pred_idx,
Expand All @@ -142,7 +142,7 @@ class BidirectionalAStar : public PathAlgorithm {
/**
* Expand from the node along the reverse search path.
*/
void ExpandReverse(baldr::GraphReader& graphreader,
bool ExpandReverse(baldr::GraphReader& graphreader,
const baldr::GraphId& node,
sif::BDEdgeLabel& pred,
const uint32_t pred_idx,
Expand Down

0 comments on commit 8fab573

Please sign in to comment.