-
Notifications
You must be signed in to change notification settings - Fork 4
Add utility to kill stagnant agents #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #341 +/- ##
==========================================
+ Coverage 83.49% 83.54% +0.05%
==========================================
Files 51 51
Lines 5089 5081 -8
Branches 587 584 -3
==========================================
- Hits 4249 4245 -4
+ Misses 828 824 -4
Partials 12 12
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:
|
|
I still don't know if it is worth to implement this... if the simulation is well-written you must not kill vwhicles to avoid gridlocks. |
| /// An agent will be considered stagnant if it has not moved for timeToleranceFactor * std::ceil(street_length / street_maxSpeed) time units. | ||
| /// @param timeToleranceFactor The time tolerance factor | ||
| /// @throw std::invalid_argument If the time tolerance factor is not positive | ||
| void killStagnantAgents(double timeToleranceFactor = 3.); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 13.4 rule Note
| /// An agent will be considered stagnant if it has not moved for timeToleranceFactor * std::ceil(street_length / street_maxSpeed) time units. | ||
| /// @param timeToleranceFactor The time tolerance factor | ||
| /// @throw std::invalid_argument If the time tolerance factor is not positive | ||
| void killStagnantAgents(double timeToleranceFactor = 3.); |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 17.8 rule Note
| static_cast<std::time_t>( | ||
| 3 * std::ceil(pStreet->length() / pStreet->maxSpeed())))}; | ||
| if (m_timeToleranceFactor.has_value()) { |
Check notice
Code scanning / Cppcheck (reported by Codacy)
MISRA 14.4 rule Note
There was a problem hiding this 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 adds functionality to automatically kill stagnant agents in traffic simulations. Stagnant agents are those that have not moved for a configurable time period, calculated as a multiple of the expected travel time for their current street.
- Adds
killStagnantAgents()method to configure automatic removal of stagnant agents - Implements agent killing logic during simulation evolution
- Cleans up leftover agents from failed insertion attempts
- Fixes spelling of parameter name from
weigthThresholdtoweightThreshold
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/dsf/mobility/RoadDynamics.hpp | Adds time tolerance factor member, implements stagnant agent detection and removal logic, adds cleanup for failed agent insertions, and fixes parameter name spelling |
| src/dsf/bindings.cpp | Exposes the new killStagnantAgents method to Python bindings |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// @brief Set the time tolerance factor for killing stagnant agents. | ||
| /// An agent will be considered stagnant if it has not moved for timeToleranceFactor * std::ceil(street_length / street_maxSpeed) time units. | ||
| /// @param timeToleranceFactor The time tolerance factor |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation for this function is incorrect. It says "Set the time tolerance factor" but the function name is killStagnantAgents. The documentation should clarify that this function enables automatic killing of stagnant agents during evolution by setting a time tolerance factor, rather than just "setting" a parameter.
| /// @brief Set the time tolerance factor for killing stagnant agents. | |
| /// An agent will be considered stagnant if it has not moved for timeToleranceFactor * std::ceil(street_length / street_maxSpeed) time units. | |
| /// @param timeToleranceFactor The time tolerance factor | |
| /// @brief Enable automatic killing of stagnant agents during evolution by setting a time tolerance factor. | |
| /// After calling this function, agents that have not moved for timeToleranceFactor * std::ceil(street_length / street_maxSpeed) time units | |
| /// will be considered stagnant and will be automatically removed ("killed") from the simulation. | |
| /// @param timeToleranceFactor The time tolerance factor used to determine agent stagnation |
da0fa74 to
d57d369
Compare
TODO: