Skip to content

Fix threshold usage in shortest path computation#438

Merged
Grufoony merged 4 commits intomainfrom
fixThresholdInPaths
Apr 20, 2026
Merged

Fix threshold usage in shortest path computation#438
Grufoony merged 4 commits intomainfrom
fixThresholdInPaths

Conversation

@Grufoony
Copy link
Copy Markdown
Owner

…p-by-step

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 95.28796% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.31%. Comparing base (dc68f76) to head (0cb1252).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/dsf/mobility/RoadNetwork.hpp 96.10% 6 Missing ⚠️
test/mobility/Test_graph.cpp 91.42% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #438      +/-   ##
==========================================
+ Coverage   87.26%   87.31%   +0.05%     
==========================================
  Files          52       52              
  Lines        6523     6628     +105     
  Branches      732      765      +33     
==========================================
+ Hits         5692     5787      +95     
- Misses        809      817       +8     
- Partials       22       24       +2     
Flag Coverage Δ
unittests 87.31% <95.28%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

graph.addStreets(s1, s2, s3, s4, s5);

auto const& pathMap =
graph.allPathsTo(4, [](auto const& pEdge) { return pEdge.length(); }, 0.7);

auto const& pathMap =
graph.allPathsTo(4, [](auto const& pEdge) { return pEdge.length(); }, 0.7);
CHECK_EQ(pathMap.at(0).size(), 2);
auto const& pathMap =
graph.allPathsTo(4, [](auto const& pEdge) { return pEdge.length(); }, 0.7);
CHECK_EQ(pathMap.at(0).size(), 2);
}
graph.allPathsTo(4, [](auto const& pEdge) { return pEdge.length(); }, 0.7);
CHECK_EQ(pathMap.at(0).size(), 2);
}

// Best path: 0 -> 1 -> 2 -> 5 = 10.0
// Alternative: 0 -> 1 -> 3 -> 5 = 10.89 (within 10%)
// Over-budget path: 0 -> 1 -> 3 -> 4 -> 5 = 11.39 (must be excluded)
Street s01(0, std::make_pair(0, 1), 1.0);
path[3] == 5) {
foundBestPath = true;
}
if (path.size() == 4 && path[0] == 0 && path[1] == 1 && path[2] == 3 &&
path[3] == 5) {
foundValidAlternative = true;
}
if (path.size() == 5 && path[0] == 0 && path[1] == 1 && path[2] == 3 &&
path[3] == 4 && path[4] == 5) {
foundOverBudgetPath = true;
}
}

CHECK(foundBestPath);
CHECK(foundValidAlternative);
CHECK_FALSE(foundOverBudgetPath);
CHECK(foundBestPath);
CHECK(foundValidAlternative);
CHECK_FALSE(foundOverBudgetPath);
}
@Grufoony Grufoony marked this pull request as ready for review April 14, 2026 12:36
Copilot AI review requested due to automatic review settings April 14, 2026 12:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the road-network pathfinding “threshold” semantics so the tolerance is applied against the total source→target (or node→target) path cost, rather than being applied step-by-step at each hop. This affects both C++ pathfinding behavior and its test coverage, plus a small Python-docstring clarification.

Changes:

  • Refactors RoadNetwork::allPathsTo() / RoadNetwork::shortestPath() to compute strict distances-to-target first, then filter next-hops using a full-path budget rule.
  • Adds new tests covering deeper alternative paths and ensuring over-budget full paths are excluded.
  • Updates FirstOrderDynamics test usage and Python binding docstrings to match the clarified threshold meaning.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/dsf/mobility/RoadNetwork.hpp Refactors pathfinding to enforce full-path budget threshold via distances-to-target and new filtering/recursion logic.
test/mobility/Test_graph.cpp Adds new unit tests for full-path threshold behavior (deep alternatives + budget exclusion).
test/mobility/Test_dynamics.cpp Adjusts weight-function threshold usage in a dynamics test to avoid unintended alternatives under new semantics.
src/dsf/bindings.cpp Clarifies Python docstring: threshold is relative tolerance on full source→target cost.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/dsf/mobility/RoadNetwork.hpp Outdated
Comment thread src/dsf/mobility/RoadNetwork.hpp Outdated
Comment thread test/mobility/Test_graph.cpp Outdated
Comment thread src/dsf/mobility/RoadNetwork.hpp Outdated
@Grufoony Grufoony force-pushed the fixThresholdInPaths branch from f1e9f1a to 5adaeba Compare April 15, 2026 14:44
@Grufoony Grufoony force-pushed the fixThresholdInPaths branch from 5adaeba to c94bcff Compare April 17, 2026 06:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Grufoony Grufoony changed the title Now threshold in shortest paths is applied on the whole path, not ste… Fix threshold usage in shortest path computation Apr 20, 2026
@Grufoony Grufoony merged commit 8f347f8 into main Apr 20, 2026
53 checks passed
@Grufoony Grufoony deleted the fixThresholdInPaths branch April 20, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants