mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-21 19:16:30 +00:00
Fixed some bugs
This commit is contained in:
parent
28be0142fb
commit
91eb76e7b3
@ -25,10 +25,12 @@ class Config:
|
||||
|
||||
self._SUMOCMD = data["_SUMOCMD"]
|
||||
self._SUMOCFG = data["_SUMOCFG"]
|
||||
|
||||
self.areas_number = data["areas_number"]
|
||||
self.emissions_threshold = data["emissions_threshold"]
|
||||
self.n_steps = data["n_steps"]
|
||||
self.window_size = data["window_size"]
|
||||
|
||||
self.without_actions_mode = data["without_actions_mode"]
|
||||
self.limit_speed_mode = data["limit_speed_mode"]
|
||||
self.speed_rf = data["speed_rf"]
|
||||
@ -74,7 +76,7 @@ class Config:
|
||||
sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', self._SUMOCMD)
|
||||
self.sumo_cmd = [sumo_binary, "-c", self._SUMOCFG]
|
||||
|
||||
def init_logger(self):
|
||||
def init_logger(self, save_logs = True):
|
||||
now = datetime.datetime.now()
|
||||
current_date = now.strftime("%Y_%m_%d_%H_%M_%S")
|
||||
|
||||
@ -85,7 +87,10 @@ class Config:
|
||||
|
||||
logger = logging.getLogger("sumo_logger")
|
||||
logger.setLevel(logging.INFO)
|
||||
handler = logging.FileHandler(log_filename)
|
||||
if save_logs :
|
||||
handler = logging.FileHandler(log_filename)
|
||||
else:
|
||||
handler = logging.StreamHandler()
|
||||
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"_SUMOCMD": "sumo",
|
||||
"_SUMOCFG": "mulhouse_simulation/osm.sumocfg",
|
||||
"_SUMOCFG": "simulations/mulhouse_simulation/osm.sumocfg",
|
||||
|
||||
"areas_number": 10,
|
||||
"emissions_threshold": 500000,
|
||||
|
@ -14,7 +14,7 @@ from model import Area, Vehicle, Lane , TrafficLight , Phase , Logic
|
||||
from traci import trafficlight
|
||||
|
||||
config = Config()
|
||||
logger = config.init_logger()
|
||||
logger = config.init_logger(save_logs = True)
|
||||
|
||||
def init_grid(simulation_bounds, areas_number):
|
||||
grid = list()
|
||||
@ -124,6 +124,7 @@ def main(args):
|
||||
grid = list()
|
||||
try:
|
||||
traci.start(config.sumo_cmd)
|
||||
logger.info(f'Loaded configuration file : {args.configfile}')
|
||||
logger.info(f'Loaded simulation file : {config._SUMOCFG}')
|
||||
logger.info('Loading data for the simulation')
|
||||
start = time.perf_counter()
|
||||
@ -163,9 +164,7 @@ def main(args):
|
||||
if not (ref is None):
|
||||
diff_with_actions = (ref - total_emissions)/ref
|
||||
logger.info(f'Reduction percentage of emissions = {diff_with_actions*100} %')
|
||||
|
||||
logger.info(f'With the configuration : \n{config}')
|
||||
logger.info('Logs END')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user