-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtester.py
More file actions
114 lines (103 loc) · 2.56 KB
/
tester.py
File metadata and controls
114 lines (103 loc) · 2.56 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
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
114
# from main import Generate, Load
# import greedy
# import aco
import plotly.graph_objects as go
import subprocess
import os
instances = [
'./known-solutions/berlin52.txt',
# './known-solutions/ch130.txt',
# './known-solutions/ch150.txt',
# './known-solutions/gil262.txt',
# './known-solutions/rat99.txt',
# './known-solutions/rat195.txt',
# './known-solutions/rat575.txt',
# './known-solutions/rat783.txt',
# './known-solutions/st70.txt',
# './known-solutions/tsp225.txt'
]
result_known = [
7542,
# 6110,
# 6528,
# 2378,
# 1211,
# 2323,
# 6773,
# 8806,
# 675,
# 3919
]
result_aco = []
# file = open("./greedy_vs_aco.txt", "r")
# line = file.readline().split(",")
# instances = [float(num) for num in line]
# line = file.readline().split(",")
# result_greedy = [round(float(num), 2) for num in line]
# line = file.readline().split(",")
# result_aco = [float(num) for num in line]
# file.close()
# fig = go.Figure()
# fig.add_trace(go.Bar(
# x=instances,
# y=result_greedy,
# # texttemplate="%{y}",
# # textposition="auto",
# # textangle=270,
# name="Greedy Algoritm"
# ))
# fig.add_trace(go.Bar(
# x=instances,
# y=result_aco,
# # texttemplate="%{y}",
# # textposition="auto",
# # textangle=270,
# # textfont_size=100,
# name="Ant Colony Optimization"
# ))
# for i in range(15):
# fig.add_annotation(
# x=instances[i], y=result_greedy[i],
# text=result_greedy[i],
# font=dict(
# size=18
# ),
# showarrow=True,
# textangle=90,
# xshift=-5,
# yshift=10
# )
# fig.add_annotation(
# x=instances[i], y=result_aco[i],
# text=result_aco[i],
# font=dict(
# size=18
# ),
# showarrow=True,
# textangle=90,
# xshift=25,
# yshift=10
# )
# fig.update_layout(barmode='group', title_text="Greedy vs ACO")
# # fig.update_xaxes(type='category')
# fig.show()
i = 0
names = []
for instance in instances:
print(instance)
print("Best known: ", result_known[i])
i+=1
FNULL = open(os.devnull, 'w')
args = "aco.exe {} {} {} {} {} {}".format(instance, 2000,
1000000, 1.0,
12.0, 0.6) # beta 6 10 12 - 0% 1% 5%
subprocess.call(args, shell=False)
file = open("./output.txt", "r")
distance = float(file.readline())
result_aco.append(distance)
print("ACO: ", distance)
name = instance.split("/")
names.append(name[2])
print(names,"\n")
print(result_known,"\n")
print(result_aco)