Skip to content

Commit 79ef769

Browse files
committed
Fix some warnings
1 parent f7f5ac7 commit 79ef769

File tree

7 files changed

+20
-15
lines changed

7 files changed

+20
-15
lines changed

benchmark/Street/BenchStreet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ using SparseMatrix = dsm::SparseMatrix<bool>;
1313
using Bench = sb::Bench<long long int>;
1414

1515
int main() {
16-
Street street(0, 1000, 10., std::make_pair(0, 1));
16+
Street street(0, std::make_pair(0, 1), 5000.);
1717
Agent agent(0, 0, 0);
1818
Bench b(1000);
1919

src/dsm/headers/Dynamics.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ namespace dsm {
221221
const std::map<Id, std::unique_ptr<agent_t>>& agents() const { return m_agents; }
222222
/// @brief Get the number of agents currently in the simulation
223223
/// @return Size The number of agents
224-
const Size nAgents() const { return m_agents.size(); }
224+
Size nAgents() const { return m_agents.size(); }
225225
/// @brief Get the time
226226
/// @return Time The time
227227
Time time() const { return m_time; }

src/dsm/headers/Node.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace dsm {
3030
std::optional<std::pair<double, double>> m_coords;
3131
std::string m_name;
3232
Size m_capacity;
33-
Size m_transportCapacity;
33+
int m_transportCapacity;
3434

3535
public:
3636
/// @brief Construct a new Node object with capacity 1
@@ -79,7 +79,13 @@ namespace dsm {
7979
virtual void setCapacity(Size capacity) { m_capacity = capacity; }
8080
/// @brief Set the node's transport capacity
8181
/// @param capacity The node's transport capacity
82-
virtual void setTransportCapacity(Size capacity) { m_transportCapacity = capacity; }
82+
virtual void setTransportCapacity(int capacity) {
83+
if (capacity < 1) {
84+
throw std::invalid_argument(buildLog(std::format(
85+
"The transport capacity of a node ({}) must be greater than 0.", capacity)));
86+
}
87+
m_transportCapacity = capacity;
88+
}
8389
/// @brief Get the node's id
8490
/// @return Id The node's id
8591
Id id() const { return m_id; }
@@ -94,7 +100,7 @@ namespace dsm {
94100
Size capacity() const { return m_capacity; }
95101
/// @brief Get the node's transport capacity
96102
/// @return Size The node's transport capacity
97-
Size transportCapacity() const { return m_transportCapacity; }
103+
int transportCapacity() const { return m_transportCapacity; }
98104

99105
virtual double density() const = 0;
100106
virtual bool isFull() const = 0;

src/dsm/headers/RoadDynamics.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ namespace dsm {
420420
if (std::abs(deltaAngle) < std::numbers::pi) {
421421
// Lanes are counted as 0 is the far right lane
422422
if (std::abs(deltaAngle) < std::numbers::pi / 4) {
423-
auto const dstNodeId = pNextStreet->nodePair().first;
424423
std::vector<double> weights;
425424
for (auto const& queue : street->exitQueues()) {
426425
weights.push_back(1. / (queue.size() + 1));

src/dsm/headers/Street.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace dsm {
88
: Edge(id, street.nodePair(), street.capacity(), street.transportCapacity()),
99
m_length{street.length()},
1010
m_maxSpeed{street.maxSpeed()},
11-
m_angle{street.angle()},
1211
m_nLanes{street.nLanes()},
13-
m_name{street.name()} {
12+
m_name{street.name()},
13+
m_angle{street.angle()} {
1414
for (auto i{0}; i < street.nLanes(); ++i) {
1515
m_exitQueues.push_back(dsm::queue<Size>());
1616
}
@@ -135,8 +135,8 @@ namespace dsm {
135135
return id;
136136
}
137137

138-
Size Street::nAgents() const {
139-
Size nAgents{static_cast<Size>(m_waitingAgents.size())};
138+
int Street::nAgents() const {
139+
auto nAgents{static_cast<int>(m_waitingAgents.size())};
140140
for (const auto& queue : m_exitQueues) {
141141
nAgents += queue.size();
142142
}

src/dsm/headers/Street.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ namespace dsm {
3939
std::set<Id> m_waitingAgents;
4040
double m_length;
4141
double m_maxSpeed;
42-
double m_angle;
43-
std::string m_name;
4442
int m_nLanes;
43+
std::string m_name;
44+
double m_angle;
4545
static double m_meanVehicleLength;
4646

4747
public:
@@ -105,7 +105,7 @@ namespace dsm {
105105
const std::vector<dsm::queue<Size>>& exitQueues() const { return m_exitQueues; }
106106
/// @brief Get the number of agents on the street
107107
/// @return Size, The number of agents on the street
108-
Size nAgents() const;
108+
int nAgents() const;
109109
/// @brief Get the street's density in \f$m^{-1}\f$ or in \f$a.u.\f$, if normalized
110110
/// @param normalized If true, the street's density is normalized by the street's capacity
111111
/// @return double, The street's density

src/dsm/headers/TrafficLight.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ namespace dsm {
200200

201201
bool TrafficLight::isFavouringDirection(bool const priority) const {
202202
for (auto const& [streetId, cycles] : m_cycles) {
203-
if ((priority && m_streetPriorities.contains(streetId) ||
204-
(!priority && !m_streetPriorities.contains(streetId)))) {
203+
if ((priority && m_streetPriorities.contains(streetId)) ||
204+
(!priority && !m_streetPriorities.contains(streetId))) {
205205
for (auto const& cycle : cycles) {
206206
if (!cycle.isGreenTimeIncreased()) {
207207
return false;

0 commit comments

Comments
 (0)