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

Added reverse actions method

This commit is contained in:
Ahp06 2018-12-09 15:05:33 +01:00
parent af05ad08d0
commit c1a66c45de
3 changed files with 13 additions and 9 deletions

View File

@ -59,19 +59,20 @@ def lock_area(area):
def reverse_actions(area): def reverse_actions(area):
#Reset max speed to original #Reset max speed to original
if not area.limited_speed: if area.limited_speed:
area.limited_speed = False area.limited_speed = False
for lane in area.lanes: for lane in area._lanes:
traci.lane.setMaxSpeed(lane.lane_id, lane.initial_max_speed / 3.6) traci.lane.setMaxSpeed(lane.lane_id, lane.initial_max_speed)
#Reset traffic lights initial duration #Reset traffic lights initial duration
if not area.tls_adjusted: if area.tls_adjusted:
area.tls_adjusted = False area.tls_adjusted = False
for tl in area._tls:
for initial_logic in tl._logics: for initial_logic in tl._logics:
traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, initial_logic) traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, initial_logic._logic)
#Unlock the area #Unlock the area
if not area.locked: if area.locked:
area.locked = False area.locked = False
for lane in area._lanes: for lane in area._lanes:
traci.lane.setAllowed(lane.lane_id, '') #empty means all classes are allowed traci.lane.setAllowed(lane.lane_id, '') #empty means all classes are allowed

View File

@ -76,6 +76,7 @@ lock_area_mode = False
if weight_routing_mode: if weight_routing_mode:
limit_speed_mode = False limit_speed_mode = False
adjust_traffic_light_mode = False adjust_traffic_light_mode = False
lock_area_mode = False
#If without_actions_mode is choosen #If without_actions_mode is choosen
if without_actions_mode: if without_actions_mode:

View File

@ -109,6 +109,9 @@ def get_emissions(grid: List[Area], vehicles: List[Vehicle], current_step):
logger.info(f'Action - {area.name} blocked') logger.info(f'Action - {area.name} blocked')
actions.lock_area(area) actions.lock_area(area)
else:
actions.reverse_actions(area)
def main(): def main():
grid = list() grid = list()
@ -133,7 +136,6 @@ def main():
get_emissions(grid, vehicles,step) get_emissions(grid, vehicles,step)
if config.weight_routing_mode: if config.weight_routing_mode:
logger.info('Action - Lane weights adjusted')
actions.adjust_edges_weights() actions.adjust_edges_weights()
step += 1 step += 1