Skip to content

Commit 362e2c5

Browse files
authored
Remove normDensity function from Street class (#216)
* Remove `normDensity` function from Street class * Update version
1 parent d22a673 commit 362e2c5

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/dsm/dsm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
static constexpr uint8_t DSM_VERSION_MAJOR = 2;
88
static constexpr uint8_t DSM_VERSION_MINOR = 1;
9-
static constexpr uint8_t DSM_VERSION_PATCH = 6;
9+
static constexpr uint8_t DSM_VERSION_PATCH = 7;
1010

1111
#define DSM_VERSION \
1212
std::format("{}.{}.{}", DSM_VERSION_MAJOR, DSM_VERSION_MINOR, DSM_VERSION_PATCH)

src/dsm/headers/Dynamics.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ namespace dsm {
12091209
std::vector<double> densities;
12101210
densities.reserve(m_graph.streetSet().size());
12111211
for (const auto& [streetId, street] : m_graph.streetSet()) {
1212-
densities.push_back(normalized ? street->normDensity() : street->density());
1212+
densities.push_back(street->density(normalized));
12131213
}
12141214
return Measurement<double>(densities);
12151215
}
@@ -1232,9 +1232,9 @@ namespace dsm {
12321232
std::vector<double> flows;
12331233
flows.reserve(m_graph.streetSet().size());
12341234
for (const auto& [streetId, street] : m_graph.streetSet()) {
1235-
if (above and (street->normDensity() > threshold)) {
1235+
if (above && (street->density(true) > threshold)) {
12361236
flows.push_back(street->density() * this->streetMeanSpeed(streetId));
1237-
} else if (!above and (street->normDensity() < threshold)) {
1237+
} else if (!above && (street->density(true) < threshold)) {
12381238
flows.push_back(street->density() * this->streetMeanSpeed(streetId));
12391239
}
12401240
}
@@ -1364,7 +1364,7 @@ namespace dsm {
13641364
const auto& agent{this->m_agents[agentId]};
13651365
const auto& street{this->m_graph.streetSet()[agent->streetId().value()]};
13661366
double speed{street->maxSpeed() *
1367-
(1. - this->m_minSpeedRateo * street->normDensity())};
1367+
(1. - this->m_minSpeedRateo * street->density(true))};
13681368
if (this->m_speedFluctuationSTD > 0.) {
13691369
std::normal_distribution<double> speedDist{speed,
13701370
speed * this->m_speedFluctuationSTD};
@@ -1456,11 +1456,11 @@ namespace dsm {
14561456
speeds.reserve(this->m_graph.streetSet().size());
14571457
for (const auto& [streetId, street] : this->m_graph.streetSet()) {
14581458
if (above) {
1459-
if (street->normDensity() > threshold) {
1459+
if (street->density(true) > threshold) {
14601460
speeds.push_back(this->streetMeanSpeed(streetId));
14611461
}
14621462
} else {
1463-
if (street->normDensity() < threshold) {
1463+
if (street->density(true) < threshold) {
14641464
speeds.push_back(this->streetMeanSpeed(streetId));
14651465
}
14661466
}

src/dsm/headers/Street.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ namespace dsm {
153153
return nAgents;
154154
}
155155

156+
double Street::density(bool normalized) const {
157+
return normalized ? nAgents() / static_cast<double>(m_capacity)
158+
: nAgents() / (m_len * m_nLanes);
159+
}
160+
156161
Size Street::nExitingAgents() const {
157162
Size nAgents{0};
158163
for (const auto& queue : m_exitQueues) {

src/dsm/headers/Street.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ namespace dsm {
166166
/// @brief Get the number of agents on the street
167167
/// @return Size, The number of agents on the street
168168
Size nAgents() const;
169-
/// @brief Get the street's density in \f$m^{-1}\f$
169+
/// @brief Get the street's density in \f$m^{-1}\f$ or in \f$a.u.\f$, if normalized
170+
/// @param normalized If true, the street's density is normalized by the street's capacity
170171
/// @return double, The street's density
171-
double density() const { return nAgents() / (m_len * m_nLanes); }
172-
/// @brief Get the street's normalized density
173-
/// @return double, The street's normalized density
174-
double normDensity() const { return nAgents() / static_cast<double>(m_capacity); }
172+
double density(bool normalized = false) const;
175173
/// @brief Check if the street is full
176174
/// @return bool, True if the street is full, false otherwise
177175
bool isFull() const { return nAgents() == m_capacity; }

0 commit comments

Comments
 (0)