2018-11-23 12:53:20 +00:00
|
|
|
"""
|
|
|
|
Global configuration for the simulation
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2018-12-07 15:30:23 +00:00
|
|
|
import datetime
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
############################# SIMULATION FILE #################################
|
|
|
|
###############################################################################
|
2018-11-23 12:53:20 +00:00
|
|
|
|
|
|
|
if 'SUMO_HOME' in os.environ:
|
|
|
|
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
|
|
|
|
sys.path.append(tools)
|
|
|
|
else:
|
|
|
|
sys.exit("please declare environment variable 'SUMO_HOME'")
|
|
|
|
|
|
|
|
_SUMOCMD = 'sumo' # use 'sumo-gui' cmd for UI
|
|
|
|
_SUMOCFG = "mulhouse_simulation/osm.sumocfg"
|
2018-12-07 15:30:23 +00:00
|
|
|
sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', _SUMOCMD)
|
|
|
|
sumo_cmd = [sumo_binary, "-c", _SUMOCFG]
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
############################# LOGS OUTPUT #####################################
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
now = datetime.datetime.now()
|
|
|
|
current_date = now.strftime("%Y_%m_%d_%H_%M")
|
|
|
|
LOG_FILENAME = f'sumo_logs_{current_date}.log'
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
########################## SIMULATION CONFIGURATION ###########################
|
|
|
|
###############################################################################
|
|
|
|
|
2018-11-23 12:53:20 +00:00
|
|
|
CELLS_NUMBER = 10
|
|
|
|
EMISSIONS_THRESHOLD = 500000
|
|
|
|
n_steps = 200
|
|
|
|
|
2018-12-07 15:30:23 +00:00
|
|
|
###############################################################################
|
|
|
|
########################## ACTIONS CONFIGURATION ##############################
|
|
|
|
###############################################################################
|
|
|
|
|
2018-12-03 20:17:19 +00:00
|
|
|
#Limit the speed into areas when the threshold is exceeded
|
2018-12-07 15:30:23 +00:00
|
|
|
speed_rf = 0.1
|
2018-12-03 20:46:31 +00:00
|
|
|
limit_speed_mode = False
|
2018-12-03 20:17:19 +00:00
|
|
|
|
2018-12-03 20:05:01 +00:00
|
|
|
#Decrease all traffic lights duration into the area when the threshold is exceeded
|
2018-12-07 15:30:23 +00:00
|
|
|
trafficLights_duration_rf = 0.2
|
2018-12-03 20:46:31 +00:00
|
|
|
adjust_traffic_light_mode = False
|
|
|
|
|
|
|
|
#Immediately delete all vehicles in the simulation area
|
2018-12-06 20:49:01 +00:00
|
|
|
remove_vehicles_mode = False
|
|
|
|
|
|
|
|
#Vehicles are routed according to the less polluted route (HEAVY)
|
2018-12-07 15:30:23 +00:00
|
|
|
weight_routing_mode = False
|
2018-12-06 20:49:01 +00:00
|
|
|
|
|
|
|
#Lock the area when the threshold is exceeded (NOT FIXED)
|
2018-12-07 15:30:23 +00:00
|
|
|
lock_area_mode = True
|
2018-11-23 12:53:20 +00:00
|
|
|
|
2018-12-03 20:05:01 +00:00
|
|
|
#Weight routing mode cannot be combinated with other actions
|
|
|
|
if weight_routing_mode:
|
|
|
|
limit_speed_mode = False
|
|
|
|
adjust_traffic_light_mode = False
|
|
|
|
|
2018-12-07 15:30:23 +00:00
|
|
|
###############################################################################
|
|
|
|
########################## SIMULATION REFERENCES ##############################
|
|
|
|
###############################################################################
|
2018-11-23 12:53:20 +00:00
|
|
|
|
2018-12-06 20:49:01 +00:00
|
|
|
# Total of emissions of all pollutants in mg for n steps of simulation without locking areas
|
|
|
|
total_emissions200 = 43970763.15084749
|
|
|
|
total_emissions300 = 87382632.08217141
|
|
|
|
|
2018-12-07 15:30:23 +00:00
|
|
|
###############################################################################
|
|
|
|
########################## CONFIGURATION METHODS ##############################
|
|
|
|
###############################################################################
|
|
|
|
|
2018-12-06 20:49:01 +00:00
|
|
|
def get_basics_emissions():
|
|
|
|
if n_steps == 200:
|
|
|
|
return total_emissions200
|
|
|
|
if n_steps == 300:
|
|
|
|
return total_emissions300
|
|
|
|
|
2018-11-23 12:53:20 +00:00
|
|
|
def showConfig():
|
|
|
|
return (str(f'Grid : {CELLS_NUMBER}x{CELLS_NUMBER}\n')
|
|
|
|
+ str(f'step number = {n_steps}\n')
|
2018-12-07 15:30:23 +00:00
|
|
|
+ str(f'weight routing mode = {weight_routing_mode}\n')
|
|
|
|
+ str(f'lock area mode = {lock_area_mode}\n')
|
|
|
|
+ str(f'limit speed mode = {limit_speed_mode}, RF = {speed_rf*100}%\n')
|
|
|
|
+ str(f'adjust traffic light mode = {adjust_traffic_light_mode} , RF = {trafficLights_duration_rf*100}%\n'))
|
2018-11-23 12:53:20 +00:00
|
|
|
|