Dynamical system model
Loading...
Searching...
No Matches
dsf::mobility::Street Class Reference

The Street class represents a street in the network. More...

#include <Street.hpp>

Inheritance diagram for dsf::mobility::Street:
dsf::mobility::Road dsf::Edge

Public Member Functions

 Street (Id id, std::pair< Id, Id > 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
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.
void setStationaryWeight (double const weight)
 Set the street's stationary weight.
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.
const dsf::queue< std::unique_ptr< Agent > > & queue (size_t const &index) const
 Get the street's queue.
std::vector< dsf::queue< std::unique_ptr< Agent > > > const & exitQueues () const
 Get the street's queues.
std::size_t nAgents () const final
 Get the number of agents on the street.
auto stationaryWeight () const noexcept
 Get the street's stationary weight.
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.
std::size_t nMovingAgents () const
 Get the number of of moving agents, i.e. agents not yet enqueued.
double nExitingAgents (Direction direction=Direction::ANY, bool normalizeOnNLanes=false) const
 Get the number of agents on all queues for a given direction.
Measurement< double > meanSpeed (bool const bReset=true)
 Get the mean speed of the agents that have passed through the street.
auto const & 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.
void enqueue (std::size_t const &queueId)
 Add an agent to the street's queue.
std::unique_ptr< Agentdequeue (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< Id, Id > 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.
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 setRoadType (RoadType const roadType)
 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.
double density (bool normalized=false) 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.
auto transportCapacity () const noexcept
 Get the road's transport capacity, in number of agents.
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 roadType () const noexcept
 Get the road type.
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< Id, Id > 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 setBetweennessCentrality (double const betweennessCentrality)
 Set the edge's betweenness centrality.
void setWeight (double const weight)
 Set the edge's weight.
auto id () const
 Get the edge's id.
auto source () const
 Get the edge's source node id.
auto target () const
 Get the edge's target node id.
auto const & nodePair () const
 Get the edge's node pair.
auto const & geometry () const
 Get the edge's geometry.
auto const & betweennessCentrality () const
 Get the edge's betweenness centrality.
auto angle () const
 Get the edge's angle, in radians, between the source and target nodes.
double weight () const
 Get the edge's weight.
double deltaAngle (double const previousEdgeAngle) const

Static Public Member Functions

static void setMeanVehicleLength (double meanVehicleLength)
 Set the mean vehicle length.
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.

Additional Inherited Members

Protected Member Functions inherited from dsf::Edge
void m_setAngle (geometry::Point srcNodeCoordinates, geometry::Point dstNodeCoordinates)
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::optional< RoadType > m_roadType {std::nullopt}
RoadStatus m_roadStatus = RoadStatus::OPEN
Protected Attributes inherited from dsf::Edge
geometry::PolyLine m_geometry
Id m_id
std::pair< Id, Id > m_nodePair
std::optional< double > m_betweennessCentrality {std::nullopt}
std::optional< double > m_weight {std::nullopt}
double m_angle
Static Protected Attributes inherited from dsf::mobility::Road
static double m_meanVehicleLength = 5.

Detailed Description

The Street class represents a street in the network.

Constructor & Destructor Documentation

◆ Street()

dsf::mobility::Street::Street ( Id id,
std::pair< Id, Id > 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.

Parameters
idThe street's id
nodePairThe street's node pair
lengthThe street's length, in meters (default is the mean vehicle length)
nLanesThe street's number of lanes (default is 1)
maxSpeedThe street's speed limit, in m/s (default is 50 km/h)
nameThe street's name (default is an empty string)
geometryThe street's geometry
capacityThe street's capacity (default is the maximum number of vehicles that can fit in the street)
transportCapacityThe street's transport capacity (default is 1)

Member Function Documentation

◆ addAgent()

void dsf::mobility::Street::addAgent ( std::unique_ptr< Agent > pAgent,
std::time_t const currentTime )

Add an agent to the street.

Parameters
pAgentThe agent to add to the street
currentTimeThe current simulation time

◆ changeNLanes()

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.

Parameters
nLanesThe new number of lanes
speedFactorOptional, The factor to multiply the max speed of the street

◆ counterName()

auto dsf::mobility::Street::counterName ( ) const
inline

Get the name of the counter.

Returns
std::string The name of the counter

◆ counts()

auto dsf::mobility::Street::counts ( ) const
inline

Get the counts of the counter.

Returns
std::size_t The counts of the counter

◆ dequeue()

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.

Parameters
indexThe index of the queue
currentTimeThe current simulation time
Returns
Id The id of the agent removed from the street's queue

◆ enableCounter()

void dsf::mobility::Street::enableCounter ( std::string name = std::string(),
CounterPosition position = CounterPosition::EXIT )

Enable a coil (dsf::Counter sensor) on the street.

Parameters
nameThe name of the counter (default is "Coil_<street_id>")
positionThe position of the counter on the street (default is EXIT)

◆ enqueue()

void dsf::mobility::Street::enqueue ( std::size_t const & queueId)

Add an agent to the street's queue.

Parameters
queueIdThe id of the queue
Exceptions
std::runtime_errorIf the street's queue is full

◆ exitQueues()

std::vector< dsf::queue< std::unique_ptr< Agent > > > const & dsf::mobility::Street::exitQueues ( ) const
inline

Get the street's queues.

Returns
std::vector<dsf::queue<Size>> The street's queues

◆ hasCoil()

bool dsf::mobility::Street::hasCoil ( ) const
inlineconstexpr

Check if the street has a coil (dsf::Counter sensor) on it.

Returns
bool True if the street has a coil, false otherwise

◆ laneMapping()

auto const & dsf::mobility::Street::laneMapping ( ) const
inline

Get the street's lane mapping.

Returns
std::vector<Direction> The street's lane mapping

◆ meanSpeed()

Measurement< double > dsf::mobility::Street::meanSpeed ( bool const bReset = true)

Get the mean speed of the agents that have passed through the street.

Parameters
bResetIf true, the average speed data is reset after the computation
Returns
Measurement<double> The (mean, std) speed of the agents that have passed through the street

◆ movingAgents()

dsf::priority_queue< std::unique_ptr< Agent >, std::vector< std::unique_ptr< Agent > >, AgentComparator > & dsf::mobility::Street::movingAgents ( )
inline

Get the street's moving agents priority queue.

Returns
dsf::priority_queue<std::unique_ptr<Agent>, std::vector<std::unique_ptr<Agent>>, AgentComparator>& The street's moving agents priority queue

◆ nAgents()

std::size_t dsf::mobility::Street::nAgents ( ) const
finalvirtual

Get the number of agents on the street.

Returns
std::size_t, The number of agents on the street

Implements dsf::mobility::Road.

◆ nExitingAgents()

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.

Parameters
directionThe direction of the agents (default is ANY)
normalizeOnNLanesIf true, the number of agents is normalized by the number of lanes
Returns
double The number of agents on all queues for a given direction

◆ nMovingAgents()

std::size_t dsf::mobility::Street::nMovingAgents ( ) const

Get the number of of moving agents, i.e. agents not yet enqueued.

Returns
std::size_t The number of moving agents

◆ queue()

const dsf::queue< std::unique_ptr< Agent > > & dsf::mobility::Street::queue ( size_t const & index) const
inline

Get the street's queue.

Returns
dsf::queue<Size>, The street's queue

◆ resetCounter()

void dsf::mobility::Street::resetCounter ( )

Reset the counter of the street.

Exceptions
std::runtime_errorIf the street does not have a coil

◆ setLaneMapping()

void dsf::mobility::Street::setLaneMapping ( std::vector< Direction > const & laneMapping)

Set the street's lane mapping.

Parameters
laneMappingThe street's lane mapping

◆ setMeanVehicleLength()

void dsf::mobility::Street::setMeanVehicleLength ( double meanVehicleLength)
static

Set the mean vehicle length.

Parameters
meanVehicleLengthThe mean vehicle length
Exceptions
std::invalid_argumentIf the mean vehicle length is negative

◆ setQueue()

void dsf::mobility::Street::setQueue ( dsf::queue< std::unique_ptr< Agent > > queue,
size_t index )

Set the street's queue.

Parameters
queueThe street's queue
indexThe index of the queue

◆ setStationaryWeight()

void dsf::mobility::Street::setStationaryWeight ( double const weight)
inline

Set the street's stationary weight.

Parameters
weightThe street's stationary weight

◆ stationaryWeight()

auto dsf::mobility::Street::stationaryWeight ( ) const
inlinenoexcept

Get the street's stationary weight.

Returns
double The street's stationary weight

The documentation for this class was generated from the following files:
  • src/dsf/mobility/Street.hpp
  • src/dsf/mobility/Street.cpp