-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconvert_dataset.py
More file actions
71 lines (56 loc) · 2.67 KB
/
Copy pathconvert_dataset.py
File metadata and controls
71 lines (56 loc) · 2.67 KB
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
import os
import numpy as np
import argparse
if __name__ == "__main__":
# python convert_dataset.py -d results_single_top -name Garr199905
parser = argparse.ArgumentParser(description='Parse file and create plots')
parser.add_argument('-f1', help='File where the topologies are stored', type=str, required=True, nargs='+')
parser.add_argument('-name', help='Topology name', type=str, required=True, nargs='+')
args = parser.parse_args()
data_dir = args.f1[0]
topology_name = args.name[0]
new_dir = "../Enero_datasets/dataset_sing_top/data/"+data_dir+"/NEW_"+topology_name+'/'
new_dir_train = new_dir+"TRAIN"
new_dir_eval = new_dir+"EVALUATE"
new_dir_all = new_dir+"ALL"
new_dir_TM_train = new_dir_train+"/TM/"
new_dir_TM_eval = new_dir_eval+"/TM/"
new_dir_TM_all = new_dir_all+"/TM/"
if not os.path.exists(new_dir):
os.makedirs(new_dir)
else:
os.system("rm -rf %s" % (new_dir))
os.makedirs(new_dir)
os.makedirs(new_dir_train)
os.makedirs(new_dir_eval)
os.makedirs(new_dir_all)
os.makedirs(new_dir_TM_train)
os.makedirs(new_dir_TM_eval)
os.makedirs(new_dir_TM_all)
# aux_top_name = "./data/"+data_dir+"/"+topology_name+"/graph_"+topology_name+".txt"
aux_top_name = "../Enero_datasets/results-1-link_capacity-unif-05-1/results_zoo/"+topology_name+"/"+topology_name+".graph"
os.system("cp %s %s.graph" % (aux_top_name, new_dir_train+'/'+topology_name))
os.system("cp %s %s.graph" % (aux_top_name, new_dir_eval+'/'+topology_name))
os.system("cp %s %s.graph" % (aux_top_name, new_dir_all+'/'+topology_name))
num_TMs_train = 0
nums_TMs_eval = 0
nums_TMs_all = 0
for subdir, dirs, files in os.walk("../Enero_datasets/results-1-link_capacity-unif-05-1/results_zoo/"+topology_name+"/TM/"):
for file in files:
#if file.startswith('TM-'):
if file.endswith('.demands'):
dst_dir = new_dir_TM_eval
tm_iter = nums_TMs_eval
# Compute handcrafted 70% of the total samples
if num_TMs_train<100:
dst_dir = new_dir_TM_train
tm_iter = num_TMs_train
os.system("cp %s %s.%s.demands" % (subdir+'/'+file, dst_dir+'/'+topology_name, tm_iter))
if num_TMs_train<100:
num_TMs_train += 1
else:
nums_TMs_eval += 1
dst_dir = new_dir_TM_all
tm_iter = nums_TMs_all
os.system("cp %s %s.%s.demands" % (subdir+'/'+file, dst_dir+'/'+topology_name, tm_iter))
nums_TMs_all += 1