mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 03:26:30 +00:00
Added info logs
This commit is contained in:
parent
342320bd4a
commit
c07748f340
@ -51,11 +51,9 @@ def adjust_traffic_light_phase_duration(area, reduction_factor):
|
|||||||
traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, modifyLogic(logic,reduction_factor))
|
traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, modifyLogic(logic,reduction_factor))
|
||||||
|
|
||||||
def count_vehicles_in_area(area):
|
def count_vehicles_in_area(area):
|
||||||
#Trying to lock area
|
|
||||||
vehicles_in_area = 0
|
vehicles_in_area = 0
|
||||||
for lane in area._lanes:
|
for lane in area._lanes:
|
||||||
vehicles_in_area += traci.lane.getLastStepVehicleNumber(lane.lane_id)
|
vehicles_in_area += traci.lane.getLastStepVehicleNumber(lane.lane_id)
|
||||||
|
|
||||||
return vehicles_in_area
|
return vehicles_in_area
|
||||||
|
|
||||||
def lock_area(area):
|
def lock_area(area):
|
||||||
|
@ -26,7 +26,7 @@ sumo_cmd = [sumo_binary, "-c", _SUMOCFG]
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
now = datetime.datetime.now()
|
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'
|
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
|
#Limit the speed into areas when the threshold is exceeded
|
||||||
speed_rf = 0.1
|
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
|
#Decrease all traffic lights duration into the area when the threshold is exceeded
|
||||||
trafficLights_duration_rf = 0.2
|
trafficLights_duration_rf = 0.2
|
||||||
adjust_traffic_light_mode = False
|
adjust_traffic_light_mode = True
|
||||||
|
|
||||||
#Immediately delete all vehicles in the simulation area
|
#Immediately delete all vehicles in the simulation area
|
||||||
remove_vehicles_mode = False
|
remove_vehicles_mode = False
|
||||||
@ -56,7 +56,7 @@ remove_vehicles_mode = False
|
|||||||
weight_routing_mode = False
|
weight_routing_mode = False
|
||||||
|
|
||||||
#Lock the area when the threshold is exceeded (NOT FIXED)
|
#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
|
#Weight routing mode cannot be combinated with other actions
|
||||||
if weight_routing_mode:
|
if weight_routing_mode:
|
||||||
|
@ -61,8 +61,6 @@ def parsePhase(phase_repr):
|
|||||||
return Phase(duration[0], minDuration[0], maxDuration[0], phaseDef)
|
return Phase(duration[0], minDuration[0], maxDuration[0], phaseDef)
|
||||||
|
|
||||||
def add_data_to_areas(areas: List[Area]):
|
def add_data_to_areas(areas: List[Area]):
|
||||||
|
|
||||||
|
|
||||||
lanes = get_all_lanes()
|
lanes = get_all_lanes()
|
||||||
for area in areas:
|
for area in areas:
|
||||||
for lane in lanes: # add lanes
|
for lane in lanes: # add lanes
|
||||||
@ -146,7 +144,9 @@ def main():
|
|||||||
|
|
||||||
finally:
|
finally:
|
||||||
traci.close(False)
|
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
|
total_emissions = 0
|
||||||
for area in grid:
|
for area in grid:
|
||||||
total_emissions += area.emissions
|
total_emissions += area.emissions
|
||||||
|
Loading…
Reference in New Issue
Block a user