mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-21 19:16:30 +00:00
Add end time parameter
This commit is contained in:
parent
426bd572dc
commit
c4163e3e69
@ -143,7 +143,7 @@ def load_sumoconfig_template(simulation_name, routefiles=(), generate_polygons=F
|
|||||||
root.find('input').remove(additional)
|
root.find('input').remove(additional)
|
||||||
root.find('report/log').set('value', f'{simulation_name}.log')
|
root.find('report/log').set('value', f'{simulation_name}.log')
|
||||||
# Set the seed for the random number generator. By default, use the current time
|
# Set the seed for the random number generator. By default, use the current time
|
||||||
root.find('random_number/seed').set('value', seed or str(time.time()))
|
root.find('random_number/seed').set('value', seed or str(int(time.time())))
|
||||||
return sumoconfig
|
return sumoconfig
|
||||||
|
|
||||||
|
|
||||||
@ -180,12 +180,11 @@ def generate_polygons_(osm_file, scenario_name, dest):
|
|||||||
subprocess.run(polyconvert_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run(polyconvert_cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
|
||||||
def generate_mobility(out_path, name, vclasses):
|
def generate_mobility(out_path, name, vclasses, end_time):
|
||||||
netfile = f'{name}.net.xml'
|
netfile = f'{name}.net.xml'
|
||||||
netpath = os.path.join(out_path, netfile)
|
netpath = os.path.join(out_path, netfile)
|
||||||
output = os.path.join(out_path, f'{name}.trips.xml')
|
output = os.path.join(out_path, f'{name}.trips.xml')
|
||||||
routefiles = []
|
routefiles = []
|
||||||
end_time = 200
|
|
||||||
for vclass, density in vclasses.items():
|
for vclass, density in vclasses.items():
|
||||||
# simname.bus.rou.xml, simname.passenger.rou.xml, ...
|
# simname.bus.rou.xml, simname.passenger.rou.xml, ...
|
||||||
routefile = f'{name}.{vclass}.rou.xml'
|
routefile = f'{name}.{vclass}.rou.xml'
|
||||||
@ -216,7 +215,7 @@ def generate_all(args):
|
|||||||
logs_dir = os.path.join(simulation_dir, 'log')
|
logs_dir = os.path.join(simulation_dir, 'log')
|
||||||
|
|
||||||
generate_scenario(osm_file, simulation_dir, simulation_name, generate_polygons)
|
generate_scenario(osm_file, simulation_dir, simulation_name, generate_polygons)
|
||||||
routefiles = generate_mobility(simulation_dir, simulation_name, args.vclasses)
|
routefiles = generate_mobility(simulation_dir, simulation_name, args.vclasses, args.end)
|
||||||
generate_sumo_configuration(routefiles, simulation_dir, simulation_name, generate_polygons)
|
generate_sumo_configuration(routefiles, simulation_dir, simulation_name, generate_polygons)
|
||||||
# Move all logs to logdir
|
# Move all logs to logdir
|
||||||
move_logs(simulation_dir, logs_dir)
|
move_logs(simulation_dir, logs_dir)
|
||||||
@ -245,6 +244,7 @@ def parse_command_line(args=None):
|
|||||||
'given in vehicles per hour per kilometer. For now, the following vehicle classes are '
|
'given in vehicles per hour per kilometer. For now, the following vehicle classes are '
|
||||||
'available: passenger, truck, bus.')
|
'available: passenger, truck, bus.')
|
||||||
parser.add_argument('--seed', help='Initializes the random number generator.')
|
parser.add_argument('--seed', help='Initializes the random number generator.')
|
||||||
|
parser.add_argument('-e', '--end', type=int, default=200, help='end time (default 200)')
|
||||||
return parser.parse_args(args=args)
|
return parser.parse_args(args=args)
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class GenerationTests(unittest.TestCase):
|
|||||||
trips_file = os.path.join(self.sim_path, f'{self.sim_name}.trips.xml')
|
trips_file = os.path.join(self.sim_path, f'{self.sim_name}.trips.xml')
|
||||||
configurator.generate_scenario(osm_file, self.sim_path, self.sim_name)
|
configurator.generate_scenario(osm_file, self.sim_path, self.sim_name)
|
||||||
classes = {'passenger': 10, 'truck': 1}
|
classes = {'passenger': 10, 'truck': 1}
|
||||||
routefiles = configurator.generate_mobility(self.sim_path, self.sim_name, vclasses=classes)
|
routefiles = configurator.generate_mobility(self.sim_path, self.sim_name, vclasses=classes, end_time=200)
|
||||||
|
|
||||||
self.assert_is_file(trips_file)
|
self.assert_is_file(trips_file)
|
||||||
for f in routefiles:
|
for f in routefiles:
|
||||||
|
Loading…
Reference in New Issue
Block a user