-
Notifications
You must be signed in to change notification settings - Fork 0
/
sumo.py
48 lines (38 loc) · 1.23 KB
/
sumo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from util import ROOT, dict_to_list, call
SUMO_HOME = '/opt/sumo'
SECONDS_IN_HOUR = 60 * 60
def randomHourMinutes_calls(root_path=ROOT):
calls = []
net_file = '%s/data/sumo/eich.net.xml' % root_path
rou_file = '%s/data/sumo/eich.rou.xml' % root_path
add_file = '%s/data/sumo/eich.add.xml' % root_path
trip_file = '%s/temp/eich.trip.xml' % root_path
out_file = '%s/temp/eich.out.xml' % root_path
trip_generator = '%s/tools/trip/randomTrips.py' % SUMO_HOME
args = dict_to_list({
'python': trip_generator,
'-e': SECONDS_IN_HOUR,
'-n': net_file,
'-o': trip_file,
'-r': rou_file,
})
calls.append(args)
args = {
'--net-file': net_file,
'--route-files': rou_file,
'--additional-files': add_file,
'--begin': 0,
'--end': SECONDS_IN_HOUR,
'--time-to-teleport': 0,
}
calls.append(['sumo', '-W'] + dict_to_list(args))
return calls
def randomHourMinutes():
"""
Generates random trips for an hour in Eichstaett, then simulates and outputs minutely.
"""
calls = randomHourMinutes_calls()
print 'Generating trips...'
call(calls[0])
print 'Running SUMO simulation...'
return call(calls[1])