Skip to content

Conversation

@Grufoony
Copy link
Collaborator

@Grufoony Grufoony commented Oct 6, 2025

TODO:

  • Add tests for the new code

@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

❌ Patch coverage is 23.80952% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.54%. Comparing base (4d47642) to head (10fd7c9).

Files with missing lines Patch % Lines
src/dsf/mobility/RoadDynamics.hpp 23.80% 16 Missing ⚠️
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              
Flag Coverage Δ
unittests 83.54% <23.80%> (+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.

@Grufoony
Copy link
Collaborator Author

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.
Need to think about this

/// 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

MISRA 13.4 rule
/// 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

MISRA 17.8 rule
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

MISRA 14.4 rule
Copy link
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 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 weigthThreshold to weightThreshold

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.

Comment on lines +129 to +131
/// @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
Copy link

Copilot AI Nov 18, 2025

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.

Suggested change
/// @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

Copilot uses AI. Check for mistakes.
@Grufoony Grufoony force-pushed the killAgents branch 3 times, most recently from da0fa74 to d57d369 Compare November 18, 2025 11:32
@Grufoony Grufoony marked this pull request as ready for review November 18, 2025 12:25
@Grufoony Grufoony changed the title Kill agents Add utility to kill stagnant agents Nov 18, 2025
@Grufoony Grufoony merged commit 418c6ba into main Nov 18, 2025
38 of 41 checks passed
@Grufoony Grufoony deleted the killAgents branch November 18, 2025 12:43
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.

2 participants