Dynamical system model
Loading...
Searching...
No Matches
dsm::Intersection Class Reference

The Intersection class represents a node in the network. More...

#include <Node.hpp>

Inheritance diagram for dsm::Intersection:
dsm::Node dsm::TrafficLight< Delay >

Public Member Functions

 Intersection (Id id)
 Construct a new Intersection object.
 
 Intersection (Id id, std::pair< double, double > coords)
 Construct a new Intersection object.
 
void setCapacity (Size capacity) override
 Set the node's capacity.
 
void addAgent (double angle, Id agentId)
 Put an agent in the node.
 
void addAgent (Id agentId)
 Put an agent in the node.
 
void removeAgent (Id agentId)
 Removes an agent from the node.
 
void setStreetPriorities (std::set< Id > streetPriorities)
 Set the node streets with priority.
 
void addStreetPriority (Id streetId)
 Add a street to the node street priorities.
 
double density () const override
 Returns the node's density.
 
bool isFull () const override
 Returns true if the node is full.
 
virtual const std::set< Id > & streetPriorities () const
 Get the node's street priorities.
 
const std::multimap< int16_t, Id > & agents ()
 Get the node's agent ids.
 
Size agentCounter ()
 Returns the number of agents that have passed through the node.
 
virtual bool isIntersection () const noexcept override final
 
- Public Member Functions inherited from dsm::Node
 Node (Id id)
 Construct a new Node object with capacity 1.
 
 Node (Id id, std::pair< double, double > coords)
 Construct a new Node object with capacity 1.
 
void setId (Id id)
 Set the node's id.
 
void setCoords (std::pair< double, double > coords)
 Set the node's coordinates.
 
virtual void setTransportCapacity (Size capacity)
 Set the node's transport capacity.
 
Id id () const
 Get the node's id.
 
const std::optional< std::pair< double, double > > & coords () const
 Get the node's coordinates.
 
Size capacity () const
 Get the node's capacity.
 
Size transportCapacity () const
 Get the node's transport capacity.
 
virtual bool isTrafficLight () const noexcept
 
virtual bool isRoundabout () const noexcept
 

Protected Attributes

std::multimap< int16_t, Id > m_agents
 
std::set< Id > m_streetPriorities
 
Size m_agentCounter
 
- Protected Attributes inherited from dsm::Node
Id m_id
 
std::optional< std::pair< double, double > > m_coords
 
Size m_capacity
 
Size m_transportCapacity
 

Detailed Description

The Intersection class represents a node in the network.

Template Parameters
IdThe type of the node's id. It must be an unsigned integral type.

Constructor & Destructor Documentation

◆ Intersection() [1/2]

dsm::Intersection::Intersection ( Id id)
inlineexplicit

Construct a new Intersection object.

Parameters
idThe node's id

◆ Intersection() [2/2]

dsm::Intersection::Intersection ( Id id,
std::pair< double, double > coords )
inline

Construct a new Intersection object.

Parameters
idThe node's id
coordsA std::pair containing the node's coordinates

Member Function Documentation

◆ addAgent() [1/2]

void dsm::Intersection::addAgent ( double angle,
Id agentId )

Put an agent in the node.

Parameters
agentA std::pair containing the agent's angle difference and id

The agent's angle difference is used to order the agents in the node. The agent with the smallest angle difference is the first one to be removed from the node.

Exceptions
std::runtime_errorif the node is full

◆ addAgent() [2/2]

void dsm::Intersection::addAgent ( Id agentId)

Put an agent in the node.

Parameters
agentIdThe agent's id

The agent's angle difference is used to order the agents in the node. The agent with the smallest angle difference is the first one to be removed from the node.

Exceptions
std::runtime_errorif the node is full

◆ addStreetPriority()

void dsm::Intersection::addStreetPriority ( Id streetId)
inline

Add a street to the node street priorities.

Parameters
streetIdThe street's id

◆ agentCounter()

Size dsm::Intersection::agentCounter ( )

Returns the number of agents that have passed through the node.

Returns
Size The number of agents that have passed through the node

This function returns the number of agents that have passed through the node since the last time this function was called. It also resets the counter.

◆ agents()

const std::multimap< int16_t, Id > & dsm::Intersection::agents ( )
inline

Get the node's agent ids.

Returns
std::set<Id> A std::set containing the node's agent ids

◆ density()

double dsm::Intersection::density ( ) const
inlineoverridevirtual

Returns the node's density.

Returns
double The node's density

Implements dsm::Node.

◆ isFull()

bool dsm::Intersection::isFull ( ) const
inlineoverridevirtual

Returns true if the node is full.

Returns
bool True if the node is full

Implements dsm::Node.

◆ isIntersection()

virtual bool dsm::Intersection::isIntersection ( ) const
inlinefinaloverridevirtualnoexcept

Reimplemented from dsm::Node.

◆ removeAgent()

void dsm::Intersection::removeAgent ( Id agentId)

Removes an agent from the node.

Parameters
agentIdThe agent's id

◆ setCapacity()

void dsm::Intersection::setCapacity ( Size capacity)
overridevirtual

Set the node's capacity.

Parameters
capacityThe node's capacity
Exceptions
std::runtime_errorif the capacity is smaller than the current queue size

Reimplemented from dsm::Node.

◆ setStreetPriorities()

void dsm::Intersection::setStreetPriorities ( std::set< Id > streetPriorities)
inline

Set the node streets with priority.

Parameters
streetPrioritiesA std::set containing the node's street priorities

◆ streetPriorities()

virtual const std::set< Id > & dsm::Intersection::streetPriorities ( ) const
inlinevirtual

Get the node's street priorities.

This function returns a std::set containing the node's street priorities. If a street has priority, it means that the agents that are on that street have priority over the agents that are on the other streets.

Returns
std::set<Id> A std::set containing the node's street priorities

The documentation for this class was generated from the following files: