diff --git a/benchmark/Bench_Intersection.cpp b/benchmark/Bench_Intersection.cpp index 62b18438..bf1ecfe2 100644 --- a/benchmark/Bench_Intersection.cpp +++ b/benchmark/Bench_Intersection.cpp @@ -51,7 +51,7 @@ static void BM_Intersection_nAgents(benchmark::State& state) { intersection.addAgent(std::move(agent)); } for (auto _ : state) { - dsf::Size n = intersection.nAgents(); + auto n = intersection.nAgents(); benchmark::DoNotOptimize(n); } } diff --git a/src/dsf/base/Node.hpp b/src/dsf/base/Node.hpp index 6309d009..39778a76 100644 --- a/src/dsf/base/Node.hpp +++ b/src/dsf/base/Node.hpp @@ -22,8 +22,6 @@ namespace dsf { /// @brief The Node class represents the concept of a node in the network. - /// @tparam Id The type of the node's id - /// @tparam Size The type of the node's capacity class Node { protected: Id m_id; diff --git a/src/dsf/mobility/RoadDynamics.hpp b/src/dsf/mobility/RoadDynamics.hpp index c821aac4..30abe784 100644 --- a/src/dsf/mobility/RoadDynamics.hpp +++ b/src/dsf/mobility/RoadDynamics.hpp @@ -305,7 +305,8 @@ namespace dsf::mobility { /// @param nAgents The number of agents to add /// @param itineraryId The id of the itinerary to use (default is std::nullopt) /// @throw std::runtime_error If there are no itineraries - void addAgentsUniformly(Size nAgents, std::optional itineraryId = std::nullopt); + void addAgentsUniformly(std::size_t nAgents, + std::optional itineraryId = std::nullopt); /// @brief Add an agent to the simulation /// @param agent std::unique_ptr to the agent @@ -390,8 +391,8 @@ namespace dsf::mobility { return m_agents; } /// @brief Get the number of agents currently in the simulation - /// @return Size The number of agents - Size nAgents() const; + /// @return std::size_t The number of agents + inline auto nAgents() const { return m_nAgents.load(); }; /// @brief Get the mean travel time of the agents in \f$s\f$ /// @param clearData If true, the travel times are cleared after the computation @@ -1753,7 +1754,7 @@ namespace dsf::mobility { template requires(is_numeric_v) - void RoadDynamics::addAgentsUniformly(Size nAgents, + void RoadDynamics::addAgentsUniformly(std::size_t nAgents, std::optional optItineraryId) { m_nAddedAgents += nAgents; if (m_timeToleranceFactor.has_value() && !m_agents.empty()) { @@ -1773,10 +1774,9 @@ namespace dsf::mobility { bool const bRandomItinerary{!optItineraryId.has_value() && !this->itineraries().empty()}; std::shared_ptr pItinerary; - std::uniform_int_distribution itineraryDist{ - 0, static_cast(this->itineraries().size() - 1)}; - std::uniform_int_distribution streetDist{ - 0, static_cast(this->graph().nEdges() - 1)}; + std::uniform_int_distribution itineraryDist{ + 0, this->itineraries().size() - 1}; + std::uniform_int_distribution streetDist{0, this->graph().nEdges() - 1}; if (this->nAgents() + nAgents > this->graph().capacity()) { throw std::overflow_error(std::format( "Cannot add {} agents. The graph has currently {} with a maximum capacity of " @@ -1785,7 +1785,7 @@ namespace dsf::mobility { this->nAgents(), this->graph().capacity())); } - for (Size i{0}; i < nAgents; ++i) { + for (std::size_t i{0}; i < nAgents; ++i) { if (bRandomItinerary) { auto itineraryIt{this->itineraries().cbegin()}; std::advance(itineraryIt, itineraryDist(this->m_generator)); @@ -1793,7 +1793,7 @@ namespace dsf::mobility { } auto streetIt = this->graph().edges().begin(); while (true) { - Size step = streetDist(this->m_generator); + auto step = streetDist(this->m_generator); std::advance(streetIt, step); if (!(streetIt->second->isFull())) { break; @@ -2575,12 +2575,6 @@ namespace dsf::mobility { } } - template - requires(is_numeric_v) - Size RoadDynamics::nAgents() const { - return m_nAgents; - } - template requires(is_numeric_v) Measurement RoadDynamics::meanTravelTime(bool clearData) { diff --git a/src/dsf/mobility/RoadNetwork.hpp b/src/dsf/mobility/RoadNetwork.hpp index 8b0988fb..a1784e7e 100644 --- a/src/dsf/mobility/RoadNetwork.hpp +++ b/src/dsf/mobility/RoadNetwork.hpp @@ -43,11 +43,9 @@ namespace dsf::mobility { /// @brief The RoadNetwork class represents a graph in the network. - /// @tparam Id, The type of the graph's id. It must be an unsigned integral type. - /// @tparam Size, The type of the graph's capacity. It must be an unsigned integral type. class RoadNetwork : public Network { private: - unsigned long long m_capacity; + std::size_t m_capacity; /// @brief If every node has coordinates, set the street angles /// @details The street angles are set using the node's coordinates. @@ -239,7 +237,7 @@ namespace dsf::mobility { const std::unique_ptr* street(Id source, Id destination) const; /// @brief Get the maximum agent capacity - /// @return unsigned long long The maximum agent capacity of the graph + /// @return std::size_t The maximum agent capacity of the graph inline auto capacity() const noexcept { return m_capacity; } /// @brief Perform a global Dijkstra search to a target node from all other nodes in the graph diff --git a/src/dsf/mobility/Roundabout.hpp b/src/dsf/mobility/Roundabout.hpp index 66695f0e..3120e9ad 100644 --- a/src/dsf/mobility/Roundabout.hpp +++ b/src/dsf/mobility/Roundabout.hpp @@ -15,8 +15,6 @@ namespace dsf::mobility { /// @brief The Roundabout class represents a roundabout node in the network. - /// @tparam Id The type of the node's id - /// @tparam Size The type of the node's capacity class Roundabout : public RoadJunction { protected: dsf::queue> m_agents; diff --git a/src/dsf/mobility/Street.hpp b/src/dsf/mobility/Street.hpp index 90196e26..28098794 100644 --- a/src/dsf/mobility/Street.hpp +++ b/src/dsf/mobility/Street.hpp @@ -120,12 +120,12 @@ namespace dsf::mobility { void resetCounter(); /// @brief Get the street's queue - /// @return dsf::queue, The street's queue + /// @return const dsf::queue>&, The street's queue const dsf::queue>& queue(size_t const& index) const { return m_exitQueues[index]; } /// @brief Get the street's queues - /// @return std::vector> The street's queues + /// @return std::vector>> The street's queues std::vector>> const& exitQueues() const { return m_exitQueues; } diff --git a/src/dsf/utility/Typedef.hpp b/src/dsf/utility/Typedef.hpp index eacb0365..589af78b 100644 --- a/src/dsf/utility/Typedef.hpp +++ b/src/dsf/utility/Typedef.hpp @@ -17,7 +17,6 @@ namespace dsf { using Id = uint64_t; - using Size = uint32_t; using Delay = uint16_t; enum class PathWeight : uint8_t { LENGTH = 0, TRAVELTIME = 1, WEIGHT = 2 };