1
0
mirror of https://github.com/Ahp06/SUMO_Emissions.git synced 2024-11-22 03:26:30 +00:00

Added -ref option to start a reference simulation

This commit is contained in:
Ahp06 2018-12-11 16:21:03 +01:00
parent b8edadb5c8
commit 2ab280b94e
2 changed files with 24 additions and 12 deletions

View File

@ -3,14 +3,15 @@ Global configuration for the simulation
""" """
import datetime import datetime
import json
import logging import logging
import os import os
import sys import sys
import json
class Config: class Config:
# Total of emissions of all pollutants in mg for n steps of simulation without locking areas # Total of emissions of all pollutants in mg for n steps of simulation without acting on areas
# These constants are simulation dependant, you must change them according to your simulation # These constants are simulation dependant, you must change them according to your simulation
total_emissions100 = 13615949.148296086 total_emissions100 = 13615949.148296086
total_emissions200 = 43970763.15084738 total_emissions200 = 43970763.15084738

View File

@ -1,17 +1,17 @@
import argparse
import sys
import time
from traci import trafficlight
import traci
from typing import List from typing import List
import traci
import time
import argparse
from shapely.geometry import LineString
from parse import search from parse import search
from shapely.geometry import LineString
import actions import actions
from config import Config from config import Config
import sys
from model import Area, Vehicle, Lane , TrafficLight , Phase , Logic from model import Area, Vehicle, Lane , TrafficLight , Phase , Logic
from traci import trafficlight
def init_grid(simulation_bounds, areas_number): def init_grid(simulation_bounds, areas_number):
grid = list() grid = list()
@ -159,15 +159,26 @@ def main(args):
parser = argparse.ArgumentParser(description="") parser = argparse.ArgumentParser(description="")
parser.add_argument("-f", "--configfile", type=str, default= 'configs/default_config.json', required=False) parser.add_argument("-f", "--configfile", type=str, default= 'configs/default_config.json', required=False)
parser.add_argument("-save", "--save", action = "store_true") parser.add_argument("-save", "--save", action = "store_true")
parser.add_argument("-ref","--ref", action = "store_true")
args = parser.parse_args(args) args = parser.parse_args(args)
# > py ./emissions.py -f configs/config1.json -save
# will load the configuration file "config1.json" and save logs into the logs directory
# > py ./emissions.py -f configs/config1.json -save & py ./emissions.py -f configs/config1.json -save -ref
# same as above but also launches a reference simulation by using -ref option
config = Config() config = Config()
config.import_config_file(args.configfile) config.import_config_file(args.configfile)
config.init_traci() config.init_traci()
logger = config.init_logger(save_logs = args.save) logger = config.init_logger(save_logs = args.save)
if args.ref:
config.without_actions_mode = True
config.check_config()
logger.info(f'Reference simulation')
logger.info(f'Loaded configuration file : {args.configfile}') logger.info(f'Loaded configuration file : {args.configfile}')
run(config, logger) run(config, logger)
if __name__ == '__main__': if __name__ == '__main__':
main(sys.argv[1:]) main(sys.argv[1:])