-
Notifications
You must be signed in to change notification settings - Fork 1
/
state_helper.py
113 lines (84 loc) · 3.66 KB
/
state_helper.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Copyright (c) 2023 VISTEC - Vidyasirimedhi Institute of Science and Technology
# Distribute under MIT License
# Authors:
# - Sucha Supittayapornpong <sucha.s[-at-]vistec.ac.th>
# - Kanatip Chitavisutthivong <kanatip.c_s18[-at-]vistec.ac.th>
import os
HCONST = { 'topology data directory': 'Precomputation',
'commodity data directory': 'commodity',
'flow data directory': 'flow',
'link data directory': 'link',
'traffic data directory': 'traffic',
'stage data directory': 'stage',
'commdir': None,
'flowdir': None,
'linkdir': None,
'trafficdir': None,
'stagedir': None,
'output data directory': 'Output',
'intermediate data directory': 'intermediate',
'outputdir': None,
'intmeddir': None}
def involve(node, autmap):
return autmap[node] != node
def applyGenerator(nodes, autmap):
return tuple(autmap[n] for n in nodes)
def makeTopologyDataDirectory(rootdir):
if not os.path.exists(rootdir):
os.mkdir(rootdir)
if not os.path.exists(rootdir + '/' + HCONST['topology data directory']):
os.mkdir(rootdir + '/' + HCONST['topology data directory'])
def makeAutomorphicDataDirectory(rootdir, toponame):
topopath = rootdir + '/' + HCONST['topology data directory'] + '/' + toponame
if not os.path.exists(topopath):
os.mkdir(topopath)
commpath = topopath + '/' + HCONST['commodity data directory']
if not os.path.exists(commpath):
os.mkdir(commpath)
HCONST['commdir'] = commpath
flowpath = topopath + '/' + HCONST['flow data directory']
if not os.path.exists(flowpath):
os.mkdir(flowpath)
HCONST['flowdir'] = flowpath
linkpath = topopath + '/' + HCONST['link data directory']
if not os.path.exists(linkpath):
os.mkdir(linkpath)
HCONST['linkdir'] = linkpath
trafficpath = topopath + '/' + HCONST['traffic data directory']
if not os.path.exists(trafficpath):
os.mkdir(trafficpath)
HCONST['trafficdir'] = trafficpath
stagepath = topopath + '/' + HCONST['stage data directory']
if not os.path.exists(stagepath):
os.mkdir(stagepath)
HCONST['stagedir'] = stagepath
def makeOutputDataDirectory(rootdir, toponame):
if not os.path.exists(rootdir):
os.mkdir(rootdir)
outputpath = rootdir + '/' + HCONST['output data directory']
if not os.path.exists(outputpath):
os.mkdir(outputpath)
topopath = outputpath + '/' + toponame
if not os.path.exists(topopath):
os.mkdir(topopath)
HCONST['outputdir'] = topopath
intmedpath = topopath + '/' + HCONST['intermediate data directory']
if not os.path.exists(intmedpath):
os.mkdir(intmedpath)
HCONST['intmeddir'] = intmedpath
def initHCONST(rootdir, toponame, objfunc):
topopath = rootdir + '/' + HCONST['topology data directory'] + '/' + toponame
commpath = topopath + '/' + HCONST['commodity data directory']
HCONST['commdir'] = commpath
flowpath = topopath + '/' + HCONST['flow data directory']
HCONST['flowdir'] = flowpath
linkpath = topopath + '/' + HCONST['link data directory']
HCONST['linkdir'] = linkpath
trafficpath = topopath + '/' + HCONST['traffic data directory']
HCONST['trafficdir'] = trafficpath
stagepath = topopath + '/' + HCONST['stage data directory']
HCONST['stagedir'] = stagepath
outputpath = rootdir + '/' + HCONST['output data directory'] + '/' + toponame + '-' + str(objfunc)
HCONST['outputdir'] = outputpath
intmedpath = outputpath + '/' + HCONST['intermediate data directory']
HCONST['intmedpath'] = intmedpath