Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
035b62c
Init tbb::arena
Grufoony Feb 20, 2025
771f13f
Remove useless virtualization
Grufoony Feb 21, 2025
78139cc
Evolving one agent at time
Grufoony Feb 21, 2025
c357e42
Merge branch 'main' into parallelchesembraandare
Grufoony Feb 21, 2025
ee9d68e
Merge branch 'main' into parallelchesembraandare
Grufoony Feb 21, 2025
092bac9
Implement < operator for Agents
Grufoony Feb 24, 2025
dab837a
Simplified setStreetId
Grufoony Feb 24, 2025
36fda43
cose sensate
Grufoony Feb 24, 2025
cceb2b3
Cose meno sensate
Grufoony Feb 24, 2025
a29862f
Remove copy constructors from Edges
Grufoony Feb 24, 2025
5d7f725
Merge branch 'noCopyCOnstructors' into ReworkAgentHandling
Grufoony Feb 24, 2025
dabab1f
Working streets
Grufoony Feb 24, 2025
d0f4e5e
Working streets
Grufoony Feb 24, 2025
e6961e5
Working
Grufoony Feb 24, 2025
b629c24
Seems to compile
Grufoony Feb 24, 2025
68169df
Working on...
Grufoony Feb 24, 2025
d9b21d4
Fix one roundabout test
Grufoony Feb 24, 2025
a1fea5d
Remove useless headers
Grufoony Feb 25, 2025
7024fd4
Small refactor
Grufoony Feb 25, 2025
2e9ca1a
Enqueued agents must have null speed
Grufoony Feb 25, 2025
1a6f12b
Fix node evoution
Grufoony Feb 25, 2025
e5e1795
Last intersection test
Grufoony Feb 25, 2025
272c936
Agent loop optimization
Grufoony Feb 25, 2025
f7dce97
More tests!
Grufoony Feb 25, 2025
6929b23
Fix mean speed getter
Grufoony Feb 25, 2025
118128c
More tests...
Grufoony Feb 25, 2025
15eaa3d
Some traffic light's tests
Grufoony Feb 25, 2025
4cea22d
Finish tl tests
Grufoony Feb 25, 2025
d9c0775
One more test
Grufoony Feb 25, 2025
249dd99
Finish dynamic tests
Grufoony Feb 25, 2025
832a1df
Revert Adj tests
Grufoony Feb 25, 2025
4917d7d
Update action
Grufoony Feb 25, 2025
ca4e806
Try to fix macos test
Grufoony Feb 25, 2025
c108350
Update version
Grufoony Feb 25, 2025
09b68ce
Fix macos tests
Grufoony Feb 25, 2025
77331cd
Fix examples
Grufoony Feb 25, 2025
34683e9
Refactor limits
Grufoony Feb 25, 2025
dd8c0fe
Merge branch 'main' into parallelchesembraandare
Grufoony Feb 25, 2025
006c415
Parallel
Grufoony Feb 25, 2025
43fac2d
Update version
Grufoony Feb 25, 2025
172cfec
Add `saveMacroscopicObservables` as utility function
Grufoony Feb 26, 2025
557a591
Merge branch 'saveMacroscopicObservables' into dev
Grufoony Feb 26, 2025
d209378
Fix
Grufoony Feb 26, 2025
5cacf66
Fix
Grufoony Feb 26, 2025
819d26c
Fix
Grufoony Feb 26, 2025
f55af9b
Add getters with references for I/O nodes
Grufoony Feb 26, 2025
81da46a
Purtroppo non va
Grufoony Feb 26, 2025
30a3f8a
io nodes
Grufoony Feb 26, 2025
8f9f479
Revert "Purtroppo non va"
Grufoony Feb 27, 2025
719118e
Merge branch 'main' into ReworkAgentHandling
Grufoony Feb 28, 2025
95092cb
Merge branch 'ReworkAgentHandling' into dev
Grufoony Feb 28, 2025
190fe14
Add ghost agents to `saveMacroscopicObservables` function
Grufoony Feb 28, 2025
1919bec
Merge branch 'ReworkAgentHandling' into dev
Grufoony Feb 28, 2025
42a8677
Add optimized installation instruction on readme
Grufoony Feb 28, 2025
fe63fc2
Bugfix and add test
Grufoony Mar 1, 2025
32581fe
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 1, 2025
8c71362
New compiler flags
Grufoony Mar 3, 2025
f6364a0
Fix compilation
Grufoony Mar 3, 2025
39fc52d
Merge branch 'main' into ReworkAgentHandling
Grufoony Mar 4, 2025
fcd0cfe
Merge branch 'main' into ReworkAgentHandling
Grufoony Mar 4, 2025
08470e3
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 4, 2025
2d2f311
Let's try variant
Grufoony Mar 4, 2025
7d4eef0
Length
Grufoony Mar 4, 2025
0b11248
Uffa
Grufoony Mar 4, 2025
bce27f8
Debug log
Grufoony Mar 4, 2025
2d7c0bb
custom src weights
Grufoony Mar 4, 2025
52869eb
Revert "custom src weights"
Grufoony Mar 4, 2025
56ed7ca
While?
Grufoony Mar 4, 2025
6de5d74
AAAAAAAAAAAAAAAAAAAAAAAAA
Grufoony Mar 4, 2025
e618c41
Merge branch 'main' into ReworkAgentHandling
Grufoony Mar 5, 2025
d6c2ccc
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 5, 2025
6a3a2e1
Fix test
Grufoony Mar 5, 2025
187cc2d
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 5, 2025
f2f9aa2
Update
Grufoony Mar 5, 2025
51af56a
Merge branch 'main' into ReworkAgentHandling
Grufoony Mar 6, 2025
43f9e7f
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 6, 2025
9a77381
Add RoadJunction and floating point transport capacity
Grufoony Mar 7, 2025
5cdcb52
Working
Grufoony Mar 7, 2025
a029816
Merge branch 'RefactorNodes' into ReworkAgentHandling
Grufoony Mar 7, 2025
e91c010
Merge branch 'ReworkAgentHandling' into dev
Grufoony Mar 7, 2025
a08083c
Merge branch 'main' into dev
Grufoony Mar 10, 2025
09a73fa
Merge branch 'main' into dev
Grufoony Mar 10, 2025
0518603
Better save for coils
Grufoony Mar 10, 2025
2497cf4
Merge branch 'main' into dev
Grufoony Mar 11, 2025
6ed3674
Merge branch 'main' into dev
Grufoony Mar 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# DynamicalSystemFramework
[![Latest Release](https://img.shields.io/github/v/release/physycom/DynamicalSystemFramework)](https://github.com/physycom/DynamicalSystemFramework/releases/latest)
[![Standard](https://img.shields.io/badge/C%2B%2B-20/23-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
[![TBB](https://img.shields.io/badge/TBB-C%2B%2B20%2F23-blue.svg)](https://github.com/oneapi-src/oneTBB)
[![codecov](https://codecov.io/gh/physycom/DynamicalSystemFramework/graph/badge.svg?token=JV53J6IUJ3)](https://codecov.io/gh/physycom/DynamicalSystemFramework)
[![Latest Release](https://img.shields.io/github/v/release/physycom/DynamicalSystemFramework)](https://github.com/physycom/DynamicalSystemFramework/releases/latest)


The aim of this project is to rework the original [Traffic Flow Dynamics Model](https://github.com/Grufoony/TrafficFlowDynamicsModel).
This rework consists of a full code rewriting, in order to implement more features (like *intersections*) and get advantage from the latest C++ updates.
Expand Down
4 changes: 4 additions & 0 deletions src/dsm/headers/Dynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <filesystem>
#include <functional>

#include <tbb/tbb.h>

#include "Network.hpp"
#include "../utility/Logger.hpp"
#include "../utility/Typedef.hpp"
Expand Down Expand Up @@ -65,6 +67,7 @@ namespace dsm {
network_t m_graph;

protected:
tbb::task_arena m_taskArena;
Time m_time;
std::mt19937_64 m_generator;

Expand Down Expand Up @@ -94,5 +97,6 @@ namespace dsm {
if (seed.has_value()) {
m_generator.seed(*seed);
}
m_taskArena.initialize();
}
}; // namespace dsm
241 changes: 139 additions & 102 deletions src/dsm/headers/RoadDynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <exception>
#include <fstream>
#include <iomanip>
#include <variant>

#include <tbb/tbb.h>

Expand Down Expand Up @@ -50,7 +51,7 @@
std::unordered_map<Id, std::array<unsigned long long, 4>> m_turnCounts;
std::unordered_map<Id, std::array<long, 4>> m_turnMapping;
std::unordered_map<Id, double> m_streetTails;
std::vector<std::pair<double, double>> m_travelDTs;
tbb::concurrent_vector<std::pair<double, double>> m_travelDTs;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
Time m_previousOptimizationTime, m_previousSpireTime;

private:
Expand Down Expand Up @@ -147,16 +148,20 @@
/// @param nAgents The number of agents to add
/// @param src_weights The weights of the source nodes
/// @param dst_weights The weights of the destination nodes
/// @param minNodeDistance The minimum distance between the source and destination nodes
/// @throw std::invalid_argument If the source and destination nodes are the same
template <typename TContainer>
requires(std::is_same_v<TContainer, std::unordered_map<Id, double>> ||
std::is_same_v<TContainer, std::map<Id, double>>)
void addAgentsRandomly(Size nAgents,
const TContainer& src_weights,
const TContainer& dst_weights,
const size_t minNodeDistance = 0);
const std::variant<std::monostate, size_t, double>

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
minNodeDistance = std::monostate{});

void addAgentsRandomly(Size nAgents, const size_t minNodeDistance = 0);
void addAgentsRandomly(Size nAgents,
const std::variant<std::monostate, size_t, double>
minNodeDistance = std::monostate{});

/// @brief Add an agent to the simulation
/// @param agent std::unique_ptr to the agent
Expand Down Expand Up @@ -583,7 +588,7 @@
}
}
if (!pAgentTemp->isRandom()) {
if (destinationNode->id() ==

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
this->itineraries().at(pAgentTemp->itineraryId())->destination()) {
bArrived = true;
}
Expand Down Expand Up @@ -734,7 +739,7 @@
bool updatePaths) {
std::for_each(
destinationNodes.begin(),
destinationNodes.end(),

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
[this](auto const& nodeId) -> void { this->addItinerary(nodeId, nodeId); });
if (updatePaths) {
this->updatePaths();
Expand Down Expand Up @@ -798,19 +803,18 @@
template <typename TContainer>
requires(std::is_same_v<TContainer, std::unordered_map<Id, double>> ||
std::is_same_v<TContainer, std::map<Id, double>>)
void RoadDynamics<delay_t>::addAgentsRandomly(Size nAgents,
const TContainer& src_weights,
const TContainer& dst_weights,
const size_t minNodeDistance) {
void RoadDynamics<delay_t>::addAgentsRandomly(
Size nAgents,
const TContainer& src_weights,
const TContainer& dst_weights,
const std::variant<std::monostate, size_t, double> minNodeDistance) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
auto const& nSources{src_weights.size()};
auto const& nDestinations{dst_weights.size()};
Logger::debug(
std::format("Init addAgentsRandomly for {} agents from {} nodes to {} nodes with "
"minNodeDistance {}",
std::format("Init addAgentsRandomly for {} agents from {} nodes to {} nodes.",
nAgents,
nSources,
dst_weights.size(),
minNodeDistance));
dst_weights.size()));
if (nSources == 1 && nDestinations == 1 &&
src_weights.begin()->first == dst_weights.begin()->first) {
throw std::invalid_argument(Logger::buildExceptionMessage(
Expand Down Expand Up @@ -871,10 +875,23 @@
if (this->itineraries().at(id)->path()->getRow(srcId).empty()) {
continue;
}
if (nDestinations > 1 && minNodeDistance > 0) {
// NOTE: Result must have a value in this case, so we can use value() as sort-of assertion
if (std::holds_alternative<size_t>(minNodeDistance)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
auto const minDistance{std::get<size_t>(minNodeDistance)};

Check warning on line 879 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L879

Added line #L879 was not covered by tests
if (this->graph().shortestPath(srcId, id).value().path().size() <
minNodeDistance) {
minDistance) {
continue;

Check warning on line 882 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L882

Added line #L882 was not covered by tests
}
} else if (std::holds_alternative<double>(minNodeDistance)) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
auto const minDistance{std::get<double>(minNodeDistance)};
if (this->graph()

Check warning on line 886 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L885-L886

Added lines #L885 - L886 were not covered by tests
.shortestPath(srcId, id, weight_functions::streetLength)
.value()
.distance() < minDistance) {
Logger::debug(

Check warning on line 890 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L888-L890

Added lines #L888 - L890 were not covered by tests
std::format("Skipping node {} because the distance from the source "
"is less than {}",
id,
minDistance));
continue;
}
}
Expand All @@ -901,8 +918,8 @@

template <typename delay_t>
requires(is_numeric_v<delay_t>)
void RoadDynamics<delay_t>::addAgentsRandomly(Size nAgents,
const size_t minNodeDistance) {
void RoadDynamics<delay_t>::addAgentsRandomly(
Size nAgents, const std::variant<std::monostate, size_t, double> minNodeDistance) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
std::unordered_map<Id, double> src_weights, dst_weights;
for (auto const& id : this->graph().inputNodes()) {
src_weights[id] = 1.;
Expand Down Expand Up @@ -958,108 +975,123 @@
}
m_itineraries.emplace(itinerary->id(), std::move(itinerary));
}

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 14.4 rule Note

MISRA 14.4 rule
template <typename delay_t>
requires(is_numeric_v<delay_t>)
void RoadDynamics<delay_t>::evolve(bool reinsert_agents) {
Logger::debug("Init evolve");
// move the first agent of each street queue, if possible, putting it in the next node
bool const bUpdateData =
m_dataUpdatePeriod.has_value() && this->time() % m_dataUpdatePeriod.value() == 0;

Check notice

Code scanning / Cppcheck (reported by Codacy)

time is Y2038-unsafe Note

time is Y2038-unsafe
auto const N{this->graph().nNodes()};
std::for_each(
this->graph().nodes().cbegin(),
this->graph().nodes().cend(),
[&](const auto& pair) {
for (auto const& sourceId :
this->graph().adjacencyMatrix().getCol(pair.first)) {
auto const streetId = sourceId * N + pair.first;
auto const& pStreet{this->graph().edge(streetId)};
if (bUpdateData) {
m_streetTails[streetId] += pStreet->nExitingAgents();
}
m_evolveStreet(pStreet, reinsert_agents);

while (!pStreet->movingAgents().empty()) {
auto const& pAgent{pStreet->movingAgents().top()};
if (pAgent->freeTime() < this->time()) {
break;
}
pAgent->setSpeed(0.);
auto const nLanes = pStreet->nLanes();
bool bArrived{false};
if (!pAgent->isRandom()) {
if (this->itineraries().at(pAgent->itineraryId())->destination() ==
pStreet->target()) {
pAgent->updateItinerary();
}
if (this->itineraries().at(pAgent->itineraryId())->destination() ==
pStreet->target()) {
bArrived = true;
auto const numNodes{this->graph().nNodes()};
const auto& nodes =
this->graph().nodes(); // assuming a container with contiguous indices
const unsigned int concurrency = std::thread::hardware_concurrency();
// Calculate a grain size to partition the nodes into roughly "concurrency" blocks
const size_t grainSize = std::max(size_t(1), numNodes / concurrency);
this->m_taskArena.execute([&] {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, numNodes, grainSize),

Check warning on line 995 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L995

Added line #L995 was not covered by tests
[&](const tbb::blocked_range<size_t>& range) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 13.1 rule Note

MISRA 13.1 rule
for (size_t i = range.begin(); i != range.end(); ++i) {
const auto& pNode = nodes.at(i);
for (auto const& sourceId :
this->graph().adjacencyMatrix().getCol(pNode->id())) {
auto const streetId = sourceId * N + pNode->id();

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
auto const& pStreet{this->graph().edge(streetId)};
if (bUpdateData) {
m_streetTails[streetId] += pStreet->nExitingAgents();
}
}
if (bArrived) {
std::uniform_int_distribution<size_t> laneDist{
0, static_cast<size_t>(nLanes - 1)};
pStreet->enqueue(laneDist(this->m_generator));
continue;
}
auto const nextStreetId =
this->m_nextStreetId(pAgent, pStreet->target(), pStreet->id());
auto const& pNextStreet{this->graph().edge(nextStreetId)};
pAgent->setNextStreetId(nextStreetId);
if (nLanes == 1) {
pStreet->enqueue(0);
continue;
}
auto const deltaAngle{pNextStreet->deltaAngle(pStreet->angle())};
if (std::abs(deltaAngle) < std::numbers::pi) {
// Lanes are counted as 0 is the far right lane
if (std::abs(deltaAngle) < std::numbers::pi / 4) {
std::vector<double> weights;
for (auto const& queue : pStreet->exitQueues()) {
weights.push_back(1. / (queue.size() + 1));
m_evolveStreet(pStreet, reinsert_agents);

while (!pStreet->movingAgents().empty()) {
auto const& pAgent{pStreet->movingAgents().top()};
if (pAgent->freeTime() < this->time()) {
break;

Check warning on line 1011 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L1011

Added line #L1011 was not covered by tests
}
// If all weights are the same, make the last 0
if (std::all_of(weights.begin(), weights.end(), [&](double w) {
return std::abs(w - weights.front()) <
std::numeric_limits<double>::epsilon();
})) {
weights.back() = 0.;
if (nLanes > 2) {
weights.front() = 0.;
pAgent->setSpeed(0.);
auto const nLanes = pStreet->nLanes();
bool bArrived{false};
if (!pAgent->isRandom()) {
if (this->itineraries().at(pAgent->itineraryId())->destination() ==
pStreet->target()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
pAgent->updateItinerary();
}
if (this->itineraries().at(pAgent->itineraryId())->destination() ==
pStreet->target()) {
bArrived = true;
}
}

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 15.5 rule Note

MISRA 15.5 rule
// Normalize the weights
auto const sum = std::accumulate(weights.begin(), weights.end(), 0.);
for (auto& w : weights) {
w /= sum;
if (bArrived) {
std::uniform_int_distribution<size_t> laneDist{
0, static_cast<size_t>(nLanes - 1)};
pStreet->enqueue(laneDist(this->m_generator));
continue;
}
auto const nextStreetId =
this->m_nextStreetId(pAgent, pStreet->target(), pStreet->id());
auto const& pNextStreet{this->graph().edge(nextStreetId)};
pAgent->setNextStreetId(nextStreetId);
if (nLanes == 1) {
pStreet->enqueue(0);
continue;
}
auto const deltaAngle{pNextStreet->deltaAngle(pStreet->angle())};
if (std::abs(deltaAngle) < std::numbers::pi) {
// Lanes are counted as 0 is the far right lane
if (std::abs(deltaAngle) < std::numbers::pi / 4) {
std::vector<double> weights;
for (auto const& queue : pStreet->exitQueues()) {
weights.push_back(1. / (queue.size() + 1));
}
// If all weights are the same, make the last 0
if (std::all_of(weights.begin(), weights.end(), [&](double w) {
return std::abs(w - weights.front()) <
std::numeric_limits<double>::epsilon();
})) {
weights.back() = 0.;
if (nLanes > 2) {
weights.front() = 0.;
}
}
// Normalize the weights
auto const sum =
std::accumulate(weights.begin(), weights.end(), 0.);
for (auto& w : weights) {
w /= sum;
}
std::discrete_distribution<size_t> laneDist{weights.begin(),
weights.end()};
pStreet->enqueue(laneDist(this->m_generator));
} else if (deltaAngle < 0.) { // Right
pStreet->enqueue(0); // Always the first lane

Check warning on line 1068 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L1068

Added line #L1068 was not covered by tests
} else { // Left (deltaAngle > 0.)
pStreet->enqueue(nLanes - 1); // Always the last lane
}
} else { // U turn
pStreet->enqueue(nLanes - 1); // Always the last lane

Check warning on line 1073 in src/dsm/headers/RoadDynamics.hpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/headers/RoadDynamics.hpp#L1073

Added line #L1073 was not covered by tests
}
std::discrete_distribution<size_t> laneDist{weights.begin(),
weights.end()};
pStreet->enqueue(laneDist(this->m_generator));
} else if (deltaAngle < 0.) { // Right
pStreet->enqueue(0); // Always the first lane
} else { // Left (deltaAngle > 0.)
pStreet->enqueue(nLanes - 1); // Always the last lane
}
} else { // U turn
pStreet->enqueue(nLanes - 1); // Always the last lane
}
}
}
});
});
});
Logger::debug("Pre-nodes");
// Move transport capacity agents from each node
std::for_each(this->graph().nodes().cbegin(),
this->graph().nodes().cend(),
[&](const auto& pair) {
m_evolveNode(pair.second);
if (pair.second->isTrafficLight()) {
auto& tl = dynamic_cast<TrafficLight&>(*pair.second);
++tl;
}
});
this->m_taskArena.execute([&] {
tbb::parallel_for(tbb::blocked_range<size_t>(0, numNodes, grainSize),

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
[&](const tbb::blocked_range<size_t>& range) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 13.1 rule Note

MISRA 13.1 rule
for (size_t i = range.begin(); i != range.end(); ++i) {
const auto& pNode = nodes.at(i);
m_evolveNode(pNode);
if (pNode->isTrafficLight()) {
auto& tl = dynamic_cast<TrafficLight&>(*pNode);
++tl;
}
}
});
});
// cycle over agents and update their times
std::uniform_int_distribution<Id> nodeDist{
0, static_cast<Id>(this->graph().nNodes() - 1)};
Expand Down Expand Up @@ -1519,8 +1551,12 @@
}
if (bEmptyFile) {
file << "time";
for (auto const& [streetId, _] : this->graph().edges()) {
file << separator << streetId;
for (auto const& [streetId, pStreet] : this->graph().edges()) {

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.3 rule Note

MISRA 12.3 rule
if (!pStreet->isSpire()) {
continue;
}
auto& spire = dynamic_cast<SpireStreet&>(*pStreet);
file << separator << spire.code();
}
file << std::endl;
}
Expand All @@ -1533,8 +1569,8 @@
} else {
value = dynamic_cast<SpireStreet&>(*pStreet).outputCounts(reset);
}
file << separator << value;
}
file << separator << value;
}
file << std::endl;
file.close();
Expand Down Expand Up @@ -1645,6 +1681,7 @@
file << speed.mean << separator << speed.std << std::endl;
m_travelDTs.clear();
}
m_travelDTs.clear();
file.close();
}
}; // namespace dsm
7 changes: 6 additions & 1 deletion src/dsm/sources/RoadNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,13 @@
file << ";traffic_light";
} else if (pNode->isRoundabout()) {
file << ";roundabout";
} else if (std::find(m_inputNodes.begin(), m_inputNodes.end(), nodeId) !=
m_inputNodes.end() ||
std::find(m_outputNodes.begin(), m_outputNodes.end(), nodeId) !=
m_outputNodes.end()) {
file << ";io";

Check warning on line 649 in src/dsm/sources/RoadNetwork.cpp

View check run for this annotation

Codecov / codecov/patch

src/dsm/sources/RoadNetwork.cpp#L649

Added line #L649 was not covered by tests
} else {
file << ";intersection";
file << ";";
}
file << '\n';
}
Expand Down
Loading
Loading