Dynamical system model
|
Public Member Functions | |
TrafficLight (Id id, Delay cycleTime) | |
Construct a new TrafficLight object. | |
TrafficLight (Id id, Delay cycleTime, std::pair< double, double > coords) | |
TrafficLight (Node const &node, Delay const cycleTime, Delay const counter=0) | |
TrafficLight & | operator++ () |
Delay | maxGreenTime (bool priorityStreets) const |
Get the maximum green time over every cycle. | |
Delay | minGreenTime (bool priorityStreets) const |
Get the minimum green time over every cycle. | |
double | meanGreenTime (bool priorityStreets) const |
Get the mean green time over every cycle. | |
Delay | cycleTime () const |
Get the traffic light's total cycle time. | |
void | setCycle (Id const streetId, Direction direction, TrafficLightCycle const &cycle) |
Set the cycle for a street and a direction. | |
void | setCycles (std::unordered_map< Id, std::vector< TrafficLightCycle > > cycles) |
Set the traffic light's cycles. | |
void | setComplementaryCycle (Id const streetId, Id const existingCycle) |
Set the complementary cycle for a street. | |
void | moveCycle (Id const oldStreetId, Id const newStreetId) |
Move a cycle from one street to another. | |
void | increaseGreenTimes (Delay const delta) |
Increase the green times of the traffic light for priority streets and decrease the green times for non-priority streets. | |
void | decreaseGreenTimes (Delay const delta) |
Decrease the green times of the traffic light for priority streets and increase the green times for non-priority streets. | |
std::unordered_map< Id, std::vector< TrafficLightCycle > > const & | cycles () const |
Get the traffic light's cycles. | |
bool | isDefault () const |
Returns true if all the cycles are set to their default values. | |
bool | isGreen (Id const streetId, Direction direction) const |
Returns true if the traffic light is green for a street and a direction. | |
bool | isFavouringDirection (bool const priority) const |
Returns true if the traffic light has green increased for all the cycles with priority. | |
void | resetCycles () |
Resets all traffic light cycles. | |
bool | isTrafficLight () const noexcept final |
![]() | |
Intersection (Id id) | |
Construct a new Intersection object. | |
Intersection (Id id, std::pair< double, double > coords) | |
Construct a new Intersection object. | |
Intersection (Node const &node) | |
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. | |
bool | isIntersection () const noexcept final |
![]() | |
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. | |
Node (Node const &other) | |
Node & | operator= (Node const &other) |
void | setId (Id id) |
Set the node's id. | |
void | setCoords (std::pair< double, double > coords) |
Set the node's coordinates. | |
void | setName (const std::string &name) |
Set the node's name. | |
virtual void | setTransportCapacity (int 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. | |
const std::string & | name () const |
Get the node's name. | |
Size | capacity () const |
Get the node's capacity. | |
int | transportCapacity () const |
Get the node's transport capacity. | |
virtual bool | isRoundabout () const noexcept |
virtual bool | isStation () const noexcept |
Additional Inherited Members | |
![]() | |
std::multimap< int16_t, Id > | m_agents |
std::set< Id > | m_streetPriorities |
Size | m_agentCounter |
![]() | |
Id | m_id |
std::optional< std::pair< double, double > > | m_coords |
std::string | m_name |
Size | m_capacity |
int | m_transportCapacity |
|
inline |
Construct a new TrafficLight object.
id | The node's id |
cycleTime | The node's cycle time |
|
inline |
Get the traffic light's cycles.
|
inline |
Get the traffic light's total cycle time.
void dsm::TrafficLight::decreaseGreenTimes | ( | Delay const | delta | ) |
Decrease the green times of the traffic light for priority streets and increase the green times for non-priority streets.
delta | Delay, the time to increase or decrease the green times |
void dsm::TrafficLight::increaseGreenTimes | ( | Delay const | delta | ) |
Increase the green times of the traffic light for priority streets and decrease the green times for non-priority streets.
delta | Delay, the time to increase or decrease the green times |
bool dsm::TrafficLight::isFavouringDirection | ( | bool const | priority | ) | const |
Returns true if the traffic light has green increased for all the cycles with priority.
priority | bool, if true, only the priority streets are considered; else, only the non-priority streets are considered |
bool dsm::TrafficLight::isGreen | ( | Id const | streetId, |
Direction | direction ) const |
Returns true if the traffic light is green for a street and a direction.
streetId | Id, the street's id |
direction | Direction, the direction |
|
inlinefinalvirtualnoexcept |
Reimplemented from dsm::Node.
Delay dsm::TrafficLight::maxGreenTime | ( | bool | priorityStreets | ) | const |
Get the maximum green time over every cycle.
priorityStreets | bool, if true, only the priority streets are considered; if false, only the non-priority streets are considered |
The maximum green time is the maximum green time of all the cycles for the priority streets if priorityStreets is true, or for the non-priority streets if priorityStreets is false.
double dsm::TrafficLight::meanGreenTime | ( | bool | priorityStreets | ) | const |
Get the mean green time over every cycle.
priorityStreets | bool, if true, only the priority streets are considered; if false, only the non-priority streets are considered |
The mean green time is the mean green time of all the cycles for the priority streets if priorityStreets is true, or for the non-priority streets if priorityStreets is false.
Delay dsm::TrafficLight::minGreenTime | ( | bool | priorityStreets | ) | const |
Get the minimum green time over every cycle.
priorityStreets | bool, if true, only the priority streets are considered; if false, only the non-priority streets are considered |
The minimum green time is the minimum green time of all the cycles for the priority streets if priorityStreets is true, or for the non-priority streets if priorityStreets is false.
void dsm::TrafficLight::moveCycle | ( | Id const | oldStreetId, |
Id const | newStreetId ) |
Move a cycle from one street to another.
oldStreetId | Id, the old street id |
newStreetId | Id, the new street id |
void dsm::TrafficLight::resetCycles | ( | ) |
Resets all traffic light cycles.
For more info, see TrafficLightCycle::reset()
void dsm::TrafficLight::setComplementaryCycle | ( | Id const | streetId, |
Id const | existingCycle ) |
Set the complementary cycle for a street.
streetId | Id, The street's id |
existingCycle | Id, The street's id associated with the existing cycle |
std::invalid_argument | if the street id does not exist |
std::invalid_argument | if the cycle does not exist |
The complementary cycle is a cycle that has as green time the total cycle time minus the green time of the existing cycle. The phase is the total cycle time minus the green time of the existing cycle, plus the phase of the existing cycle.
void dsm::TrafficLight::setCycle | ( | Id const | streetId, |
Direction | direction, | ||
TrafficLightCycle const & | cycle ) |
Set the cycle for a street and a direction.
streetId | The street's id |
direction | The direction |
cycle | The traffic light cycle |
|
inline |
Set the traffic light's cycles.
cycles | std::unordered_map<Id, std::vector<TrafficLightCycle>> The traffic light's cycles |