1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-24 20:46:29 +00:00

Fixed some bugs

This commit is contained in:
Ahp06 2018-12-09 15:46:22 +01:00
parent c1a66c45de
commit 289c09b253
3 changed files with 3 additions and 6 deletions

View File

@ -28,7 +28,7 @@ sumo_cmd = [sumo_binary, "-c", _SUMOCFG]
now = datetime.datetime.now() now = datetime.datetime.now()
current_date = now.strftime("%Y_%m_%d_%H_%M_%S") 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 # create logger
logger = logging.getLogger("sumo_logger") logger = logging.getLogger("sumo_logger")

View File

@ -15,9 +15,6 @@ from traci import trafficlight
logger = config.logger logger = config.logger
def init_grid(simulation_bounds, areas_number): def init_grid(simulation_bounds, areas_number):
"""
Create all areas according to simulation bounds and the areas number choosen
"""
grid = list() grid = list()
width = simulation_bounds[1][0] / areas_number width = simulation_bounds[1][0] / areas_number
height = simulation_bounds[1][1] / 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) 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: 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}%') logger.info(f'Action - Decreased max speed into {area.name} by {config.speed_rf*100}%')

View File

@ -83,7 +83,7 @@ class Area:
sum += emission sum += emission
return sum return sum
def sum_emissions_by_step(self, current_step, window_size): def sum_emissions_into_window(self, current_step, window_size):
sum = 0 sum = 0
q = current_step // window_size #Returns the integral part of the quotient q = current_step // window_size #Returns the integral part of the quotient
for i in range(q*window_size, current_step): for i in range(q*window_size, current_step):