mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-24 12:36:30 +00:00
Added reverse actions method
This commit is contained in:
parent
af05ad08d0
commit
c1a66c45de
@ -59,19 +59,20 @@ def lock_area(area):
|
||||
|
||||
def reverse_actions(area):
|
||||
#Reset max speed to original
|
||||
if not area.limited_speed:
|
||||
if area.limited_speed:
|
||||
area.limited_speed = False
|
||||
for lane in area.lanes:
|
||||
traci.lane.setMaxSpeed(lane.lane_id, lane.initial_max_speed / 3.6)
|
||||
for lane in area._lanes:
|
||||
traci.lane.setMaxSpeed(lane.lane_id, lane.initial_max_speed)
|
||||
|
||||
#Reset traffic lights initial duration
|
||||
if not area.tls_adjusted:
|
||||
if area.tls_adjusted:
|
||||
area.tls_adjusted = False
|
||||
for initial_logic in tl._logics:
|
||||
traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, initial_logic)
|
||||
for tl in area._tls:
|
||||
for initial_logic in tl._logics:
|
||||
traci.trafficlights.setCompleteRedYellowGreenDefinition(tl.tl_id, initial_logic._logic)
|
||||
|
||||
#Unlock the area
|
||||
if not area.locked:
|
||||
if area.locked:
|
||||
area.locked = False
|
||||
for lane in area._lanes:
|
||||
traci.lane.setAllowed(lane.lane_id, '') #empty means all classes are allowed
|
||||
|
@ -76,6 +76,7 @@ lock_area_mode = False
|
||||
if weight_routing_mode:
|
||||
limit_speed_mode = False
|
||||
adjust_traffic_light_mode = False
|
||||
lock_area_mode = False
|
||||
|
||||
#If without_actions_mode is choosen
|
||||
if without_actions_mode:
|
||||
|
@ -109,6 +109,9 @@ def get_emissions(grid: List[Area], vehicles: List[Vehicle], current_step):
|
||||
logger.info(f'Action - {area.name} blocked')
|
||||
actions.lock_area(area)
|
||||
|
||||
else:
|
||||
actions.reverse_actions(area)
|
||||
|
||||
|
||||
def main():
|
||||
grid = list()
|
||||
@ -133,7 +136,6 @@ def main():
|
||||
get_emissions(grid, vehicles,step)
|
||||
|
||||
if config.weight_routing_mode:
|
||||
logger.info('Action - Lane weights adjusted')
|
||||
actions.adjust_edges_weights()
|
||||
|
||||
step += 1
|
||||
|
Loading…
Reference in New Issue
Block a user