pytsc.backends.sumo package
Submodules
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo module
pytsc.backends.sumo.config module
- class pytsc.backends.sumo.config.Config(scenario, **kwargs)[source]
Bases:
pytsc.common.config.BaseConfig
Configuration class for SUMO simulator.
- Parameters
scenario (str) – Name of the scenario for which the configuration is being loaded.
**kwargs – Additional configuration parameters to override default values.
pytsc.backends.sumo.metrics module
- class pytsc.backends.sumo.metrics.MetricsParser(parsed_network, simulator, traffic_signals)[source]
Bases:
pytsc.common.metrics.BaseMetricsParser
Traffic signal network metrics parser for SUMO simulator.
- Parameters
parsed_network (ParsedNetwork) – Parsed network object.
simulator (SUMOSimulator) – SUMO simulator object.
traffic_signals (dict) – Dictionary of traffic signals.
- property average_travel_time
The average travel time of vehicles in the network.
- Returns
The average travel time of vehicles.
- Return type
float
- property average_wait_time
The average wait time of vehicles in the network.
- Returns
The average wait time of vehicles.
- Return type
float
- property density
The density of vehicles in the network.
- Returns
The density of vehicles.
- Return type
float
- property flickering_signal
The flickering signal is the average of the phase changed signals of all traffic signals in the network. It indicates how often the traffic signals are changing phases.
- Returns
The flickering signal.
- Return type
float
- get_step_stats()[source]
Get the statistics of the current simulation step.
- Returns
Dictionary containing the statistics of the current step.
- Return type
dict
- property mean_delay
The mean delay of vehicles in the network.
- Returns
The mean delay of vehicles.
- Return type
float
- property mean_speed
The mean speed of vehicles in the network.
- Returns
The mean speed of vehicles.
- Return type
float
- property n_emergency_brakes
The number of emergency brakes in the simulation.
- Returns
The number of emergency brakes.
- Return type
int
- property n_queued
The total number of queued vehicles in the network.
- Returns
The total number of queued vehicles.
- Return type
int
- property n_queued_norm
The normalized number of queued vehicles in the network.
- Returns
The normalized number of queued vehicles.
- Return type
float
- property n_teleported
The number of teleported vehicles in the simulation.
- Returns
The number of teleported vehicles.
- Return type
int
- property n_vehicles_exited
The number of vehicles that exited the simulation.
- Returns
The number of vehicles that exited the simulation.
- Return type
int
- property n_vehicles_inserted
The number of vehicles that were inserted into the simulation.
- Returns
The number of vehicles that were inserted into the simulation.
- Return type
int
- property norm_mean_speed
The normalized mean speed of vehicles in the network.
- Returns
The normalized mean speed of vehicles.
- Return type
float
- property pressure
The pressure of the traffic signals in the network.
- Returns
The pressure of the traffic signals.
- Return type
float
- property time_step
The time step of the simulation.
- Returns
The time step of the simulation.
- Return type
float
pytsc.backends.sumo.network_parser module
- class pytsc.backends.sumo.network_parser.NetworkParser(config)[source]
Bases:
pytsc.common.network_parser.BaseNetworkParser
Network parser for SUMO simulator.
- Parameters
config (Config) – Configuration object containing simulation parameters.
- property adjacency_matrix
The adjacency matrix is a square matrix used to represent a finite graph.
- Returns
The adjacency matrix representing the connections between traffic signals.
- Return type
np.ndarray
- property k_hop_neighbors
Returns a dictionary of k-hop neighbors for each traffic signal.
- Returns
A dictionary mapping traffic signal IDs to their k-hop neighbors.
- Return type
dict
- property lane_angles
The lane angles are the angles of each lane in the network.
- Returns
A dictionary mapping lane IDs to their angles in degrees.
- Return type
dict
- property lane_indices
The lane indices are the indices of each lane in the network.
- Returns
A dictionary mapping lane IDs to their indices.
- Return type
dict
- property lane_lengths
The lane lengths are the lengths of each lane in the network.
- Returns
A dictionary mapping lane IDs to their lengths.
- Return type
dict
- property lane_max_speeds
The lane maximum speeds are the maximum speeds of each lane in the network.
- Returns
A dictionary mapping lane IDs to their maximum speeds.
- Return type
dict
- property lanes
The lanes are the unique identifiers for each lane in the network.
- Returns
A list of lane IDs.
- Return type
list
- property network_boundary
The network boundary is the minimum and maximum coordinates of the network.
- Returns
A tuple containing the minimum and maximum coordinates of the network.
- Return type
tuple
- property norm_network_boundary
The normalized network boundary is the difference between the maximum and minimum coordinates of the network.
- Returns
A list containing the normalized width and height of the network.
- Return type
list
- plot_network(figsize=(12, 12))[source]
Plots the SUMO network with intersections and traffic signals.
- Parameters
figsize (tuple) – Size of the figure for plotting.
- property traffic_signal_ids
The traffic signal IDs are the unique identifiers for each traffic signal in the network.
- Returns
A list of traffic signal IDs.
- Return type
list
- property ts_coordinates
Returns the coordinates of the traffic signals in the network.
- Returns
A dictionary mapping traffic signal IDs to their coordinates.
- Return type
dict
- property ts_norm_coordinates
Returns the normalized coordinates of the traffic signals in the network.
- Returns
A dictionary mapping traffic signal IDs to their normalized coordinates.
- Return type
dict
- property ts_phase_to_inc_out_lanes
Returns a dictionary of incoming and outgoing lanes for each phase for each traffic signal.
- Returns
A dictionary mapping traffic signal IDs to their phases and the corresponding incoming and outgoing lanes.
- Return type
dict
pytsc.backends.sumo.retriever module
- class pytsc.backends.sumo.retriever.Retriever(simulator)[source]
Bases:
pytsc.common.retriever.BaseRetriever
Data retrieval class for the SUMO simulator.
- Parameters
simulator (SUMOSimulator) – SUMO simulator object.
- retrieve_lane_measurements()[source]
Retrieve lane measurements from the simulator.
- Returns
Dictionary containing lane measurements.
- Return type
dict
- retrieve_sim_measurements()[source]
Retrieve simulation measurements from the simulator.
- Returns
Dictionary containing simulation measurements.
- Return type
dict
- retrieve_ts_measurements()[source]
Retrieve traffic signal measurements from the simulator.
- Returns
Dictionary containing traffic signal measurements.
- Return type
dict
- tc = {'mean_speed': 17, 'n_arrived': 121, 'n_colliding': 128, 'n_departed': 115, 'n_emergency_brakes': 137, 'n_loaded': 113, 'n_queued': 20, 'n_teleported': 117, 'n_vehicles': 16, 'occupancy': 19, 'phase': 40, 'time_step': 102, 'travel_time': 90, 'vehicle_id': 18, 'wait_time': 122}
pytsc.backends.sumo.simulator module
- class pytsc.backends.sumo.simulator.Simulator(parsed_network)[source]
Bases:
pytsc.common.simulator.BaseSimulator
SUMO simulator class.
- Parameters
parsed_network (ParsedNetwork) – Parsed network object containing network information.
- property is_terminated
Check if the simulation is terminated.
- Returns
True if the simulation is terminated, False otherwise.
- Return type
bool
- retrieve_step_measurements()[source]
Retrieve step measurements from the simulator.
- Returns
Dictionary containing step measurements.
- Return type
dict
- property sim_step
Get the current simulation step.
- Returns
Current simulation step.
- Return type
int
- property sim_time
Get the current simulation time.
- Returns
Current simulation time.
- Return type
float
pytsc.backends.sumo.traffic_signal module
- class pytsc.backends.sumo.traffic_signal.TSController(id, config, simulator)[source]
Bases:
pytsc.common.traffic_signal.BaseTSController
Traffic signal controller for SUMO simulator.
- Parameters
id (str) – Traffic signal ID.
config (dict) – Configuration dictionary containing traffic signal parameters.
simulator (Simulator) – Simulator object containing simulation parameters and network information.
- class pytsc.backends.sumo.traffic_signal.TSProgram(id, config, simulator)[source]
Bases:
pytsc.common.traffic_signal.BaseTSProgram
Traffic signal program for SUMO simulator.
- Parameters
id (str) – Traffic signal ID.
config (dict) – Configuration dictionary containing traffic signal parameters.
simulator (Simulator) – Simulator object containing simulation parameters and network information.
- start_phase_index = 0
- class pytsc.backends.sumo.traffic_signal.TrafficSignal(id, config, simulator)[source]
Bases:
pytsc.common.traffic_signal.BaseTrafficSignal
Traffic signal class for SUMO simulator.
- Parameters
id (str) – Traffic signal ID.
config (dict) – Configuration dictionary containing traffic signal parameters.
simulator (Simulator) – Simulator object containing simulation parameters and network information.