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 benchmark/Bench_Intersection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/dsf/base/Node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 10 additions & 16 deletions src/dsf/mobility/RoadDynamics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Id> itineraryId = std::nullopt);
void addAgentsUniformly(std::size_t nAgents,
std::optional<Id> itineraryId = std::nullopt);

/// @brief Add an agent to the simulation
/// @param agent std::unique_ptr to the agent
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1753,7 +1754,7 @@ namespace dsf::mobility {

template <typename delay_t>
requires(is_numeric_v<delay_t>)
void RoadDynamics<delay_t>::addAgentsUniformly(Size nAgents,
void RoadDynamics<delay_t>::addAgentsUniformly(std::size_t nAgents,
std::optional<Id> optItineraryId) {
m_nAddedAgents += nAgents;
if (m_timeToleranceFactor.has_value() && !m_agents.empty()) {
Expand All @@ -1773,10 +1774,9 @@ namespace dsf::mobility {
bool const bRandomItinerary{!optItineraryId.has_value() &&
!this->itineraries().empty()};
std::shared_ptr<Itinerary> pItinerary;
std::uniform_int_distribution<Size> itineraryDist{
0, static_cast<Size>(this->itineraries().size() - 1)};
std::uniform_int_distribution<Size> streetDist{
0, static_cast<Size>(this->graph().nEdges() - 1)};
std::uniform_int_distribution<std::size_t> itineraryDist{
0, this->itineraries().size() - 1};
std::uniform_int_distribution<std::size_t> 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 "
Expand All @@ -1785,15 +1785,15 @@ 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));
pItinerary = itineraryIt->second;
}
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;
Expand Down Expand Up @@ -2575,12 +2575,6 @@ namespace dsf::mobility {
}
}

template <typename delay_t>
requires(is_numeric_v<delay_t>)
Size RoadDynamics<delay_t>::nAgents() const {
return m_nAgents;
}

template <typename delay_t>
requires(is_numeric_v<delay_t>)
Measurement<double> RoadDynamics<delay_t>::meanTravelTime(bool clearData) {
Expand Down
6 changes: 2 additions & 4 deletions src/dsf/mobility/RoadNetwork.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoadJunction, Street> {
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.
Expand Down Expand Up @@ -239,7 +237,7 @@ namespace dsf::mobility {
const std::unique_ptr<Street>* 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
Expand Down
2 changes: 0 additions & 2 deletions src/dsf/mobility/Roundabout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<Agent>> m_agents;
Expand Down
4 changes: 2 additions & 2 deletions src/dsf/mobility/Street.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ namespace dsf::mobility {
void resetCounter();

/// @brief Get the street's queue
/// @return dsf::queue<Size>, The street's queue
/// @return const dsf::queue<std::unique_ptr<Agent>>&, The street's queue
const dsf::queue<std::unique_ptr<Agent>>& queue(size_t const& index) const {
return m_exitQueues[index];
}
/// @brief Get the street's queues
/// @return std::vector<dsf::queue<Size>> The street's queues
/// @return std::vector<dsf::queue<std::unique_ptr<Agent>>> The street's queues
std::vector<dsf::queue<std::unique_ptr<Agent>>> const& exitQueues() const {
return m_exitQueues;
}
Expand Down
1 change: 0 additions & 1 deletion src/dsf/utility/Typedef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
Loading