Skip to content

Conversation

@Grufoony
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

❌ Patch coverage is 99.31507% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.59%. Comparing base (d787e02) to head (a9b050e).

Files with missing lines Patch % Lines
src/dsf/utility/queue.hpp 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #397      +/-   ##
==========================================
+ Coverage   85.30%   85.59%   +0.28%     
==========================================
  Files          53       53              
  Lines        5941     6067     +126     
  Branches      652      658       +6     
==========================================
+ Hits         5068     5193     +125     
- Misses        862      863       +1     
  Partials       11       11              
Flag Coverage Δ
unittests 85.59% <99.31%> (+0.28%) ⬆️

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.

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 pull request adds functionality to dynamically change the number of lanes on streets in a road network simulation. The PR introduces methods to modify lane counts both at the Street level and RoadNetwork level (by ID or by name), with optional speed factor adjustments to simulate scenarios like construction zones.

Changes:

  • Added Street::changeNLanes() method to modify lane count with optional speed adjustment
  • Added RoadNetwork::changeStreetNLanesById() and RoadNetwork::changeStreetNLanesByName() methods
  • Updated dsf::queue and dsf::priority_queue classes with move semantics and deleted copy operations
  • Added comprehensive test coverage for the new functionality
  • Exposed the new methods to Python through pybind11 bindings

Reviewed changes

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

Show a summary per file
File Description
src/dsf/mobility/Street.hpp Added changeNLanes() method declaration and private helper m_updateLaneMapping()
src/dsf/mobility/Street.cpp Implemented changeNLanes() and refactored lane mapping logic into helper method
src/dsf/mobility/RoadNetwork.hpp Added changeStreetNLanesById() and changeStreetNLanesByName() method declarations
src/dsf/mobility/RoadNetwork.cpp Implemented RoadNetwork-level lane change methods and added logging to setStreetStatusById()
src/dsf/utility/queue.hpp Added move constructors/operators and deleted copy operations; added using directives for base constructors
src/dsf/bindings.cpp Exposed new lane change methods to Python API
test/mobility/Test_street.cpp Added comprehensive tests for Street::changeNLanes()
test/mobility/Test_graph.cpp Added comprehensive tests for RoadNetwork lane change methods

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

Comment on lines +968 to +971
pStreet->changeNLanes(nLanes);
if (speedFactor.has_value()) {
pStreet->setMaxSpeed(pStreet->maxSpeed() * speedFactor.value());
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The Street::changeNLanes method already accepts an optional speedFactor parameter, but this implementation calls changeNLanes without it and then separately calls setMaxSpeed. Consider passing the speedFactor directly to changeNLanes instead: pStreet->changeNLanes(nLanes, speedFactor);. This would simplify the code and use the designed API more directly.

Copilot uses AI. Check for mistakes.
if (speedFactor.has_value()) {
m_maxSpeed = m_maxSpeed * speedFactor.value();
}
m_exitQueues.resize(m_nLanes);
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

When decreasing the number of lanes using m_exitQueues.resize(m_nLanes), agents in the removed queues will be lost. The queues contain std::unique_ptr<Agent>, so when the vector is resized down, the destructors will be called and the agents will be deleted. Consider handling these agents by moving them to remaining queues or throwing an error if there are agents present in the queues being removed.

Copilot uses AI. Check for mistakes.
Comment on lines +967 to +971
auto const& pStreet{edge(streetId)};
pStreet->changeNLanes(nLanes);
if (speedFactor.has_value()) {
pStreet->setMaxSpeed(pStreet->maxSpeed() * speedFactor.value());
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The RoadNetwork maintains a total capacity (m_capacity) that is the sum of all street capacities. When a street's number of lanes is changed, its capacity changes, but the RoadNetwork's total capacity is not updated. This will cause the network's capacity to become out of sync with the actual sum of street capacities. Consider updating the network's capacity by calculating the delta (new capacity - old capacity) and adding it to m_capacity.

Copilot uses AI. Check for mistakes.
Comment on lines +984 to +992
auto const& pStreet = pair.second;
if (pStreet->name().find(streetName) != std::string::npos) {
pStreet->changeNLanes(nLanes);
if (speedFactor.has_value()) {
pStreet->setMaxSpeed(pStreet->maxSpeed() * speedFactor.value());
}
++nAffectedRoads;
}
});
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The RoadNetwork maintains a total capacity (m_capacity) that is the sum of all street capacities. When streets' number of lanes are changed, their capacities change, but the RoadNetwork's total capacity is not updated. This will cause the network's capacity to become out of sync with the actual sum of street capacities. Consider tracking capacity changes for all affected streets and updating the network's m_capacity accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines +986 to +989
pStreet->changeNLanes(nLanes);
if (speedFactor.has_value()) {
pStreet->setMaxSpeed(pStreet->maxSpeed() * speedFactor.value());
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The Street::changeNLanes method already accepts an optional speedFactor parameter, but this implementation calls changeNLanes without it and then separately calls setMaxSpeed. Consider passing the speedFactor directly to changeNLanes instead: pStreet->changeNLanes(nLanes, speedFactor);. This would simplify the code and use the designed API more directly.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +14
using std::queue<T, Container>::queue;
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;

queue() = default;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The using std::queue<T, Container>::queue; directive at line 10 conflicts with the explicit queue() = default; constructor at line 14. When you use a using declaration to inherit constructors, you should not also explicitly declare the same constructors. The using declaration already brings in the default constructor from the base class. This can lead to ambiguity or compilation issues. Remove either the using declaration or the explicit queue() = default; declaration.

Copilot uses AI. Check for mistakes.
typedef typename Container::iterator iterator;
typedef typename Container::const_iterator const_iterator;

priority_queue() = default;
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The using std::priority_queue<T, Container, Compare>::priority_queue; directive at line 35 conflicts with the explicit priority_queue() = default; constructor at line 39. When you use a using declaration to inherit constructors, you should not also explicitly declare the same constructors. The using declaration already brings in the default constructor from the base class. This can lead to ambiguity or compilation issues. Remove either the using declaration or the explicit priority_queue() = default; declaration.

Suggested change
priority_queue() = default;

Copilot uses AI. Check for mistakes.
priority_queue(const priority_queue&) = delete;
priority_queue& operator=(const priority_queue&) = delete;

// c is a protected member of std::queue, which is the underlying container
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

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

The comment states "c is a protected member of std::queue" but should state "c is a protected member of std::priority_queue" since this is in the priority_queue class definition.

Suggested change
// c is a protected member of std::queue, which is the underlying container
// c is a protected member of std::priority_queue, which is the underlying container

Copilot uses AI. Check for mistakes.
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