SUMO simulator¶
- class routerl.environment.SumoSimulator(params: dict, path_gen_params: dict, seed: int = 23423, using_custom_demand: bool = False, save_detectors_info: bool = False, generate_asgn_data: bool = False, use_clustered_routes: bool = False, use_edge_subscriptions: bool = False)[source]
Sumo simulator class
A class responsible for managing the communication between our learning agents and the SUMO traffic simulator. SUMO provides the traffic environment where vehicles travel between designated origins and destinations, and it returns the corresponding travel times for these vehicles.
- Parameters:
params (dict) – Dictionary of parameters for the SUMO environment. Specified here.
path_gen_params (dict) –
Dictionary of parameters for the SUMO environment. specified here.
seed (int) – Random seed for reproducibility.
using_custom_demand (bool) – Flag to indicate whether user provides custom travel demand data.
generate_asgn_data (bool) – Generate additional SUMO_output files (per-timestep departures and snapshots).
use_clustered_routes (bool) – Flag to indicate whether to use an updated, clustered-routes-compatible version of JanuX for path generation.
use_edge_subscriptions (bool) – Subscribe to dynamic per-edge SUMO variables required by congestion observations.
- Variables:
network_name – Network name.
simulation_length – Simulation length.
sumo_id – SUMO connection id.
sumo_connection – Traci-SUMO connection object.
timestep – Time step being simulated within the day.
- add_vehicle(act_dict: dict) None[source]
Adds a vehicle to the SUMO simulation environment with the specified route and parameters.
- Parameters:
act_dict (dict) – A dictionary containing key vehicle attributes.
- Returns:
None
- refresh_edge_state() None[source]
Refresh subscribed edge state when required by the observation.
- reset() dict[source]
Resets the SUMO simulation to its initial state.
Reads detector data.
- Returns:
det_dict (dict[str, float]) – dictionary with detector data.
- retrieve_detector_data() None[source]
Return information about whether an a vehicle stopped in a detector.
- start() None[source]
Starts the SUMO simulation with the specified configuration.
- Returns:
None
- step() tuple[source]
Advances the SUMO simulation by one timestep and retrieves information about vehicle arrivals and detector data.
- Returns:
self.timestep (int) – The current simulation timestep.
arrivals (list) – List of vehicle IDs that arrived at their destinations during the current timestep.
- stop() None[source]
Stops and closes the SUMO simulation.
- Returns:
None