mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-24 20:46:29 +00:00
Fixed some typo
This commit is contained in:
parent
a239c51a1b
commit
8a4e6dca4f
@ -9,9 +9,8 @@ This module defines all possible actions on the simulation
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import traci
|
import traci
|
||||||
from typing import Iterable
|
|
||||||
|
|
||||||
from model import Area, Vehicle
|
from model import Area
|
||||||
|
|
||||||
|
|
||||||
def compute_edge_weight(edge_id):
|
def compute_edge_weight(edge_id):
|
||||||
@ -103,7 +102,7 @@ def lock_area(area):
|
|||||||
Prohibits access to the area to a particular vehicle class
|
Prohibits access to the area to a particular vehicle class
|
||||||
NOT FIXED : Some vehicles continue to go into the area
|
NOT FIXED : Some vehicles continue to go into the area
|
||||||
if they can not turn around and then will stay blocked there
|
if they can not turn around and then will stay blocked there
|
||||||
as long as it will not be reversed
|
as long as "lock_area" will not be reversed
|
||||||
:param area: The Area object
|
:param area: The Area object
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
@ -136,4 +135,4 @@ def reverse_actions(area):
|
|||||||
if 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
|
||||||
|
@ -39,7 +39,7 @@ class Config:
|
|||||||
:param config_file: The path to your configuration file
|
:param config_file: The path to your configuration file
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
with open(f'{config_file}.json', 'r') as f:
|
with open(f'{config_file}', 'r') as f:
|
||||||
data = json.load(f)
|
data = json.load(f)
|
||||||
|
|
||||||
for option in data:
|
for option in data:
|
||||||
|
@ -8,10 +8,6 @@ Created on 19 janv. 2019
|
|||||||
This module defines the entry point of the application
|
This module defines the entry point of the application
|
||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
|
||||||
Init the Traci API
|
|
||||||
"""
|
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
@ -31,6 +27,9 @@ import emissions
|
|||||||
from model import Emission
|
from model import Emission
|
||||||
|
|
||||||
|
|
||||||
|
"""
|
||||||
|
Init the Traci API
|
||||||
|
"""
|
||||||
if 'SUMO_HOME' in os.environ:
|
if 'SUMO_HOME' in os.environ:
|
||||||
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
|
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
|
||||||
sys.path.append(tools)
|
sys.path.append(tools)
|
||||||
@ -177,8 +176,16 @@ def create_dump(dump_name, simulation_dir, areas_number):
|
|||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo')
|
||||||
|
#sumo_cmd = [sumo_binary, "-c", f'files/simulations/{simulation_dir}/osm.sumocfg']
|
||||||
|
|
||||||
|
for f in os.listdir(simulation_dir):
|
||||||
|
if f.endswith('.sumocfg'):
|
||||||
|
_SUMOCFG = os.path.join(simulation_dir, f)
|
||||||
|
|
||||||
sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo')
|
sumo_binary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo')
|
||||||
sumo_cmd = [sumo_binary, "-c", f'files/simulations/{simulation_dir}/osm.sumocfg']
|
sumo_cmd = [sumo_binary, "-c", _SUMOCFG]
|
||||||
|
|
||||||
|
|
||||||
traci.start(sumo_cmd)
|
traci.start(sumo_cmd)
|
||||||
if not os.path.isfile(f'files/dump/{dump_name}.json'):
|
if not os.path.isfile(f'files/dump/{dump_name}.json'):
|
||||||
@ -254,7 +261,7 @@ def main(args):
|
|||||||
create_dump(args.new_dump, args.simulation_dir, args.areas)
|
create_dump(args.new_dump, args.simulation_dir, args.areas)
|
||||||
|
|
||||||
if args.run is not None:
|
if args.run is not None:
|
||||||
dump_path = f'files/dump/{args.run}.json'
|
dump_path = f'{args.run}'
|
||||||
if os.path.isfile(dump_path):
|
if os.path.isfile(dump_path):
|
||||||
with open(dump_path, 'r') as f:
|
with open(dump_path, 'r') as f:
|
||||||
data = jsonpickle.decode(f.read())
|
data = jsonpickle.decode(f.read())
|
||||||
@ -264,14 +271,14 @@ def main(args):
|
|||||||
|
|
||||||
if args.c is not None:
|
if args.c is not None:
|
||||||
for config in args.c:
|
for config in args.c:
|
||||||
files.append(f'files/configs/{config}')
|
files.append(f'{config}')
|
||||||
|
|
||||||
if args.c_dir is not None:
|
if args.c_dir is not None:
|
||||||
path = f'files/configs/{args.c_dir}/'
|
path = f'{args.c_dir}'
|
||||||
bundle_files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
|
bundle_files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
|
||||||
for config in bundle_files:
|
for config in bundle_files:
|
||||||
conf_formatted = config.replace('.json','')
|
files.append(os.path.join(path, config))
|
||||||
files.append(f'files/configs/{args.c_dir}/{conf_formatted}')
|
|
||||||
|
|
||||||
for conf in files: # Initialize all process
|
for conf in files: # Initialize all process
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user