LovelyBuggies / sumo-gym

OpenAI-gym like toolkit for developing and comparing reinforcement learning algorithms on SUMO.
Other
30 stars 7 forks source link

simple simulation and make-fmpenv-xml #31

Closed qqqube closed 2 years ago

wyunhao commented 2 years ago

Please also help to extract the edge length from the xml file, and make it an attribute in the edge_dict.

Actually, since the dictionaries we made for vertices or edges are like: {0:"a", "1": "b", ... }, of which the key will always be indices, we can just do a list. So we have self.vertex_attr = ['genJ0', 'gneJ1', ...], and self.edge_attr = [('gneE0', 23.42), ('gneE1', 22.60)] (each element a tuple if edgeId and length).

LovelyBuggies commented 2 years ago

And generally, could you please move the logic of converting raw_variables to variables to fmp_uitls.py using the helper function? We don't expect they appear in fmpenv init, because it should be as succinct as possible for the algorithm team's convenience.

(
                raw_vertices,  # [id (str), x_coord (float), y_coord (float)]
                raw_charging_stations, # [id, (x_coord, y_coord), edge_id, charging speed]
                raw_electric_vehicles, # [id (str), maximum speed (float), maximumBatteryCapacity (float)]
                raw_edges,  # [id (str), from_vertex_id (str), to_vertex_id (str)]
                raw_departures,  # [vehicle_id, starting_edge_id]
                raw_demand,  # [junction_id, dest_vertex_id]
            ) = sumo_gym.utils.xml_utils.decode_xml_fmp(
                net_xml_file_path, demand_xml_file_path,
                additional_xml_file_path
            )
# A convert function here
self.vertices, self.demand, self.edges, self.electric_vehicles, self.departures, self.charging_stations = convert_raw(raw_vertices, raw_charging_stations, raw_electric_vehicles, raw_edges,  raw_departures,  raw_demand).