-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.py
More file actions
71 lines (67 loc) · 1.59 KB
/
bench.py
File metadata and controls
71 lines (67 loc) · 1.59 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 plotly.graph_objects as go
file = open("./benchmarks.txt", "r")
line = file.readline().split(",")
instances = [num for num in line]
line = file.readline().split(",")
best = [float(num) for num in line]
line = file.readline().split(",")
result_aco = [float(num) for num in line]
file.close()
relative_error = [ round((abs(best[i] - result_aco[i])/best[i])*100, 2) for i in range(10)]
fig = go.Figure()
fig.add_trace(go.Bar(
x=instances,
y=best,
# texttemplate="%{y}",
# textposition="auto",
# textangle=270,
name="Best known solution"
))
fig.add_trace(go.Bar(
x=instances,
y=result_aco,
# text=relative_error,
# textposition="inside",
# # textangle=270,
# textfont_size=20,
name="Ant Colony Optimization"
))
for i in range(10):
fig.add_annotation(
x=instances[i], y=best[i],
text=best[i],
font=dict(
size=18
),
showarrow=True,
arrowhead=5,
textangle=0,
xshift=-25,
yshift=10
)
fig.add_annotation(
x=instances[i], y=result_aco[i],
text=result_aco[i],
font=dict(
size=18
),
showarrow=True,
arrowhead=5,
textangle=0,
xshift=40,
yshift=10
)
fig.add_annotation(
x=instances[i], y=result_aco[i],
text=str(relative_error[i])+'%',
font=dict(
size=18
),
showarrow=False,
textangle=0,
xshift=40,
yshift=60
)
fig.update_layout(barmode='group', title_text="Benchmark")
# fig.update_xaxes(type='category')
fig.show()