Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/dsm/dsm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

static constexpr uint8_t DSM_VERSION_MAJOR = 2;
static constexpr uint8_t DSM_VERSION_MINOR = 1;
static constexpr uint8_t DSM_VERSION_PATCH = 6;
static constexpr uint8_t DSM_VERSION_PATCH = 7;

#define DSM_VERSION \
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH)
Expand Down
12 changes: 6 additions & 6 deletions src/dsm/headers/Dynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@
std::vector<double> densities;
densities.reserve(m_graph.streetSet().size());
for (const auto& [streetId, street] : m_graph.streetSet()) {
densities.push_back(normalized ? street->normDensity() : street->density());
densities.push_back(street->density(normalized));
}
return Measurement<double>(densities);
}
Expand All @@ -1232,9 +1232,9 @@
std::vector<double> flows;
flows.reserve(m_graph.streetSet().size());
for (const auto& [streetId, street] : m_graph.streetSet()) {
if (above and (street->normDensity() > threshold)) {
if (above && (street->density(true) > threshold)) {
flows.push_back(street->density() * this->streetMeanSpeed(streetId));
} else if (!above and (street->normDensity() < threshold)) {
} else if (!above && (street->density(true) < threshold)) {
flows.push_back(street->density() * this->streetMeanSpeed(streetId));
}
}
Expand Down Expand Up @@ -1364,7 +1364,7 @@
const auto& agent{this->m_agents[agentId]};
const auto& street{this->m_graph.streetSet()[agent->streetId().value()]};
double speed{street->maxSpeed() *
(1. - this->m_minSpeedRateo * street->normDensity())};
(1. - this->m_minSpeedRateo * street->density(true))};

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 12.1 rule Note

MISRA 12.1 rule
if (this->m_speedFluctuationSTD > 0.) {
std::normal_distribution<double> speedDist{speed,
speed * this->m_speedFluctuationSTD};
Expand Down Expand Up @@ -1456,11 +1456,11 @@
speeds.reserve(this->m_graph.streetSet().size());
for (const auto& [streetId, street] : this->m_graph.streetSet()) {
if (above) {
if (street->normDensity() > threshold) {
if (street->density(true) > threshold) {
speeds.push_back(this->streetMeanSpeed(streetId));
}
} else {
if (street->normDensity() < threshold) {
if (street->density(true) < threshold) {
speeds.push_back(this->streetMeanSpeed(streetId));
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/dsm/headers/Street.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@
return nAgents;
}

double Street::density(bool normalized) const {
return normalized ? nAgents() / static_cast<double>(m_capacity)
: nAgents() / (m_len * m_nLanes);

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 10.4 rule Note

MISRA 10.4 rule
}

Size Street::nExitingAgents() const {
Size nAgents{0};
for (const auto& queue : m_exitQueues) {
Expand Down
8 changes: 3 additions & 5 deletions src/dsm/headers/Street.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@
/// @brief Get the number of agents on the street
/// @return Size, The number of agents on the street
Size nAgents() const;
/// @brief Get the street's density in \f$m^{-1}\f$
/// @brief Get the street's density in \f$m^{-1}\f$ or in \f$a.u.\f$, if normalized
/// @param normalized If true, the street's density is normalized by the street's capacity
/// @return double, The street's density
double density() const { return nAgents() / (m_len * m_nLanes); }
/// @brief Get the street's normalized density
/// @return double, The street's normalized density
double normDensity() const { return nAgents() / static_cast<double>(m_capacity); }
double density(bool normalized = false) const;

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 13.4 rule Note

MISRA 13.4 rule

Check notice

Code scanning / Cppcheck (reported by Codacy)

MISRA 17.8 rule Note

MISRA 17.8 rule
/// @brief Check if the street is full
/// @return bool, True if the street is full, false otherwise
bool isFull() const { return nAgents() == m_capacity; }
Expand Down
Loading