Dynamical system model
|
The Intersection class represents a node in the network. More...
#include <Node.hpp>
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 |
The Intersection class represents a node in the network.
Id | The type of the node's id. It must be an unsigned integral type. |
|
inlineexplicit |
Construct a new Intersection object.
id | The node's id |
|
inline |
Construct a new Intersection object.
id | The node's id |
coords | A std::pair containing the node's coordinates |
void dsm::Intersection::addAgent | ( | double | angle, |
Id | agentId ) |
Put an agent in the node.
agent | A 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.
std::runtime_error | if the node is full |
void dsm::Intersection::addAgent | ( | Id | agentId | ) |
Put an agent in the node.
agentId | The 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.
std::runtime_error | if the node is full |
|
inline |
Add a street to the node street priorities.
streetId | The street's id |
Size dsm::Intersection::agentCounter | ( | ) |
Returns 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.
|
inline |
Get the node's agent ids.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
|
inlinefinaloverridevirtualnoexcept |
Reimplemented from dsm::Node.
void dsm::Intersection::removeAgent | ( | Id | agentId | ) |
Removes an agent from the node.
agentId | The agent's id |
|
overridevirtual |
Set the node's capacity.
capacity | The node's capacity |
std::runtime_error | if the capacity is smaller than the current queue size |
Reimplemented from dsm::Node.
|
inline |
Set the node streets with priority.
streetPriorities | A std::set containing the node's street priorities |
|
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.