|
Dynamical System Framework
|
The Street class represents a street in the network. More...
#include <Street.hpp>
Public Member Functions | |
| Street (Id id, std::pair< Node *, Node * > nodePair, double length=Road::meanVehicleLength(), double maxSpeed=13.8888888889, int nLanes=1, std::string name=std::string(), geometry::PolyLine geometry={}, std::optional< int > capacity=std::nullopt, double transportCapacity=1.) | |
| Construct a new Street object. | |
| Street (Street &&)=default | |
| Street (Street const &)=delete | |
| bool | operator== (Street const &other) const |
| RoadJunction * | source () noexcept |
| Get the street's source junction. | |
| RoadJunction const * | source () const noexcept |
| RoadJunction * | target () noexcept |
| Get the street's target junction. | |
| RoadJunction const * | target () const noexcept |
| void | setLaneMapping (std::vector< Direction > const &laneMapping) |
| Set the street's lane mapping. | |
| void | setQueue (dsf::queue< std::unique_ptr< Agent > > queue, size_t index) |
| Set the street's queue. | |
| auto | estimatedTravelTime () const |
| Get this street estimated travel time using the active global estimator. | |
| void | changeNLanes (int const nLanes, std::optional< double > const speedFactor=std::nullopt) |
| Change the number of lanes of the street. Usually if there is a construction site, you may want to reduce the number of lanes and possibly the max speed. | |
| void | enableCounter (std::string name=std::string(), CounterPosition position=CounterPosition::EXIT) |
| Enable a coil (dsf::Counter sensor) on the street. | |
| void | resetCounter () |
| Reset the counter of the street. | |
| auto const & | lanes () const noexcept |
| Get the street's lanes. | |
| auto const & | lane (std::size_t const index) const |
| Get a lane of the street. | |
| const dsf::queue< std::unique_ptr< Agent > > & | queue (size_t const &index) const |
| Get the street's queue. | |
| void | refillFlowAccumulator (std::size_t const index, std::time_t const timeStep) noexcept |
| Bring the exit gate of a lane up to date with a time step. | |
| std::size_t | nAgents () const final |
| Get the number of agents on the street. | |
| auto | counterName () const |
| Get the name of the counter. | |
| auto | counts () const |
| Get the counts of the counter. | |
| dsf::priority_queue< std::unique_ptr< Agent >, std::vector< std::unique_ptr< Agent > >, AgentComparator > & | movingAgents () |
| Get the street's moving agents priority queue. | |
| const auto & | movingAgents () const |
| std::size_t | nMovingAgents () const |
| Get the number of of moving agents, i.e. agents not yet enqueued. | |
| template<bool Normalized> | |
| double | movingDensity () const |
| Get the street's density of moving agents, i.e. excluding the queued ones. | |
| double | nExitingAgents (Direction direction=Direction::ANY, bool normalizeOnNLanes=false) const |
| Get the number of agents on all queues for a given direction. | |
| template<bool Reset> requires (!Reset) | |
| Measurement< double > | meanSpeed () const |
| Get the mean speed of the agents that have passed through the street. | |
|
template<bool Reset> requires (Reset) | |
| Measurement< double > | meanSpeed () |
| std::vector< Direction > | laneMapping () const |
| Get the street's lane mapping. | |
| void | addAgent (std::unique_ptr< Agent > pAgent, std::time_t const currentTime) |
| Add an agent to the street. | |
| std::unique_ptr< Agent > | dequeueMovingAgent () |
| Remove the top agent from the street's moving agents priority queue. | |
| std::unique_ptr< Agent > | dequeueArrivedAgent (std::time_t const currentTime) |
| Remove the top agent from the street's moving agents, which ends its trip at the end of the street, without queueing. | |
| void | enqueue (std::size_t const &queueId) |
| Add an agent to the street's queue. | |
| std::unique_ptr< Agent > | dequeue (std::size_t const &index, std::time_t const currentTime) |
| Remove an agent from the street's queue. | |
| constexpr bool | hasCoil () const |
| Check if the street has a coil (dsf::Counter sensor) on it. | |
| Public Member Functions inherited from dsf::mobility::Road | |
| Road (Id id, std::pair< Node *, Node * > nodePair, double length=m_meanVehicleLength, double maxSpeed=13.8888888889, int nLanes=1, std::string name=std::string(), geometry::PolyLine geometry={}, std::optional< int > capacity=std::nullopt, double transportCapacity=1.) | |
| Construct a new Road object. | |
| void | setMaxSpeed (double speed) |
| Set the maximum speed, in meters per second (default is 50 km/h). | |
| void | setCapacity (int capacity) |
| Set the capacity, in number of agents. | |
| void | setTransportCapacity (double transportCapacity) |
| Set the transport capacity, in number of agents per lane and time step. | |
| void | setPriority () |
| Set the road's priority to true. | |
| void | addForbiddenTurn (Id roadId) |
| Add a road id to the forbidden turns. | |
| void | setForbiddenTurns (std::set< Id > const &forbiddenTurns) |
| Replace the road's forbidden turns with the given set. | |
| void | setMobilityClass (std::uint8_t const mobilityClass) |
| Set the road type. | |
| void | setStatus (RoadStatus const status) |
| Set the road status. | |
| auto | length () const noexcept |
| Get the length, in meters. | |
| auto | maxSpeed () const noexcept |
| Get the maximum speed, in meters per second. | |
| auto | nLanes () const noexcept |
| Get the number of lanes. | |
| auto | capacity () const noexcept |
| Get the road's capacity, in number of agents. | |
| template<bool Normalized> | |
| double | density () const noexcept |
| Get the road's density in \(m^{-1}\) or in \(a.u.\), if normalized. | |
| bool | isFull () const final |
| Check if the road is full. | |
| bool | isActive () const final |
| Check if the road is active (i.e., open). | |
| auto | transportCapacity () const noexcept |
| Get the road's transport capacity, in number of agents per lane and time step. | |
| auto const & | name () const noexcept |
| Get the name. | |
| auto | hasPriority () const noexcept |
| Get the priority. | |
| auto const & | forbiddenTurns () const noexcept |
| Get the road's forbidden turns. | |
| auto | mobilityClass () const noexcept |
| Get the road mobility class. | |
| auto | roadStatus () const noexcept |
| Get the road status. | |
| Direction | turnDirection (double const &previousStreetAngle) const |
| Get the road's turn direction given the previous road angle. | |
| Public Member Functions inherited from dsf::Edge | |
| Edge (Id id, std::pair< Node *, Node * > nodePair, geometry::PolyLine geometry={}) | |
| Construct a new Edge object. | |
| Edge (Edge &&)=default | |
| Edge (const Edge &)=delete | |
| void | setGeometry (geometry::PolyLine geometry) |
| Set the edge's geometry. | |
| void | setAttribute (std::string const &name, std::variant< std::monostate, bool, std::int64_t, double, std::string > const &value) |
| Set an attribute for the edge. | |
| void | setSource (Node *pNode) |
| Replace the edge's source node, e.g. when the network changes its type. | |
| void | setTarget (Node *pNode) |
| Replace the edge's target node, e.g. when the network changes its type. | |
| void | setReverse (Edge *pEdge) |
| Set the edge's reverse, i.e. the edge v -> u. | |
| auto | id () const |
| Get the edge's id. | |
| auto const & | nodePair () const noexcept |
| Get the edge's nodes. | |
| Node * | source () const noexcept |
| Get the edge's source node. | |
| Node * | target () const noexcept |
| Get the edge's target node. | |
| Edge * | reverse () const noexcept |
| Get the edge's reverse, i.e. the edge v -> u. | |
| auto const & | geometry () const |
| Get the edge's geometry. | |
| auto | angle () const |
| Get the edge's angle, in radians, between the source and target nodes. | |
| auto const & | attributes () const |
| Get the edge's attributes. | |
| template<typename T> | |
| std::optional< T > | getAttribute (std::string const &name) const |
| Get an attribute of the edge by name. | |
| double | deltaAngle (double const previousEdgeAngle) const |
Static Public Member Functions | |
| static void | acquireAgentData () |
| static void | setMeanVehicleLength (double meanVehicleLength) |
| Set the mean vehicle length. | |
| static void | setEstimatedTravelTimeFunction (std::function< double(Street const &)> estimatedTravelTimeFunction) |
| Set the global street travel-time estimator. | |
| static std::function< double(Street const &)> const & | estimatedTravelTimeFunction () noexcept |
| Get the global street travel-time estimator. | |
| static auto | agentData () |
| Static Public Member Functions inherited from dsf::mobility::Road | |
| static void | setMeanVehicleLength (double meanVehicleLength) |
| Set the mean vehicle length, in meters (default is 5). | |
| static double | meanVehicleLength () |
| Get the mean vehicle length. | |
| static std::uint64_t | routingRevision () noexcept |
| Get the routing revision, shared by all roads. | |
Additional Inherited Members | |
| Protected Member Functions inherited from dsf::Edge | |
| void | m_setAngle (geometry::Point srcNodeCoordinates, geometry::Point dstNodeCoordinates) |
| Static Protected Member Functions inherited from dsf::mobility::Road | |
| static void | m_bumpRoutingRevision () noexcept |
| Record a change which affects routing (see routingRevision). | |
| Protected Attributes inherited from dsf::mobility::Road | |
| double | m_length |
| double | m_maxSpeed |
| int | m_nLanes |
| std::size_t | m_capacity |
| double | m_transportCapacity |
| std::string | m_name |
| bool | m_hasPriority = false |
| std::set< Id > | m_forbiddenTurns |
| std::uint8_t | m_mobilityClass = 0u |
| RoadStatus | m_roadStatus = RoadStatus::OPEN |
| Protected Attributes inherited from dsf::Edge | |
| geometry::PolyLine | m_geometry |
| Id | m_id |
| std::pair< Node *, Node * > | m_nodePair |
| Edge * | m_pReverse {nullptr} |
| double | m_angle |
| std::unordered_map< std::string, std::variant< std::monostate, bool, std::int64_t, double, std::string > > | m_attributes |
| Static Protected Attributes inherited from dsf::mobility::Road | |
| static double | m_meanVehicleLength = 5. |
| static std::atomic< std::uint64_t > | m_routingRevision {0} |
The Street class represents a street in the network.
| dsf::mobility::Street::Street | ( | Id | id, |
| std::pair< Node *, Node * > | nodePair, | ||
| double | length = Road::meanVehicleLength(), | ||
| double | maxSpeed = 13.8888888889, | ||
| int | nLanes = 1, | ||
| std::string | name = std::string(), | ||
| geometry::PolyLine | geometry = {}, | ||
| std::optional< int > | capacity = std::nullopt, | ||
| double | transportCapacity = 1. ) |
Construct a new Street object.
| id | The street's id |
| nodePair | The street's node pair |
| length | The street's length, in meters (default is the mean vehicle length) |
| nLanes | The street's number of lanes (default is 1) |
| maxSpeed | The street's speed limit, in m/s (default is 50 km/h) |
| name | The street's name (default is an empty string) |
| geometry | The street's geometry |
| capacity | The street's capacity (default is the maximum number of vehicles that can fit in the street) |
| transportCapacity | The street's transport capacity (default is 1) |
| void dsf::mobility::Street::addAgent | ( | std::unique_ptr< Agent > | pAgent, |
| std::time_t const | currentTime ) |
Add an agent to the street.
| pAgent | The agent to add to the street |
| currentTime | The current simulation time |
| void dsf::mobility::Street::changeNLanes | ( | int const | nLanes, |
| std::optional< double > const | speedFactor = std::nullopt ) |
Change the number of lanes of the street. Usually if there is a construction site, you may want to reduce the number of lanes and possibly the max speed.
| nLanes | The new number of lanes |
| speedFactor | Optional, The factor to multiply the max speed of the street |
|
inline |
Get the name of the counter.
|
inline |
Get the counts of the counter.
| std::unique_ptr< Agent > dsf::mobility::Street::dequeue | ( | std::size_t const & | index, |
| std::time_t const | currentTime ) |
Remove an agent from the street's queue.
Consumes one unit of the lane's exit gate (see Lane::flowAccumulator)
| index | The index of the queue |
| currentTime | The current simulation time |
| std::unique_ptr< Agent > dsf::mobility::Street::dequeueArrivedAgent | ( | std::time_t const | currentTime | ) |
Remove the top agent from the street's moving agents, which ends its trip at the end of the street, without queueing.
The agent travels the whole street and is recorded as leaving it (see dequeue), but it uses neither a queue nor the exit gate: a MIDDLE counter counts it, an EXIT one does not
| currentTime | The current simulation time |
| std::unique_ptr< Agent > dsf::mobility::Street::dequeueMovingAgent | ( | ) |
Remove the top agent from the street's moving agents priority queue.
| void dsf::mobility::Street::enableCounter | ( | std::string | name = std::string(), |
| CounterPosition | position = CounterPosition::EXIT ) |
Enable a coil (dsf::Counter sensor) on the street.
| name | The name of the counter (default is "Coil_<street_id>") |
| position | The position of the counter on the street (default is EXIT) |
| void dsf::mobility::Street::enqueue | ( | std::size_t const & | queueId | ) |
Add an agent to the street's queue.
| queueId | The id of the queue |
| std::runtime_error | If the street's queue is full |
|
inline |
Get this street estimated travel time using the active global estimator.
|
inlineconstexpr |
Check if the street has a coil (dsf::Counter sensor) on it.
|
inline |
Get a lane of the street.
| index | The index of the lane |
| std::vector< Direction > dsf::mobility::Street::laneMapping | ( | ) | const |
Get the street's lane mapping.
|
inlinenoexcept |
Get the street's lanes.
|
inline |
Get the mean speed of the agents that have passed through the street.
| Reset | If true, the average speed data is reset after the computation |
|
inline |
Get the street's moving agents priority queue.
|
inline |
Get the street's density of moving agents, i.e. excluding the queued ones.
| Normalized | If true, the density is normalized by the street's capacity |
|
finalvirtual |
Get the number of agents on the street.
Implements dsf::mobility::Road.
| double dsf::mobility::Street::nExitingAgents | ( | Direction | direction = Direction::ANY, |
| bool | normalizeOnNLanes = false ) const |
Get the number of agents on all queues for a given direction.
| direction | The direction of the agents (default is ANY) |
| normalizeOnNLanes | If true, the number of agents is normalized by the number of lanes |
| std::size_t dsf::mobility::Street::nMovingAgents | ( | ) | const |
Get the number of of moving agents, i.e. agents not yet enqueued.
|
inline |
Get the street's queue.
|
inlinenoexcept |
Bring the exit gate of a lane up to date with a time step.
The gate catches up on the time steps since its previous refill (see FlowAccumulator::refill()), so idle lanes need no refill
| index | The index of the lane |
| timeStep | The current time step |
| void dsf::mobility::Street::resetCounter | ( | ) |
Reset the counter of the street.
| std::runtime_error | If the street does not have a coil |
|
static |
Set the global street travel-time estimator.
| estimatedTravelTimeFunction | A callable with signature double(Street const&) |
| std::invalid_argument | If the function is empty |
| void dsf::mobility::Street::setLaneMapping | ( | std::vector< Direction > const & | laneMapping | ) |
Set the street's lane mapping.
| laneMapping | The street's lane mapping |
|
static |
Set the mean vehicle length.
| meanVehicleLength | The mean vehicle length |
| std::invalid_argument | If the mean vehicle length is negative |
| void dsf::mobility::Street::setQueue | ( | dsf::queue< std::unique_ptr< Agent > > | queue, |
| size_t | index ) |
Set the street's queue.
| queue | The street's queue |
| index | The index of the queue |
|
inlinenoexcept |
Get the street's source junction.
|
inlinenoexcept |
Get the street's target junction.