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 dsf::mobility::StochasticStreet

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 enableCounter (std::string name=std::string())
 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.
 
int nAgents () const final
 Get the number of agents on the street.
 
double density (bool normalized=false) const final
 Get the street's density in \(m^{-1}\) or in \(a.u.\), if normalized.
 
bool isFull () const final
 Check if the street is full.
 
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.
 
int nMovingAgents () const override
 Get the number of of moving agents, i.e. agents not yet enqueued.
 
double nExitingAgents (Direction direction=Direction::ANY, bool normalizeOnNLanes=false) const final
 Get the number of agents on all queues for a given direction.
 
std::vector< Direction > const & laneMapping () const
 Get the street's lane mapping.
 
virtual void addAgent (std::unique_ptr< Agent > pAgent)
 Add an agent to the street.
 
void enqueue (size_t const &queueId)
 Add an agent to the street's queue.
 
virtual std::unique_ptr< Agentdequeue (size_t index)
 Remove an agent from the street's queue.
 
constexpr bool hasCoil () const
 Check if the street has a coil (dsf::Counter sensor) on it.
 
virtual constexpr bool isStochastic () const noexcept
 Check if the street is stochastic.
 
- 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 (int priority)
 Set the road's priority.
 
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.
 
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.
 
auto transportCapacity () const noexcept
 Get the road's transport capacity, in number of agents.
 
auto const & name () const noexcept
 Get the name.
 
auto priority () const noexcept
 Get the priority.
 
auto const & forbiddenTurns () const noexcept
 Get the road's forbidden turns.
 
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 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 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
 
int m_capacity
 
double m_transportCapacity
 
std::string m_name
 
int m_priority
 
std::set< Id > m_forbiddenTurns
 
- Protected Attributes inherited from dsf::Edge
geometry::PolyLine m_geometry
 
Id m_id
 
std::pair< Id, Id > m_nodePair
 
std::optional< double > m_weight
 
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)
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)
virtual

Add an agent to the street.

Parameters
pAgentThe agent to add to 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

◆ density()

double dsf::mobility::Street::density ( bool normalized = false) const
finalvirtual

Get the street's density in \(m^{-1}\) or in \(a.u.\), if normalized.

Parameters
normalizedIf true, the street's density is normalized by the street's capacity
Returns
double, The street's density

Implements dsf::mobility::Road.

◆ dequeue()

std::unique_ptr< Agent > dsf::mobility::Street::dequeue ( size_t index)
virtual

Remove an agent from the street's queue.

Returns
Id The id of the agent removed from the street's queue

◆ enableCounter()

void dsf::mobility::Street::enableCounter ( std::string name = std::string())

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

Parameters
nameThe name of the counter (default is "Coil_<street_id>")

◆ enqueue()

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

Add an agent to the street's queue.

Parameters
agentIdThe id of the agent to add to the street's 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

◆ isFull()

bool dsf::mobility::Street::isFull ( ) const
inlinefinalvirtual

Check if the street is full.

Returns
bool, True if the street is full, false otherwise

Implements dsf::Edge.

◆ isStochastic()

virtual constexpr bool dsf::mobility::Street::isStochastic ( ) const
inlineconstexprvirtualnoexcept

Check if the street is stochastic.

Returns
bool True if the street is stochastic, false otherwise

Reimplemented in dsf::mobility::StochasticStreet.

◆ laneMapping()

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

Get the street's lane mapping.

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

◆ 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()

int dsf::mobility::Street::nAgents ( ) const
finalvirtual

Get the number of agents on the street.

Returns
Size, 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
finalvirtual

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

Implements dsf::mobility::Road.

◆ nMovingAgents()

int dsf::mobility::Street::nMovingAgents ( ) const
overridevirtual

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

Returns
int The number of moving agents

Implements dsf::mobility::Road.

◆ 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()

static 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

◆ 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: