mirror of
				https://github.com/Ahp06/SUMO_Emissions.git
				synced 2025-11-03 19:49:19 +00:00 
			
		
		
		
	Added info logs
This commit is contained in:
		@@ -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):
 | 
			
		||||
 
 | 
			
		||||
@@ -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:
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user