Dynamical system model
|
Public Member Functions | |
TrafficLight (Id id) | |
Construct a new TrafficLight object. | |
TrafficLight (const Node &node) | |
Construct a new TrafficLight object. | |
void | setDelay (Delay delay) |
Set the node's delay. | |
void | setDelay (std::pair< Delay, Delay > delay) |
Set the node's delay. | |
void | setPhase (Delay phase) |
Set the node's phase. | |
void | setLeftTurnRatio (std::pair< double, double > ratio) |
Set the node's left turn ratio. | |
void | setLeftTurnRatio (double const first, double const second) |
Set the node's left turn ratio. | |
void | setLeftTurnRatio (double const ratio) |
Set the node's left turn ratio as std::pair(ratio, ratio) | |
void | increaseCounter () |
Increase the node's counter. | |
void | setPhaseAfterCycle (Delay phase) |
Set the phase of the node after the current red-green cycle has passed. | |
std::optional< std::pair< Delay, Delay > > | delay () const |
Get the node's delay. | |
Delay | counter () const |
std::optional< std::pair< double, double > > | leftTurnRatio () const |
Get the node's left turn ratio. | |
bool | isGreen () const |
Returns true if the traffic light is green. | |
bool | isGreen (Id streetId) const |
bool | isTrafficLight () const noexcept override |
Public Member Functions inherited from dsm::Intersection | |
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 | isRoundabout () const noexcept |
Additional Inherited Members | |
Protected Attributes inherited from dsm::Intersection | |
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 |
|
inlineexplicit |
Construct a new TrafficLight object.
id | The node's id |
dsm::TrafficLight< Delay >::TrafficLight | ( | const Node & | node | ) |
Construct a new TrafficLight object.
node | An Intersection object |
|
inline |
Get the node's delay.
void dsm::TrafficLight< Delay >::increaseCounter | ( | ) |
Increase the node's counter.
This function is used to increase the node's counter when the simulation is running. It automatically resets the counter when it reaches the double of the delay value.
std::runtime_error | if the delay is not set |
bool dsm::TrafficLight< Delay >::isGreen | ( | ) | const |
Returns true if the traffic light is green.
|
inlineoverridevirtualnoexcept |
Reimplemented from dsm::Node.
|
inline |
Get the node's left turn ratio.
void dsm::TrafficLight< Delay >::setDelay | ( | Delay | delay | ) |
Set the node's delay.
This function is used to set the node's delay. If the delay is already set, the function will check the counter:
delay | The node's delay |
void dsm::TrafficLight< Delay >::setDelay | ( | std::pair< Delay, Delay > | delay | ) |
Set the node's delay.
This function is used to set the node's delay. If the delay is already set, the function will check the counter:
delay | The node's delay |
|
inline |
Set the node's left turn ratio.
first | The first component of the left turn ratio |
second | The second component of the left turn ratio |
|
inline |
Set the node's left turn ratio as std::pair(ratio, ratio)
ratio | The left turn ratio |
void dsm::TrafficLight< Delay >::setLeftTurnRatio | ( | std::pair< double, double > | ratio | ) |
Set the node's left turn ratio.
ratio | A std::pair containing the left turn ratio |
ratio.first * greentime is the green time for left turns while ratio.second * redtime is the red time for left turns This is useful for traffic lights when the input street has many lanes and, for example, one resevred for left turns.
void dsm::TrafficLight< Delay >::setPhase | ( | Delay | phase | ) |
Set the node's phase.
phase | The node's phase |
std::runtime_error | if the delay is not set |
void dsm::TrafficLight< Delay >::setPhaseAfterCycle | ( | Delay | phase | ) |
Set the phase of the node after the current red-green cycle has passed.
phase | The new node phase |