Skip to content

Commit cce6625

Browse files
committed
Added data
1 parent c43aa19 commit cce6625

File tree

10 files changed

+423
-75
lines changed

10 files changed

+423
-75
lines changed

analyse_instances.py

Lines changed: 18 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,79 +12,22 @@ def measure_resolution_time(flow_graph):
1212
max_flow = flow_graph.get_max_flow()
1313
end_time = time.time()
1414
resolution_time = end_time - start_time
15-
return resolution_time, max_flow
16-
def process_instances(directory, num_iterations):
17-
instances = os.listdir(directory)
18-
results = []
19-
nodes = 0
20-
edges = 0
21-
for instance in instances:
22-
file_path = os.path.join(directory, instance)
23-
y = get_instance_size(file_path)
24-
nodes += y[0]
25-
edges += y[1]
26-
# if instance[8] == "-":
27-
# continue
28-
# for _ in range(num_iterations):
29-
# file_path = os.path.join(directory, instance)
30-
# flow_graph = parse_file(file_path)
31-
# resolution_times = []
32-
# max_flows = []
33-
# resolution_time, max_flow = measure_resolution_time(flow_graph)
34-
# results.append((file_path, resolution_time, max_flow))
35-
print(nodes/len(instances), edges/len(instances))
36-
return results
37-
38-
39-
40-
def analyze_results(results):
41-
# Separate the results by instance size
42-
size_results = {}
43-
for instance, resolution_time, max_flow in results:
44-
num_nodes, num_edges = get_instance_size(instance) # Implement a function to extract the number of nodes and edges from the instance name
45-
size = (num_nodes, num_edges)
46-
if size not in size_results:
47-
size_results[size] = []
48-
size_results[size].append(resolution_time)
49-
50-
# Calculate average resolution time and standard deviation for each instance size
51-
sizes = []
52-
avg_times = []
53-
std_devs = []
54-
for size, times in size_results.items():
55-
sizes.append(size)
56-
avg_time = statistics.mean(times)
57-
avg_times.append(avg_time)
58-
std_dev = statistics.stdev(times)
59-
std_devs.append(std_dev)
60-
61-
# Sort the sizes in ascending order based on the number of nodes
62-
sizes.sort(key=lambda s: s[0])
63-
64-
# Prepare labels for the x-axis
65-
x_labels = [f"Nodes: {size[0]}, Edges: {size[1]}" for size in sizes]
66-
67-
# Plot the results
68-
plt.errorbar(range(len(sizes)), avg_times, yerr=std_devs, fmt='o-', label='Method X') # Replace 'Method X' with the appropriate method name
69-
plt.xlabel('Instance Size')
70-
plt.ylabel('Resolution Time')
71-
plt.title('Resolution Time Comparison')
72-
plt.xticks(range(len(sizes)), x_labels, rotation=45)
73-
plt.legend()
74-
plt.grid(True)
75-
plt.tight_layout()
76-
plt.show()
77-
78-
def get_instance_size(instance):
79-
with open(instance, 'r') as file:
80-
lines = file.readlines()
81-
82-
num_nodes = int(lines[0].split()[1])
83-
num_edges = int(lines[3].split()[1])
84-
85-
return num_nodes, num_edges
86-
87-
15+
return resolution_time
16+
def process_instances():
17+
for n in range(1,15):
18+
results = []
19+
for nodes in range(100, 1600, 100):
20+
for density in range(1, 4):
21+
instance = f"inst-{nodes}-0.{density}.txt"
22+
file_path = os.path.join(directory, instance)
23+
flow_graph = parse_file(file_path)
24+
resolution_time = measure_resolution_time(flow_graph)
25+
results.append(resolution_time)
26+
export_results(results,n)
27+
28+
def export_results(results,n):
29+
with open("resPython"+str(n)+".txt", "w") as file:
30+
for result in results:
31+
file.write(str(result)+"\n")
8832
directory = "Instances"
89-
results = process_instances(directory,5)
90-
analyze_results(results)
33+
results = process_instances()

resPython1.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.009295463562011719
2+
0.01669931411743164
3+
0.022097349166870117
4+
0.03496050834655762
5+
0.057733774185180664
6+
0.07295346260070801
7+
0.07137227058410645
8+
0.13994789123535156
9+
0.20398759841918945
10+
0.1266491413116455
11+
0.2527782917022705
12+
0.47317981719970703
13+
0.2591228485107422
14+
0.4145522117614746
15+
0.6135649681091309
16+
0.30159997940063477
17+
0.7661449909210205
18+
0.8179423809051514
19+
0.5277318954467773
20+
1.0648293495178223
21+
1.2757582664489746
22+
0.7249228954315186
23+
1.0066344738006592
24+
2.062387228012085
25+
0.73177170753479
26+
1.5381014347076416
27+
2.1698923110961914
28+
0.9387311935424805
29+
1.7575695514678955
30+
2.5808677673339844
31+
1.3437283039093018
32+
2.3106162548065186
33+
2.912755012512207
34+
1.4233286380767822
35+
2.6718997955322266
36+
3.8199172019958496
37+
2.079949140548706
38+
4.119158029556274
39+
4.4461517333984375
40+
2.3561878204345703
41+
5.081780672073364
42+
5.487390518188477
43+
2.2024314403533936
44+
3.7188873291015625
45+
5.5438361167907715

resPython2.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.01102304458618164
2+
0.02503180503845215
3+
0.0370028018951416
4+
0.03904557228088379
5+
0.06699180603027344
6+
0.07955360412597656
7+
0.06983280181884766
8+
0.15731024742126465
9+
0.21904730796813965
10+
0.1551496982574463
11+
0.2505924701690674
12+
0.529109001159668
13+
0.2855494022369385
14+
0.4860544204711914
15+
0.6421787738800049
16+
0.30906200408935547
17+
0.8135998249053955
18+
0.8524367809295654
19+
0.545140266418457
20+
1.2073121070861816
21+
1.2623326778411865
22+
0.7815768718719482
23+
1.0071654319763184
24+
2.169132709503174
25+
0.8272178173065186
26+
1.5490686893463135
27+
2.277801990509033
28+
0.9591848850250244
29+
1.8040533065795898
30+
2.7371346950531006
31+
1.3910915851593018
32+
2.387770652770996
33+
2.842406988143921
34+
1.4561164379119873
35+
2.788469076156616
36+
4.139883756637573
37+
2.0549607276916504
38+
4.156881332397461
39+
4.068823337554932
40+
1.885709285736084
41+
4.8218467235565186
42+
5.466190814971924
43+
2.2043111324310303
44+
3.5947046279907227
45+
5.232773065567017

resPython3.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.008599519729614258
2+
0.017000675201416016
3+
0.021999835968017578
4+
0.035513877868652344
5+
0.05800485610961914
6+
0.07300615310668945
7+
0.07011604309082031
8+
0.14892959594726562
9+
0.2040257453918457
10+
0.13853001594543457
11+
0.27605247497558594
12+
0.5096127986907959
13+
0.29422855377197266
14+
0.4320638179779053
15+
0.6341731548309326
16+
0.31960296630859375
17+
0.8522708415985107
18+
0.8760983943939209
19+
0.5565135478973389
20+
1.1190550327301025
21+
1.2839055061340332
22+
0.7280473709106445
23+
1.011422872543335
24+
2.188460111618042
25+
0.7601218223571777
26+
1.5243077278137207
27+
2.2728350162506104
28+
0.9461483955383301
29+
1.8908376693725586
30+
2.7584497928619385
31+
1.4231867790222168
32+
2.3157012462615967
33+
2.8214404582977295
34+
1.4160349369049072
35+
2.7032830715179443
36+
3.8359856605529785
37+
1.9797749519348145
38+
4.1508400440216064
39+
3.9994566440582275
40+
1.9538486003875732
41+
4.910297632217407
42+
5.553876638412476
43+
2.208428144454956
44+
3.6677815914154053
45+
5.504613399505615

resPython4.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.009002685546875
2+
0.01657557487487793
3+
0.0220181941986084
4+
0.0351252555847168
5+
0.05800271034240723
6+
0.07399845123291016
7+
0.06999468803405762
8+
0.14479351043701172
9+
0.21263337135314941
10+
0.14583992958068848
11+
0.3024442195892334
12+
0.5986001491546631
13+
0.31058526039123535
14+
0.43501901626586914
15+
0.6355969905853271
16+
0.33295345306396484
17+
0.8606410026550293
18+
0.8586432933807373
19+
0.6042649745941162
20+
1.138709545135498
21+
1.2821462154388428
22+
0.7287278175354004
23+
0.9660539627075195
24+
2.122391939163208
25+
0.773266077041626
26+
1.6065170764923096
27+
2.2650585174560547
28+
1.004483938217163
29+
1.7833218574523926
30+
2.691098213195801
31+
1.3953478336334229
32+
2.3084168434143066
33+
2.903730630874634
34+
1.3339629173278809
35+
2.725118398666382
36+
3.833789348602295
37+
1.9844651222229004
38+
3.982877016067505
39+
3.9759011268615723
40+
2.439681053161621
41+
4.656463861465454
42+
5.531265735626221
43+
2.1110475063323975
44+
3.5486223697662354
45+
5.189640760421753

resPython5.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.017525672912597656
2+
0.016998767852783203
3+
0.02299976348876953
4+
0.060521841049194336
5+
0.06351327896118164
6+
0.07451510429382324
7+
0.08751559257507324
8+
0.14351248741149902
9+
0.21806120872497559
10+
0.12852692604064941
11+
0.26949095726013184
12+
0.510035514831543
13+
0.27324700355529785
14+
0.4422433376312256
15+
0.6346137523651123
16+
0.3353409767150879
17+
0.7953064441680908
18+
0.8509581089019775
19+
0.6395993232727051
20+
1.2125449180603027
21+
1.4514434337615967
22+
0.7987511157989502
23+
1.0562872886657715
24+
2.2316529750823975
25+
0.7368900775909424
26+
1.5492520332336426
27+
2.281606435775757
28+
0.908759593963623
29+
1.8606793880462646
30+
2.686267852783203
31+
1.39009428024292
32+
2.332472324371338
33+
2.7600810527801514
34+
1.474724531173706
35+
2.65692400932312
36+
3.9694745540618896
37+
1.968742847442627
38+
4.012643098831177
39+
4.02247428894043
40+
1.7790842056274414
41+
4.72515606880188
42+
5.276788949966431
43+
2.2353148460388184
44+
3.6142947673797607
45+
5.6155617237091064

resPython6.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
0.010997772216796875
2+
0.021997690200805664
3+
0.02699875831604004
4+
0.03763890266418457
5+
0.0665140151977539
6+
0.10102295875549316
7+
0.07623863220214844
8+
0.14493465423583984
9+
0.2164297103881836
10+
0.12799763679504395
11+
0.27019214630126953
12+
0.49454402923583984
13+
0.26233863830566406
14+
0.4414634704589844
15+
0.626589298248291
16+
0.3010532855987549
17+
0.8406898975372314
18+
0.8064553737640381
19+
0.589590311050415
20+
1.0641405582427979
21+
1.2607426643371582
22+
0.7133898735046387
23+
0.9605178833007812
24+
2.094510316848755
25+
0.8221781253814697
26+
1.5432422161102295
27+
2.3596935272216797
28+
0.9255282878875732
29+
2.040296792984009
30+
2.7304608821868896
31+
1.4095282554626465
32+
2.414245843887329
33+
2.8823912143707275
34+
1.416149616241455
35+
3.088009834289551
36+
3.9588513374328613
37+
2.0734755992889404
38+
4.154442548751831
39+
3.9886624813079834
40+
2.0206050872802734
41+
4.648375034332275
42+
5.440542459487915
43+
2.1968276500701904
44+
3.6300692558288574
45+
5.517676591873169

0 commit comments

Comments
 (0)