Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #421 +/- ##
==========================================
- Coverage 87.80% 87.77% -0.03%
==========================================
Files 52 52
Lines 6208 6284 +76
Branches 689 697 +8
==========================================
+ Hits 5451 5516 +65
- Misses 738 749 +11
Partials 19 19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| GIVEN("A graph object") { | ||
| FirstOrderDynamics dynamics{defaultNetwork, false, 69, 0., dsf::PathWeight::LENGTH}; | ||
| WHEN("We add agents with a single OD pair") { | ||
| std::vector<std::tuple<dsf::Id, dsf::Id, double>> ods{{0, 2, 1.}}; |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note test
| dynamics.addAgents(3, AgentInsertionMethod::ODS); | ||
| THEN("All agents follow that single OD pair") { | ||
| CHECK_EQ(dynamics.nAgents(), 3); | ||
| for (size_t i = 0; i < 3; ++i) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 10.4 rule Note test
| } | ||
| } | ||
| WHEN("We add agents with multiple OD pairs") { | ||
| std::vector<std::tuple<dsf::Id, dsf::Id, double>> ods{{1, 14, 0.5}, |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note test
| auto const& agent = dynamics.agents().at(i); | ||
| auto dest = agent->itinerary()->destination(); | ||
| auto src = agent->srcNodeId().value(); | ||
| CHECK((dest == 14 || dest == 107)); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.1 rule Note test
| } | ||
| WHEN("We add agents with no OD pairs") { | ||
| THEN("An exception is thrown") { | ||
| CHECK_THROWS_AS(dynamics.addAgents(1, AgentInsertionMethod::ODS), |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 12.3 rule Note test
There was a problem hiding this comment.
Pull request overview
Refactors how agents are inserted into RoadDynamics by introducing a single addAgents(n, AgentInsertionMethod) entrypoint that supports random insertion, weighted random origin/destination selection, and explicit OD-pair based insertion. This is reflected across C++ tests and (partially) in the Python bindings.
Changes:
- Introduce
AgentInsertionMethodand new internal insertion implementations (m_addAgentsRandom,m_addAgentsODs,m_addAgentsRandomODs). - Add
setODs(...)to configure weighted origin-destination tuples for OD-based agent generation. - Update mobility tests and Python bindings to use the new
addAgents(..., insertionMethod=...)API.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| test/mobility/Test_dynamics.cpp | Updates tests to use the new insertion API and adds OD-pair insertion coverage. |
| src/dsf/mobility/RoadDynamics.hpp | Adds insertion-mode enum, OD storage/configuration, and refactors agent insertion logic. |
| src/dsf/bindings.cpp | Exposes the insertion enum and replaces old Python agent-insertion bindings with addAgents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.