-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_results.py
183 lines (132 loc) · 12.4 KB
/
test_results.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
grid = [[[1130.755279682751, 6676.981332246904, 7890.079382628768, 7917.677238337503, 10253.144854951932, 4.847262980299326, 678.7216301783369, 1549.939696277959, 4527.522253545208, 6464.058043168986],
[232.22565206367926, 6923.306364067486, 7227.893895858005, 6846.9776929211, 7046.73054102472, 1.827462026221244, 675.7605227724641, 11727.921360695911, 7252.268375206502, 9298.277350777147],
[23.924166204240613, 1773.592262665069, 2525.521449152465, 3030.9347302559286, 3179.516468221822, 1.481240239649802, 675.4448597519705, 685.8545269355819, 760.5293207906233, 4509.906145526914]],
[[1628.3454193695684, 6743.563166624639, 8042.256309382977, 7929.882572896056, 9057.586977167377, 5.019868154938581, 678.921207623216, 2890.4516946841627, 2610.4351679674864, 5246.164447011638],
[217.54985826759585, 6950.86037748659, 7125.900928636026, 6658.690655397184, 6823.290162555515, 1.8775155815736575, 675.808270541813, 8335.69989561422, 5334.901022249365, 8698.96068039143],
[321.931474649709, 1865.7694297365954, 2287.919705908505, 2745.315782981442, 3542.098617341364, 1.517484921346052, 675.4801284334728, 682.2993861547089, 2784.151596976207, 4787.067255517842]],
[[1020.155,8204.015, 8740.887650845132, 7554.627977001681, 6295.4814708986805, 1.4410463346994242, 745.3000299732114, 1319.9394676662143, 4035.7975960340304, 7310.897458966548],
[524.4626364959212, 7366.29376341635, 6453.656661597721, 5688.174450030997, 6503.113643484944, 1.370460956584858, 4473.938464737073, 11593.157774571788, 7024.80343766874, 9129.563418751806],
[27.242196154969037, 1785.6371912587147, 1845.1504029715456, 2630.4519448611845, 2768.796535474176, 1.1480437455835935, 675.1191479652346, 681.1508692634627, 899.1932464056518, 4402.540009564652]],
[[2137.378, 5516.273, 7449.856, 6512.326, 6824.505, 1.5365443334646498, 1131.6997596667904, 2226.444188165692, 2232.4406415337967, 5015.982947078345],
[211.53779595038293, 6996.753067775921, 6883.582173882352, 6689.9366489986005, 6995.646700623478, 1.36033144774294, 7528.550940102761, 7183.3012667838, 7180.3100661257995, 9118.169307628099],
[10.086101640029163, 1874.7905278553421, 2571.1908090842844, 3132.216956646232, 2914.972935782436, 1.1910887725958812, 2543.8880442845098, 4048.5258049741415, 3965.0851361262958, 4927.995647458799]]]
'''
[[803.7009341381281, 8294.747123125038, 7247.727971114401, 5313.492871187902, 9439.560475794082, 1.5040675704452973, 8697.311905325547, 1324.407084394447, 6958.722607386834, 8307.00222723254],
[258.428466011763, 7372.8930535433055, 7140.485658755027, 7953.630257679028, 6405.7871543736, 1.3472316694755464, 2755.718967656235, 11870.818640627724, 7057.644444867685, 9223.548657965752],
[101.11655442807272, 1774.753366049067, 2198.6678313602815, 3834.649708436663, 3189.457903110181, 1.1539193908537992, 2126.1261742728343, 1350.8375308433456, 3273.0240346986975, 4835.122481726992]],
[[2194.302997707028, 9650.79680640918, 6231.316557009318, 8052.234989992859, 9998.498005877123, 1.4327541693943036, 788.9029984939262, 1161.4619357231188, 6824.515351789597, 4658.637095575192],
[309.25288103511565, 6384.886090003497, 3033.1694568131666, 5676.7140960947645, 6479.100719881973, 1.3057865651017497, 6460.478640186995, 1714.11701942195, 7258.533248476971, 6032.849203969458],
[38.774946958760005, 2606.4514304664376, 2187.005323322947, 3338.3456097441795, 3443.8923173803782, 1.166322181260059, 675.1442954186446, 682.9416703199781, 970.5395358690366, 4749.987378760696]],
[[881.261116959817, 6448.983754260241, 6372.209103298402, 7546.474803967, 8101.384705081776, 1.5428467414364782, 1134.1507546376906, 1642.7743967830643, 2407.0065535197127, 4928.238053039521],
[207.49795213565878, 6697.9027502149265, 7115.860641240037, 7172.9492777590685, 6153.588097467912, 1.3600752978585087, 7498.659253205519, 6038.6374887064, 7012.811717561003, 9680.475266935498],
[34.421975629522834, 2582.3421986789194, 2520.9631735915696, 2622.612493357959, 3107.6479241583, 1.1613429463961848, 675.1296283159097, 681.6816105394029, 2974.0036130728313, 2688.9072666180673]]]
'''
random =[[[430.9331314871008, 7162.587955641722, 7546.306700819813, 9112.293335700002, 9597.852527795723, 1.6829398792245396, 675.7990524534708, 6175.970094514803, 7712.432846684358, 9687.840307704128],
[322.6772620195781, 5317.968898738356, 5717.546349213798, 7097.634009803454, 7405.799169342125, 1.623996776764519, 675.8938168014092, 726.5357818892085, 1134.1800778418842, 3662.105569148319],
[41.11246018963621, 3680.2857579252445, 4067.5954850387266, 3551.4827292521327, 3474.6603541792056, 1.2726719942911169, 833.9327570516352, 1049.942559461636, 1278.4702003227746, 3224.499788982129]],
[[287.8792042075059, 7045.481008729393, 7197.856417652286, 10295.30525420888, 10802.24499957827, 1.7264423747519717, 1287.3135289428224, 3586.6161511639575, 6208.065695905274, 8544.505538305953],
[255.27616161584973, 5173.175513110503, 5555.651889200124, 7081.868417736729, 7109.690033195593, 1.675058368270285, 675.8827743238011, 720.0794722504852, 1123.6339461223877, 3604.5966463984487],
[40.8283297915579, 3585.405785783519, 4186.330862616664, 3422.6575249614066, 3450.735554209936, 1.3219572477933004, 831.7244493114263, 1047.300361682034, 1275.9047816166085, 3240.891644545296]],
[[652.1184708021846, 7561.112547782965, 10007.803379183424, 7829.4139568900855, 9173.020770246745, 1.5192515451979887, 675.4651757401367, 1532.3729205043423, 1872.0712407571168, 11169.545197970434],
[300.8139757470386, 6115.709627156104, 7400.724172952202, 6244.3962257527455, 7466.36832338621, 1.2953002676984258, 675.4382306639911, 735.7976085912954, 2386.069252946946, 4212.712036196951],
[41.70747624252311, 2969.3486129333955, 4670.644468982763, 3411.055092261553, 3334.225536706905, 1.0966069558466787, 841.3430041568785, 1039.0236015336059, 1280.638048588408, 3315.3947168391173]],
[[1525.161745506005, 6836.937736771603, 7079.436915473506, 9806.710853399594, 8057.21139738348, 1.5623568118788267, 1280.8203796981588, 4339.223273150263, 4954.369249150966, 11699.113241288325],
[243.00839089768672, 5878.091436951967, 6224.0664194665, 7322.262046182249, 7556.000452462389, 1.3202578576055095, 675.4671710276954, 1284.3667867341871, 1100.009175081917, 3797.4216897607544],
[29.12751612330918, 3697.5354696087593, 4633.038962449761, 3006.328720446133, 3852.4536148243997, 1.1206142877028495, 833.9714588196093, 1047.5196061250685, 1321.362924811747, 3197.651298340571]]]
'''
[[430.93319916973064, 7162.587938337505, 7546.306700966829, 9112.293342882169, 9597.852522440076, 1.6828090345406426, 675.79835854781, 6175.970085295589, 7712.432846359221, 9687.840307714452],
[322.67722148256024, 5317.968900553151, 5717.546333418812, 7097.634009801954, 7405.7991600785645, 1.6238610651498404, 675.8936622676271, 726.5357824308749, 1134.1800813745745, 3662.1055674234954],
[41.11244989917734, 3680.285754709583, 4067.595487210929, 3551.482728013096, 3474.6603568908617, 1.272671996174675, 834.1553973540682, 1049.9425597130642, 1278.4701991640707, 3224.4997899745026]]
[[1581.3776232000675, 8089.19953300921, 9892.838138765024, 9059.97801850508, 11187.465259643506, 1.4973538431309104, 675.6864150506283, 2712.461831601708, 2104.826269342748, 6215.147664640666],
[398.21516696450715, 4182.959872990307, 3971.3362978722466, 5619.804504256841, 4392.826285550426, 1.312228436004681, 675.4582107761634, 714.9356450299312, 1128.2170771988613, 3683.645501990599],
[50.48109453463188, 3764.9699178322835, 3861.6821550798427, 3035.662108139929, 3432.7259225954085, 1.1172693644791765, 838.9414037204962, 1052.149692194985, 1217.6265768674223, 3386.788998151131]],
[[322.93901400381924, 7110.47910302476, 9968.165928422319, 10327.841348379206, 10511.954857113245, 1.4862701504662845, 882.3314905362464, 10401.852722405922, 2162.2218275405917, 12773.686252496433],
[200.09519782965396, 6273.686251893799, 5369.854407230191, 5911.9735197039845, 5379.816722855708, 1.36282385684365, 675.4923500547956, 731.1074067571179, 1321.7233224154597, 4053.497127372298],
[21.02367171695889, 3376.5425802993077, 2844.1834591717643, 4018.3917978050963, 3672.5406275659125, 1.124255056719984, 835.9216707445353, 1045.5119397760254, 1229.260734414876, 3216.394328117956]],
[[2106.793350222884, 8115.423135264296, 8796.634287649382, 8578.74806089716, 9920.486344546762, 1.558051057561849, 1548.0409485629978, 4454.123716052267, 9997.066590248092, 7509.35296233786],
[233.36935172409449, 5958.504305398818, 6168.132667410716, 7492.353693540984, 7451.039291893291, 1.2899865396666939, 675.4730769818793, 715.5763370304958, 1349.1075623706747, 3791.8673637340653],
[38.577077762813836, 3631.292654019218, 3822.821540066237, 3437.1651598004155, 3544.6950998695925, 1.1272619938099058, 836.4739911140872, 1048.1881009863523, 1193.4871335155137, 3145.7918348849757]]]
'''
def average(x):
from statistics import mean
for i in x:
print(mean(i[0]), mean(i[1]), mean(i[2]))
def winning_cases(x):
res = [[0,0,0,0],[0,0,0,0],[0,0,0,0]]
for j in range(3):
for i in range(10):
z = [x[0][j][i],x[1][j][i],x[2][j][i],x[3][j][i]]
res[j][z.index(min(z))] += 1
print(res[j])
def losing_cases(x):
res = [[0,0,0,0],[0,0,0,0],[0,0,0,0]]
for j in range(3):
for i in range(10):
z = [x[0][j][i],x[1][j][i],x[2][j][i],x[3][j][i]]
res[j][z.index(max(z))] += 1
print(res[j])
def compare_two(mode,x,y):
res = [[0,0],[0,0],[0,0]]
for j in range(3):
for i in range(10):
z = [mode[x][j][i],mode[y][j][i]]
res[j][z.index(min(z))] += 1
return res
def print_two(mode,x,y):
for i in range(3):
for j in range(10):
print(mode[x][i][j])
print(mode[y][i][j])
print()
print()
print("next line")
print()
def print_for_latex(mode, algo):
n_algo = algo
if algo == 0:
algo = 'Standard Grid Search'
elif algo == 1:
algo = 'Normal Local Search'
elif algo == 2:
algo = 'Multimodal'
else:
algo = 'Multimodal + Normal Local Search'
if mode == 'grid':
mode = 'Grid'
values = grid
else:
mode = 'Random'
values = random
print("\\begin{table}[h!]\n\\begin{center}\n\\caption{",algo, "-",mode,"}\n\\label{tab:table1}\n\\begin{tabular}{l|l|c|r}\n\\textbf{Function} & \\textbf{N = 4} & \\textbf{7} & \\textbf{10}\\\\\n\\hline")
for i in range(10):
print(str(i+1) + " & " + str(round(values[n_algo][0][i],2)) + " & " + str(round(values[n_algo][1][i],2)) + " & " + str(round(values[n_algo][2][i],2)) + "\\\\")
print("\\end{tabular}\n\\end{center}\n\\end{table}")
def print_comparison(mode):
if mode == 'grid':
mode = 'Grid'
values = grid
else:
mode = 'Random'
values = random
print("\\begin{table}[h!]\n\\begin{center}\n\\caption{",mode," Comparisons}\n\\label{tab:table1}\n\\begin{tabular}{c|c|c|c|c}\n X & \textbf{Grid} & \\textbf{Local Search} & \\textbf{Multimodal} & \\textbf{Multimodal + Local Search}\\\\\n\\hline")
for i in range(3):
val = []
for j in range(i+1,4):
if j < 3:
val.extend([str(compare_two(grid,i,j))])
val.extend("&")
else:
val.extend([str(compare_two(grid,i,j))])
val.extend("\\\\")
algo = i
if algo == 0:
algo = 'Grid'
elif algo == 1:
algo = 'Local Search'
elif algo == 2:
algo = 'Multimodal'
else:
algo = 'Multimodal + Local Search'
print(algo + " & " + (i+1)*('xxxx' + " & ") + str([str(compare_two(random,i,j)) + " & " for j in range(i+1,4)]) + "\\\\")
print('Multimodal + Local Search & xxxx & xxxx & xxxx & xxxx \\\\')
print("\\end{tabular}\n\\end{center}\n\\end{table}")