beecolpy 2.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- beecolpy/__init__.py +2 -0
- beecolpy/beecolpy.py +1078 -0
- beecolpy/tests/__init__.py +0 -0
- beecolpy/tests/test_beecolpy.py +423 -0
- beecolpy-2.3.3.dist-info/METADATA +548 -0
- beecolpy-2.3.3.dist-info/RECORD +9 -0
- beecolpy-2.3.3.dist-info/WHEEL +5 -0
- beecolpy-2.3.3.dist-info/licenses/LICENSE.md +21 -0
- beecolpy-2.3.3.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
from beecolpy import *
|
|
3
|
+
|
|
4
|
+
from copy import deepcopy
|
|
5
|
+
import math as mt
|
|
6
|
+
import numpy as np
|
|
7
|
+
import numpy.testing as npt
|
|
8
|
+
|
|
9
|
+
def sphere(x): #Continuous and NaN benchmark
|
|
10
|
+
#Sphere function
|
|
11
|
+
#Min: x=(0,0)
|
|
12
|
+
total = 0
|
|
13
|
+
test = 0
|
|
14
|
+
for i in range(len(x)):
|
|
15
|
+
total += x[i]**2
|
|
16
|
+
test += x[i]
|
|
17
|
+
if (test<5):
|
|
18
|
+
return total
|
|
19
|
+
else:
|
|
20
|
+
return np.nan
|
|
21
|
+
|
|
22
|
+
def translate_bin(b):
|
|
23
|
+
return np.sum([(b[::-1][i])*mt.pow(2,i) for i in range(len(b))])
|
|
24
|
+
|
|
25
|
+
def squared_bin(b):
|
|
26
|
+
#y=(x-1)*(x-3)*(x-11)
|
|
27
|
+
#y = x^3 - 15 x^2 + 47 x - 33
|
|
28
|
+
#Min: x=0 b=[0000 0000] (Local)
|
|
29
|
+
# x=8.055 b~[0000 1000] (Global)
|
|
30
|
+
#NaN: x>128 b>[0111 1111]
|
|
31
|
+
x = translate_bin(b)
|
|
32
|
+
if (x > 128):
|
|
33
|
+
return np.nan
|
|
34
|
+
else:
|
|
35
|
+
return mt.pow(x,3) - 15*mt.pow(x,2) + 47*(x) - 33
|
|
36
|
+
|
|
37
|
+
base_abc_obj = abc(function=sphere,
|
|
38
|
+
boundaries=[(-10,10) for _ in range(2)],
|
|
39
|
+
colony_size=10,
|
|
40
|
+
scouts=0.5,
|
|
41
|
+
iterations=10,
|
|
42
|
+
min_max='min',
|
|
43
|
+
nan_protection=True,
|
|
44
|
+
log_agents=True,
|
|
45
|
+
seed=42)
|
|
46
|
+
|
|
47
|
+
base_bin_abc_obj = bin_abc(function=squared_bin,
|
|
48
|
+
bits_count=4,
|
|
49
|
+
transfer_function='sigmoid',
|
|
50
|
+
colony_size=10,
|
|
51
|
+
scouts=0.5,
|
|
52
|
+
iterations=10,
|
|
53
|
+
min_max='min',
|
|
54
|
+
method='bin',
|
|
55
|
+
result_format='best',
|
|
56
|
+
nan_protection=3,
|
|
57
|
+
log_agents=True,
|
|
58
|
+
seed=42)
|
|
59
|
+
|
|
60
|
+
base_am_abc_obj = bin_abc(function=squared_bin,
|
|
61
|
+
bits_count=4,
|
|
62
|
+
colony_size=10,
|
|
63
|
+
scouts=0.5,
|
|
64
|
+
iterations=10,
|
|
65
|
+
min_max='min',
|
|
66
|
+
method='am',
|
|
67
|
+
nan_protection=True,
|
|
68
|
+
log_agents=True,
|
|
69
|
+
seed=42)
|
|
70
|
+
|
|
71
|
+
average_nan_bin_abc_obj = bin_abc(function=squared_bin,
|
|
72
|
+
bits_count=8,
|
|
73
|
+
transfer_function='sigmoid',
|
|
74
|
+
colony_size=10,
|
|
75
|
+
scouts=0.5,
|
|
76
|
+
iterations=10,
|
|
77
|
+
min_max='min',
|
|
78
|
+
method='bin',
|
|
79
|
+
result_format='average',
|
|
80
|
+
nan_protection=3,
|
|
81
|
+
log_agents=True,
|
|
82
|
+
seed=42)
|
|
83
|
+
|
|
84
|
+
nan_bin_abc_obj = bin_abc(function=squared_bin,
|
|
85
|
+
bits_count=8,
|
|
86
|
+
transfer_function='sigmoid',
|
|
87
|
+
colony_size=60,
|
|
88
|
+
scouts=10,
|
|
89
|
+
iterations=30,
|
|
90
|
+
min_max='min',
|
|
91
|
+
method='bin',
|
|
92
|
+
result_format='average',
|
|
93
|
+
nan_protection=3,
|
|
94
|
+
log_agents=True,
|
|
95
|
+
seed=42)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def test_food_source_generation():
|
|
99
|
+
# Test algorithm initialization
|
|
100
|
+
global base_abc_obj
|
|
101
|
+
out = [food.position for food in base_abc_obj.foods]
|
|
102
|
+
ref = [[2.7885359691576745, -9.49978489554666],
|
|
103
|
+
[-4.499413632617615, -5.5357852370235445],
|
|
104
|
+
[7.843591354096908, -8.261223347411677],
|
|
105
|
+
[-1.561563606294591, -9.404055611238594],
|
|
106
|
+
[-5.627240503927933, 0.10710576206724731]]
|
|
107
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def test_fit_solution():
|
|
111
|
+
# Test solver capability
|
|
112
|
+
global base_abc_obj
|
|
113
|
+
abc_obj = deepcopy(base_abc_obj)
|
|
114
|
+
abc_obj.fit()
|
|
115
|
+
out = abc_obj.get_solution()
|
|
116
|
+
ref = [0.004621261711518124, -0.08296007192538377]
|
|
117
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_get_agents():
|
|
121
|
+
# Verifies the process step-by-step
|
|
122
|
+
global base_abc_obj
|
|
123
|
+
abc_obj = deepcopy(base_abc_obj)
|
|
124
|
+
abc_obj.fit()
|
|
125
|
+
out = abc_obj.get_agents()
|
|
126
|
+
ref = [[[2.7885359691576745, -9.49978489554666],
|
|
127
|
+
[-4.499413632617615, -5.5357852370235445],
|
|
128
|
+
[7.843591354096908, -8.261223347411677],
|
|
129
|
+
[-1.561563606294591, -9.404055611238594],
|
|
130
|
+
[-5.627240503927933, 0.10710576206724731]],
|
|
131
|
+
[[2.7885359691576745, -8.233291099602813],
|
|
132
|
+
[1.5832471812626028, -5.5357852370235445],
|
|
133
|
+
[3.7358052227687066, -8.261223347411677],
|
|
134
|
+
[-1.2017059867618722, -9.404055611238594],
|
|
135
|
+
[-5.177686266266753, 0.10710576206724731]],
|
|
136
|
+
[[2.7885359691576745, -8.233291099602813],
|
|
137
|
+
[1.5832471812626028, -5.5357852370235445],
|
|
138
|
+
[3.07809973415758, -3.1160692355609463],
|
|
139
|
+
[-1.2017059867618722, -9.404055611238594],
|
|
140
|
+
[-0.626259589706855, 0.10710576206724731]],
|
|
141
|
+
[[2.7885359691576745, -5.5667304312754515],
|
|
142
|
+
[1.5832471812626028, -4.793940503704757],
|
|
143
|
+
[3.07809973415758, -3.1160692355609463],
|
|
144
|
+
[-1.2017059867618722, -9.404055611238594],
|
|
145
|
+
[-0.626259589706855, -0.08296007192538377]],
|
|
146
|
+
[[2.7885359691576745, -5.5667304312754515],
|
|
147
|
+
[1.5832471812626028, -4.793940503704757],
|
|
148
|
+
[3.07809973415758, -2.9972606160578668],
|
|
149
|
+
[-1.2017059867618722, -2.33874341261713],
|
|
150
|
+
[0.004621261711518124, -0.08296007192538377]],
|
|
151
|
+
[[2.7885359691576745, -5.5667304312754515],
|
|
152
|
+
[1.5832471812626028, -1.4037521889161138],
|
|
153
|
+
[3.07809973415758, -2.8781556401746196],
|
|
154
|
+
[-0.23585290985708707, -0.35015979771326466],
|
|
155
|
+
[0.004621261711518124, -0.08296007192538377]],
|
|
156
|
+
[[2.7885359691576745, -5.5667304312754515],
|
|
157
|
+
[0.18420441941726584, -1.4037521889161138],
|
|
158
|
+
[3.07809973415758, -2.8781556401746196],
|
|
159
|
+
[-0.23585290985708707, -0.35015979771326466],
|
|
160
|
+
[7.585404849690857, -2.609458225222321]],
|
|
161
|
+
[[2.7885359691576745, -0.8101232115728161],
|
|
162
|
+
[0.18420441941726584, -1.4037521889161138],
|
|
163
|
+
[3.07809973415758, -2.8781556401746196],
|
|
164
|
+
[9.443925300345207, -9.202102437775636],
|
|
165
|
+
[5.401373297801247, -2.609458225222321]],
|
|
166
|
+
[[2.683096137661125, -0.8101232115728161],
|
|
167
|
+
[-6.4286436765507275, 9.25068631523111],
|
|
168
|
+
[-2.3425767195845317, -2.262486375815069],
|
|
169
|
+
[9.443925300345207, -4.543441485273379],
|
|
170
|
+
[5.401373297801247, -1.4635223212335464]],
|
|
171
|
+
[[-1.2529852411980031, -0.019504875840150926],
|
|
172
|
+
[-6.4286436765507275, 9.25068631523111],
|
|
173
|
+
[0.36371179397453135, -2.262486375815069],
|
|
174
|
+
[6.465646902426063, -4.543441485273379],
|
|
175
|
+
[5.319323057174841, -1.4635223212335464]],
|
|
176
|
+
[[-0.5647328495432691, -0.019504875840150926],
|
|
177
|
+
[-6.4286436765507275, 9.25068631523111],
|
|
178
|
+
[0.36371179397453135, -1.6127483532703213],
|
|
179
|
+
[6.465646902426063, -4.543441485273379],
|
|
180
|
+
[5.319323057174841, -1.4635223212335464]]]
|
|
181
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def test_get_status():
|
|
185
|
+
# Test exploration and NaN protection
|
|
186
|
+
global base_abc_obj
|
|
187
|
+
abc_obj = deepcopy(base_abc_obj)
|
|
188
|
+
abc_obj.fit()
|
|
189
|
+
out = abc_obj.get_status()
|
|
190
|
+
ref = (10, 3, 3)
|
|
191
|
+
npt.assert_array_equal(out, ref)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def test_bin_food_source_generation():
|
|
195
|
+
# Test algorithm initialization
|
|
196
|
+
global base_bin_abc_obj
|
|
197
|
+
out = [food.position for food in base_bin_abc_obj._bin_abc_object.foods]
|
|
198
|
+
ref = [[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
199
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
200
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
201
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
202
|
+
[0.7245618290940143, 9.462315279587411, -2.42931245583293, 1.0408126254645396]]
|
|
203
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_bin_fit_best_solution():
|
|
207
|
+
# Test solver capability
|
|
208
|
+
global base_bin_abc_obj
|
|
209
|
+
bin_abc_obj = deepcopy(base_bin_abc_obj)
|
|
210
|
+
bin_abc_obj.fit()
|
|
211
|
+
out = bin_abc_obj.get_solution()
|
|
212
|
+
ref = [True, False, False, False]
|
|
213
|
+
npt.assert_array_equal(out, ref)
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def test_bin_fit_average_solution():
|
|
217
|
+
# Test solver capability
|
|
218
|
+
global average_nan_bin_abc_obj
|
|
219
|
+
bin_abc_obj = deepcopy(average_nan_bin_abc_obj)
|
|
220
|
+
bin_abc_obj.fit()
|
|
221
|
+
out = bin_abc_obj.get_solution()
|
|
222
|
+
ref = [False, False, False, False, True, False, False, False]
|
|
223
|
+
npt.assert_array_equal(out, ref)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def test_bin_fit_average_probability():
|
|
227
|
+
# Test solver capability
|
|
228
|
+
global average_nan_bin_abc_obj
|
|
229
|
+
bin_abc_obj = deepcopy(average_nan_bin_abc_obj)
|
|
230
|
+
bin_abc_obj.fit()
|
|
231
|
+
out = bin_abc_obj.get_solution(probability_vector = True)
|
|
232
|
+
ref = [0.7310473617198062,
|
|
233
|
+
0.014879869353197546,
|
|
234
|
+
0.017970912760133604,
|
|
235
|
+
0.0010584454334110485,
|
|
236
|
+
0.985098442266522,
|
|
237
|
+
0.19047384206718057,
|
|
238
|
+
0.0014741775024230605,
|
|
239
|
+
0.05895833890958545]
|
|
240
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def test_bin_nan_protection():
|
|
244
|
+
# Test NaN protection in BABC
|
|
245
|
+
global nan_bin_abc_obj
|
|
246
|
+
bin_abc_obj = deepcopy(nan_bin_abc_obj)
|
|
247
|
+
bin_abc_obj.fit()
|
|
248
|
+
out1 = bin_abc_obj.get_status()
|
|
249
|
+
out2 = bin_abc_obj.get_solution(probability_vector = False)
|
|
250
|
+
ref1 = (30, 28, 36)
|
|
251
|
+
ref2 = [False, False, False, False, True, False, False, False]
|
|
252
|
+
npt.assert_array_equal(out1, ref1)
|
|
253
|
+
npt.assert_array_equal(out2, ref2)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def test_bin_get_agents():
|
|
257
|
+
# Verifies the process step-by-step
|
|
258
|
+
global base_bin_abc_obj
|
|
259
|
+
bin_abc_obj = deepcopy(base_bin_abc_obj)
|
|
260
|
+
bin_abc_obj.fit()
|
|
261
|
+
out = bin_abc_obj.get_agents()
|
|
262
|
+
ref = [[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
263
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
264
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
265
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
266
|
+
[0.7245618290940143, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
267
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
268
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
269
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
270
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
271
|
+
[0.7245618290940143, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
272
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
273
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
274
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
275
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
276
|
+
[0.7245618290940143, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
277
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
278
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
279
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
280
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
281
|
+
[0.7245618290940143, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
282
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
283
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
284
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
285
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
286
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
287
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
288
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
289
|
+
[-5.591187559186066, 1.7853136775181753, 6.1886091335565325, -9.87002480643878],
|
|
290
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
291
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
292
|
+
[[2.7885359691576745, -9.49978489554666, -4.499413632617615, -5.5357852370235445],
|
|
293
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
294
|
+
[-5.310128439707293, -3.2830492675737215, 7.860536655806335, -8.38844684684663],
|
|
295
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
296
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
297
|
+
[[-7.838025006847868, -9.48643149005068, -3.7608551121060962, 3.5469457370081763],
|
|
298
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
299
|
+
[-5.310128439707293, -3.2830492675737215, 7.860536655806335, -8.38844684684663],
|
|
300
|
+
[9.144261444135623, -3.2681090977474643, -8.145083132397042, -8.06567246333072],
|
|
301
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
302
|
+
[[-7.838025006847868, -9.48643149005068, -3.7608551121060962, 3.5469457370081763],
|
|
303
|
+
[-1.561563606294591, -9.404055611238594, -5.627240503927933, 0.10710576206724731],
|
|
304
|
+
[-5.310128439707293, -3.2830492675737215, 7.860536655806335, -8.38844684684663],
|
|
305
|
+
[-4.470007460626215, 1.7917381192158182, 5.204157907461653, 1.9358148102460344],
|
|
306
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
307
|
+
[[-7.838025006847868, -9.48643149005068, -3.7608551121060962, 3.5469457370081763],
|
|
308
|
+
[-1.2448227285680407, 1.9607332408220728, 7.788457785849072, 4.690678465712306],
|
|
309
|
+
[-5.310128439707293, -3.2830492675737215, 7.860536655806335, -8.38844684684663],
|
|
310
|
+
[-4.470007460626215, 1.7917381192158182, 5.204157907461653, 1.9358148102460344],
|
|
311
|
+
[0.8967570342570317, 9.462315279587411, -2.42931245583293, 1.0408126254645396]],
|
|
312
|
+
[[-7.838025006847868, -9.48643149005068, -3.7608551121060962, 3.5469457370081763],
|
|
313
|
+
[-1.2448227285680407, 1.9607332408220728, 7.788457785849072, 4.690678465712306],
|
|
314
|
+
[-5.310128439707293, -3.2830492675737215, 7.860536655806335, -8.38844684684663],
|
|
315
|
+
[-4.470007460626215, 1.7917381192158182, 5.204157907461653, 1.9358148102460344],
|
|
316
|
+
[-4.343220334343467, -4.028883004564657, 1.7387544482832222, 9.978046664586774]]]
|
|
317
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def test_bin_get_status():
|
|
321
|
+
# Test exploration
|
|
322
|
+
global base_bin_abc_obj
|
|
323
|
+
bin_abc_obj = deepcopy(base_bin_abc_obj)
|
|
324
|
+
bin_abc_obj.fit()
|
|
325
|
+
out = bin_abc_obj.get_status()
|
|
326
|
+
ref = (10, 5, 0)
|
|
327
|
+
npt.assert_array_equal(out, ref)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def test_am_food_source_generation():
|
|
331
|
+
# Test algorithm initialization
|
|
332
|
+
global base_am_abc_obj
|
|
333
|
+
out = [food.position for food in base_am_abc_obj._bin_abc_object.foods]
|
|
334
|
+
ref = [[0.557707193831535, -1.8999569791093323, -0.899882726523523, -1.107157047404709],
|
|
335
|
+
[0.9458848566560496, 0.7067979496916452, 1.5687182708193816, -1.6522446694823354],
|
|
336
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
337
|
+
[-1.8938561212645455, -1.204649397253406, 0.5995377511180928, 0.1797659224128667],
|
|
338
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]]
|
|
339
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_am_fit_solution():
|
|
343
|
+
# Test solver capability
|
|
344
|
+
global base_am_abc_obj
|
|
345
|
+
am_abc_obj = deepcopy(base_am_abc_obj)
|
|
346
|
+
am_abc_obj.fit()
|
|
347
|
+
out = am_abc_obj.get_solution()
|
|
348
|
+
ref = [True, False, False, False]
|
|
349
|
+
npt.assert_array_equal(out, ref)
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def test_am_get_agents():
|
|
353
|
+
# Verifies the process step-by-step
|
|
354
|
+
global base_am_abc_obj
|
|
355
|
+
am_abc_obj = deepcopy(base_am_abc_obj)
|
|
356
|
+
am_abc_obj.fit()
|
|
357
|
+
out = am_abc_obj.get_agents()
|
|
358
|
+
ref = [[[0.557707193831535, -1.8999569791093323, -0.899882726523523, -1.107157047404709],
|
|
359
|
+
[0.9458848566560496, 0.7067979496916452, 1.5687182708193816, -1.6522446694823354],
|
|
360
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
361
|
+
[-1.8938561212645455, -1.204649397253406, 0.5995377511180928, 0.1797659224128667],
|
|
362
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]],
|
|
363
|
+
[[0.557707193831535, -1.8893582439328636, -0.899882726523523, -1.107157047404709],
|
|
364
|
+
[1.0161392006272225, 0.7067979496916452, 1.5687182708193816, -1.6522446694823354],
|
|
365
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
366
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.1797659224128667],
|
|
367
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]],
|
|
368
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.107157047404709],
|
|
369
|
+
[1.0161392006272225, 0.7067979496916452, 1.5687182708193816, -1.6522446694823354],
|
|
370
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
371
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
372
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]],
|
|
373
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.107157047404709],
|
|
374
|
+
[1.0161392006272225, 0.7067979496916452, 1.5687182708193816, -1.6522446694823354],
|
|
375
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
376
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
377
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]],
|
|
378
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.7642204917687523],
|
|
379
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -1.7645049324947064],
|
|
380
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
381
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
382
|
+
[-1.1182375118372132, 0.3570627355036349, 1.2377218267113066, -1.974004961287756]],
|
|
383
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.7642204917687523],
|
|
384
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -0.7438010528471708],
|
|
385
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
386
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
387
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]],
|
|
388
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.7642204917687523],
|
|
389
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -0.7438010528471708],
|
|
390
|
+
[-0.3123127212589183, -1.8808111222477186, -1.1254481007855865, 0.02142115241344955],
|
|
391
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
392
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]],
|
|
393
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.7642204917687523],
|
|
394
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -0.7438010528471708],
|
|
395
|
+
[-0.3123127212589183, -1.8808111222477186, -0.10276323247356367, 0.02142115241344955],
|
|
396
|
+
[-2, -1.204649397253406, 0.5995377511180928, 0.3057522684219449],
|
|
397
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]],
|
|
398
|
+
[[0.557707193831535, -1.8893582439328636, 0.3286988892938725, -1.7642204917687523],
|
|
399
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -0.7438010528471708],
|
|
400
|
+
[-0.3123127212589183, -1.8808111222477186, -0.10276323247356367, 0.02142115241344955],
|
|
401
|
+
[-0.5852854615415266, 0.23953407657547876, 1.4988508941643648, 1.895348090549156],
|
|
402
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]],
|
|
403
|
+
[[-0.617251553280799, 1.1457127128147278, -0.25442446451756817, 1.9369433972663597],
|
|
404
|
+
[0.3537604576414042, -1.9712366440596258, 0.8313637861938163, -0.7438010528471708],
|
|
405
|
+
[-0.3123127212589183, -1.8808111222477186, -0.10276323247356367, 0.02142115241344955],
|
|
406
|
+
[-0.5852854615415266, 0.23953407657547876, 1.4988508941643648, 1.895348090549156],
|
|
407
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]],
|
|
408
|
+
[[-0.617251553280799, 1.1457127128147278, -0.25442446451756817, 1.9369433972663597],
|
|
409
|
+
[0.044695987498348355, 1.174941596424008, 1.839328014732145, 0.9438457837608869],
|
|
410
|
+
[-0.3123127212589183, -1.8808111222477186, -0.10276323247356367, 0.02142115241344955],
|
|
411
|
+
[-0.5852854615415266, 0.23953407657547876, 1.4988508941643648, 1.895348090549156],
|
|
412
|
+
[-1.1182375118372132, 0.3570627355036349, 1.140180015064122, -1.974004961287756]]]
|
|
413
|
+
npt.assert_array_almost_equal(out, ref, decimal=6)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_am_get_status():
|
|
417
|
+
# Test exploration
|
|
418
|
+
global base_am_abc_obj
|
|
419
|
+
am_abc_obj = deepcopy(base_am_abc_obj)
|
|
420
|
+
am_abc_obj.fit()
|
|
421
|
+
out = am_abc_obj.get_status()
|
|
422
|
+
ref = (10, 4, 0)
|
|
423
|
+
npt.assert_array_almost_equal(out, ref)
|