forked from ameya005/AntColonyAlgorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadfiles.py
79 lines (71 loc) · 1.55 KB
/
readfiles.py
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
from numpy import *
import matplotlib.pyplot as plt
def cityReadSACO():
x,y=loadtxt('city_data.txt', unpack = True)
order=loadtxt('Data.txt')
print order
#print x
#print y
'''order1[]
x1[]
y1[]'''
x1=[]
y1=[]
for i in order:
x1.append(x[i])
y1.append(y[i])
x1.append(x[order[0]])
y1.append(y[order[0]])
plt.figure('S-ACO', (8,6), 80, 'w', 'k')
plt.plot(x1,y1, marker='x', linestyle = '--', color = 'r', label = 'S-ACO')
for i in range(len(order)):
plt.text(x1[i],y1[i],order[i])
plt.show()
def cityReadElitist():
x,y=loadtxt('city_data_elitist.txt', unpack = True)
order=loadtxt('Data_elitist.txt')
print order
#print x
#print y
'''order1[]
x1[]
y1[]'''
x1=[]
y1=[]
for i in order:
x1.append(x[i])
y1.append(y[i])
x1.append(x[order[0]])
y1.append(y[order[0]])
plt.figure('EAS', (8,6), 80, 'w', 'k')
plt.plot(x1,y1, marker='x', linestyle = '--', color = 'r',label = 'EAS')
for i in range(len(order)):
plt.text(x1[i],y1[i],order[i])
plt.show()
def cityReadRank():
x,y=loadtxt('city_data_rank.txt', unpack = True)
order=loadtxt('Data_rank.txt')
print order
#print x
#print y
'''order1[]
x1[]
y1[]'''
x1=[]
y1=[]
for i in order:
x1.append(x[i])
y1.append(y[i])
x1.append(x[order[0]])
y1.append(y[order[0]])
plt.figure('Rank-Based ACO', (8,6), 80, 'w', 'k')
plt.plot(x1,y1, marker='x', linestyle = '--', color = 'r',label = 'Rank')
for i in range(len(order)):
plt.text(x1[i],y1[i],order[i])
plt.show()
def main():
cityReadSACO()
cityReadElitist()
cityReadRank()
if __name__=="__main__":
main()