|
4 | 4 |
|
5 | 5 | scenario_name = sys.argv[1] |
6 | 6 | queuedisc_name = sys.argv[2] |
7 | | -fname = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-drop.dat' |
8 | | -nfname = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-drop.dat' |
9 | | -f = open (fname ,"r") |
10 | | -l = f.readlines () |
11 | | -l.sort () |
12 | | -f.close () |
| 7 | +file_name = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-drop.dat' |
| 8 | +new_file_name = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-drop.dat' |
| 9 | +File = open (file_name ,"r") |
| 10 | +lines_read = File.readlines () |
| 11 | +lines_read.sort () |
| 12 | +File.close () |
13 | 13 | i=0 |
14 | | -d=[] |
15 | | -a=[] |
16 | | -F3 = [] |
17 | | -for m in l: |
18 | | - if i == len(l)-1: |
| 14 | +data=[] |
| 15 | +inst_data=[] |
| 16 | +bucket = [] |
| 17 | +for file_iterator in lines_read: |
| 18 | + if i == len(lines_read)-1: |
19 | 19 | break |
20 | 20 | i+=1 |
21 | | - if m.split(' ')[0] == l[i].split(' ')[0]: |
22 | | - s1 = float(m.split(' ')[1]) |
23 | | - d.append(s1) |
| 21 | + if file_iterator.split(' ')[0] == lines_read[i].split(' ')[0]: |
| 22 | + temp_string = float(file_iterator.split(' ')[1]) |
| 23 | + data.append(temp_string) |
24 | 24 | else: |
25 | | - d.sort () |
26 | | - j=1 |
| 25 | + data.sort () |
| 26 | + data_iterator=1 |
27 | 27 |
|
28 | | - while j < len(d): |
29 | | - a.append(d[j]-d[j-1]) |
30 | | - j+=1 |
31 | | - hist, bin_edges = np.histogram(a, normed=True, bins=10000, density=True) |
| 28 | + while data_iterator < len(data): |
| 29 | + inst_data.append(data[data_iterator]-data[data_iterator-1]) |
| 30 | + data_iterator+=1 |
| 31 | + hist, bin_edges = np.histogram(inst_data, normed=True, bins=10000, density=True) |
32 | 32 | dx = bin_edges[1] - bin_edges[0] |
33 | | - F1 = np.cumsum(hist)*dx |
34 | | - F2 = [[0,0], [bin_edges[0], 0]] |
35 | | - for k in range(len(F1)): |
36 | | - F2.append([bin_edges[k+1], F1[k]]) |
37 | | - F3.append(F2) |
38 | | - d=[] |
| 33 | + Function_uno = np.cumsum(hist)*dx |
| 34 | + Function_duo = [[0,0], [bin_edges[0], 0]] |
| 35 | + for k in range(len(Function_uno)): |
| 36 | + Function_duo.append([bin_edges[k+1], Function_uno[k]]) |
| 37 | + bucket.append(Function_duo) |
| 38 | + data=[] |
39 | 39 |
|
40 | | -d.sort () |
41 | | -j = 1 |
42 | | -while j < len(d): |
43 | | - a.append(d[j]-d[j-1]) |
44 | | - j+=1 |
45 | | -hist, bin_edges = np.histogram(a, normed=True, bins=10000, density=True) |
| 40 | +data.sort () |
| 41 | +data_iterator = 1 |
| 42 | +while data_iterator < len(data): |
| 43 | + inst_data.append(data[data_iterator]-data[data_iterator-1]) |
| 44 | + data_iterator+=1 |
| 45 | +hist, bin_edges = np.histogram(inst_data, normed=True, bins=10000, density=True) |
46 | 46 | dx = bin_edges[1] - bin_edges[0] |
47 | | -F1 = np.cumsum(hist)*dx |
48 | | -F2 = [[0,0], [bin_edges[0], 0]] |
49 | | -for k in range(len(F1)): |
50 | | - F2.append([bin_edges[k+1], F1[k]]) |
51 | | -F3.append(F2) |
52 | | -d=[] |
| 47 | +Function_uno = np.cumsum(hist)*dx |
| 48 | +Function_duo = [[0,0], [bin_edges[0], 0]] |
| 49 | +for k in range(len(Function_uno)): |
| 50 | + Function_duo.append([bin_edges[k+1], Function_uno[k]]) |
| 51 | +bucket.append(Function_duo) |
| 52 | +data=[] |
53 | 53 |
|
54 | 54 | gnufile = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-gnu-drop' |
55 | 55 | gnu = open(gnufile, "w") |
|
58 | 58 | gnu.write("set output \"aqm-eval-output/"+scenario_name+"/graph/"+queuedisc_name+"-drop.png\"\n set xlabel \"Time difference between two drops\"\nset ylabel \"CDF\"\nset grid\nshow grid\n") |
59 | 59 |
|
60 | 60 |
|
61 | | -wfile = open (nfname ,"w") |
| 61 | +wfile = open (new_file_name ,"w") |
62 | 62 |
|
63 | 63 | flow = 1 |
64 | | -for x in F3: |
| 64 | +for x in bucket: |
65 | 65 | wfile.write("\n\n#\"flow"+str(flow)+"\"\n") |
66 | 66 | flow+=1 |
67 | 67 | for y in x: |
68 | 68 | wfile.write (str(y[0])+" "+str(y[1])+"\n") |
69 | 69 | wfile.close() |
70 | 70 |
|
71 | | -for j in range(len(F3)): |
72 | | - if j == 0: |
73 | | - gnu.write("plot \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"") |
| 71 | +for data_iterator in range(len(bucket)): |
| 72 | + if data_iterator == 0: |
| 73 | + gnu.write("plot \""+new_file_name+"\" i "+str(data_iterator)+" using 1:2 with lines smooth csplines title \"Flow "+str(data_iterator+1)+"\"") |
74 | 74 | else: |
75 | | - gnu.write(", \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"") |
| 75 | + gnu.write(", \""+new_file_name+"\" i "+str(data_iterator)+" using 1:2 with lines smooth csplines title \"Flow "+str(data_iterator+1)+"\"") |
76 | 76 |
|
77 | 77 | gnu.close() |
78 | 78 | os.system("gnuplot "+gnufile) |
|
0 commit comments