From c07748f3402c0ec84d1c342fae4043dd458a875a Mon Sep 17 00:00:00 2001 From: Ahp06 Date: Fri, 7 Dec 2018 16:46:54 +0100 Subject: [PATCH] Added info logs --- sumo_project/actions.py | 2 -- sumo_project/config.py | 8 ++++---- sumo_project/emissions.py | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sumo_project/actions.py b/sumo_project/actions.py index 1758d6c..8efdd61 100644 --- a/sumo_project/actions.py +++ b/sumo_project/actions.py @@ -51,11 +51,9 @@ def adjust_traffic_light_phase_duration(area, reduction_factor): traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, modifyLogic(logic,reduction_factor)) def count_vehicles_in_area(area): - #Trying to lock area vehicles_in_area = 0 for lane in area._lanes: vehicles_in_area += traci.lane.getLastStepVehicleNumber(lane.lane_id) - return vehicles_in_area def lock_area(area): diff --git a/sumo_project/config.py b/sumo_project/config.py index 1fc819b..25ff6fd 100644 --- a/sumo_project/config.py +++ b/sumo_project/config.py @@ -26,7 +26,7 @@ sumo_cmd = [sumo_binary, "-c", _SUMOCFG] ############################################################################### now = datetime.datetime.now() -current_date = now.strftime("%Y_%m_%d_%H_%M") +current_date = now.strftime("%Y_%m_%d_%H_%M_%S") LOG_FILENAME = f'sumo_logs_{current_date}.log' ############################################################################### @@ -43,11 +43,11 @@ n_steps = 200 #Limit the speed into areas when the threshold is exceeded speed_rf = 0.1 -limit_speed_mode = False +limit_speed_mode = True #Decrease all traffic lights duration into the area when the threshold is exceeded trafficLights_duration_rf = 0.2 -adjust_traffic_light_mode = False +adjust_traffic_light_mode = True #Immediately delete all vehicles in the simulation area remove_vehicles_mode = False @@ -56,7 +56,7 @@ remove_vehicles_mode = False weight_routing_mode = False #Lock the area when the threshold is exceeded (NOT FIXED) -lock_area_mode = True +lock_area_mode = False #Weight routing mode cannot be combinated with other actions if weight_routing_mode: diff --git a/sumo_project/emissions.py b/sumo_project/emissions.py index 24c22f3..f49f910 100644 --- a/sumo_project/emissions.py +++ b/sumo_project/emissions.py @@ -61,8 +61,6 @@ def parsePhase(phase_repr): return Phase(duration[0], minDuration[0], maxDuration[0], phaseDef) def add_data_to_areas(areas: List[Area]): - - lanes = get_all_lanes() for area in areas: for lane in lanes: # add lanes @@ -146,7 +144,9 @@ def main(): finally: traci.close(False) - logger.info('End of the simulation') + simulation_time = round(time.perf_counter() - start,2) + logger.info(f'End of the simulation ({simulation_time}s)') + total_emissions = 0 for area in grid: total_emissions += area.emissions