uxsim.Node

class uxsim.Node(W, name, x, y, signal=[0], signal_offset=0, flow_capacity=None, auto_rename=False, number_of_lanes=None, attribute=None, user_attribute=None, user_function=None)[source]

Node in a network.

Create a node

Parameters:
  • W (object) – The world to which the node belongs.

  • name (str) – The name of the node.

  • x (float) – The x-coordinate of the node (for visualization purposes).

  • y (float) – The y-coordinate of the node (for visualization purposes).

  • signal (list of int, optional) – A list representing the signal at the node. Default is [0], representing no signal. If a signal is present, the list contains the green times for each group. For example, `signal`=[60, 10, 50, 5] means that this signal has 4 phases, and green time for the 1st group is 60 s.

  • signal_offset (float, optional) – The offset of the signal. Default is 0.

  • flow_capacity (float, optional) – The maximum flow capacity of the node. Default is None, meaning infinite capacity.

  • auto_rename (bool, optional) – Whether to automatically rename the node if the name is already used. Default is False.

  • number_of_lanes (int, optional) – The number of lanes that can be green simultaniously at the node. Default is None.

  • attribute (any, optional) – Additional (meta) attributes defined by users.

  • user_attribute (any, optional) – Additional (meta) attributes defined by users. Same functionality to attribute, but with more understandable name.

  • user_function (func, optinal) – User-defined custom function that is automatically called when timestep is incremented (more precisely, when update() is called). It takes only one argument: the Node object itself. Example: The following code prints the current number of incoming vehicles to the node at each timestep. If user_function=None (default), no functions will be executed. >>> def user_function(node): >>> print(len(node.incoming_vehicles)) >>> W = World(…) >>> W.addNode(“node”, 0, 0, user_function=user_function) >>> … #define your scenario >>> W.exec_simulation()

signal_phase

The phase of current signal. Links that have the same signal_group have a green signal.

Type:

int

signal_t

The elapsed time since the current signal phase started. When it is larger than Link.signal[Link.signal_phase], the phase changes to the next one.

Type:

float

__init__(W, name, x, y, signal=[0], signal_offset=0, flow_capacity=None, auto_rename=False, number_of_lanes=None, attribute=None, user_attribute=None, user_function=None)[source]

Create a node

Parameters:
  • W (object) – The world to which the node belongs.

  • name (str) – The name of the node.

  • x (float) – The x-coordinate of the node (for visualization purposes).

  • y (float) – The y-coordinate of the node (for visualization purposes).

  • signal (list of int, optional) – A list representing the signal at the node. Default is [0], representing no signal. If a signal is present, the list contains the green times for each group. For example, `signal`=[60, 10, 50, 5] means that this signal has 4 phases, and green time for the 1st group is 60 s.

  • signal_offset (float, optional) – The offset of the signal. Default is 0.

  • flow_capacity (float, optional) – The maximum flow capacity of the node. Default is None, meaning infinite capacity.

  • auto_rename (bool, optional) – Whether to automatically rename the node if the name is already used. Default is False.

  • number_of_lanes (int, optional) – The number of lanes that can be green simultaniously at the node. Default is None.

  • attribute (any, optional) – Additional (meta) attributes defined by users.

  • user_attribute (any, optional) – Additional (meta) attributes defined by users. Same functionality to attribute, but with more understandable name.

  • user_function (func, optinal) – User-defined custom function that is automatically called when timestep is incremented (more precisely, when update() is called). It takes only one argument: the Node object itself. Example: The following code prints the current number of incoming vehicles to the node at each timestep. If user_function=None (default), no functions will be executed. >>> def user_function(node): >>> print(len(node.incoming_vehicles)) >>> W = World(…) >>> W.addNode(“node”, 0, 0, user_function=user_function) >>> … #define your scenario >>> W.exec_simulation()

signal_phase

The phase of current signal. Links that have the same signal_group have a green signal.

Type:

int

signal_t

The elapsed time since the current signal phase started. When it is larger than Link.signal[Link.signal_phase], the phase changes to the next one.

Type:

float

Methods

__init__(W, name, x, y[, signal, ...])

Create a node

flow_capacity_update()

flow capacity updates.

generate()

Departs vehicles from the waiting queue.

signal_control()

Updates the signal timings for a traffic signal node.

transfer()

Transfers vehicles between links at the node.

update()

Make necessary updates when the timestep is incremented.

flow_capacity_update()[source]

flow capacity updates.

generate()[source]

Departs vehicles from the waiting queue.

Notes

If there are vehicles in the generation queue of the node, this method attempts to depart a vehicle to one of the outgoing links. The choice of the outgoing link is based on the vehicle’s route preference for each link. Once a vehicle is departed, it is removed from the generation queue, added to the list of vehicles on the chosen link, and its state is set to “run”.

signal_control()[source]

Updates the signal timings for a traffic signal node.

transfer()[source]

Transfers vehicles between links at the node.

Notes

This method handles the transfer of vehicles from one link to another at the node. A vehicle is eligible for transfer if: - The next link it intends to move to has space. - The vehicle has the right signal phase to proceed. - The current link has enough capacity to allow the vehicle to exit. - The node capacity is not exceeded.

update()[source]

Make necessary updates when the timestep is incremented.