From 289c09b25373af69185e8052c6573fcf09a39495 Mon Sep 17 00:00:00 2001 From: Ahp06 Date: Sun, 9 Dec 2018 15:46:22 +0100 Subject: [PATCH] Fixed some bugs --- sumo_project/config.py | 2 +- sumo_project/emissions.py | 5 +---- sumo_project/model.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sumo_project/config.py b/sumo_project/config.py index f1a8888..4f935f9 100644 --- a/sumo_project/config.py +++ b/sumo_project/config.py @@ -28,7 +28,7 @@ sumo_cmd = [sumo_binary, "-c", _SUMOCFG] now = datetime.datetime.now() current_date = now.strftime("%Y_%m_%d_%H_%M_%S") -log_filename = f'sumo_logs_{current_date}.log' +log_filename = f'logs/sumo_logs_{current_date}.log' # create logger logger = logging.getLogger("sumo_logger") diff --git a/sumo_project/emissions.py b/sumo_project/emissions.py index 3fbaf09..b010b1a 100644 --- a/sumo_project/emissions.py +++ b/sumo_project/emissions.py @@ -15,9 +15,6 @@ from traci import trafficlight logger = config.logger def init_grid(simulation_bounds, areas_number): - """ - Create all areas according to simulation bounds and the areas number choosen - """ grid = list() width = simulation_bounds[1][0] / areas_number height = simulation_bounds[1][1] / areas_number @@ -93,7 +90,7 @@ def get_emissions(grid: List[Area], vehicles: List[Vehicle], current_step): area.emissions_by_step.append(vehicle_emissions) - if area.sum_emissions_by_step(current_step, config.window_size) > config.emissions_threshold: + if area.sum_emissions_into_window(current_step, config.window_size) >= config.emissions_threshold: if config.limit_speed_mode and not area.limited_speed: logger.info(f'Action - Decreased max speed into {area.name} by {config.speed_rf*100}%') diff --git a/sumo_project/model.py b/sumo_project/model.py index e5d288c..e910840 100644 --- a/sumo_project/model.py +++ b/sumo_project/model.py @@ -83,7 +83,7 @@ class Area: sum += emission return sum - def sum_emissions_by_step(self, current_step, window_size): + def sum_emissions_into_window(self, current_step, window_size): sum = 0 q = current_step // window_size #Returns the integral part of the quotient for i in range(q*window_size, current_step):