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.
@@ -0,0 +1,548 @@
1
+ Metadata-Version: 2.4
2
+ Name: beecolpy
3
+ Version: 2.3.3
4
+ Summary: Artificial Bee Colony solver
5
+ Home-page: https://github.com/renard162/BeeColPy
6
+ Author: Samuel Carlos Pessoa Oliveira
7
+ Author-email: samuelcpoliveira@gmail.com
8
+ License: MIT
9
+ Keywords: PSO,ABC,Bee,Colony,Binary,Angle Modulated,Solver,Optimize,metaheuristic
10
+ Classifier: Development Status :: 7 - Inactive
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.0
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.md
17
+ Requires-Dist: numpy
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: keywords
25
+ Dynamic: license
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ **BeeColPy**
32
+ ============
33
+
34
+ > **Deprecation notice:** BeeColPy is deprecated and no longer actively
35
+ > maintained. Although the package remains stable and available,
36
+ > its development has been superseded by
37
+ > [Tyrannis Optimizer](https://pypi.org/project/tyrannis/),
38
+ > the successor to BeeColPy. All users are encouraged to migrate
39
+ > to Tyrannis Optimizer for continued development, new features,
40
+ > and broader optimization capabilities.
41
+
42
+ BeeColPy is a module for function optimization through artificial bee colony
43
+ algorithm, a method developed by Karaboga [1], a variant of classical
44
+ particle swarm optimization.
45
+
46
+
47
+
48
+ **Websites:**
49
+
50
+ > Source code: https://github.com/renard162/BeeColPy/
51
+ >
52
+ > Introduction: https://en.wikipedia.org/wiki/Artificial_bee_colony_algorithm
53
+ >
54
+
55
+
56
+
57
+ **Installation**
58
+ ------------
59
+
60
+ **Dependencies**
61
+
62
+ > BeeColPy requires:
63
+ >
64
+ > - Python (>= 3.0)
65
+ > - NumPy (>= 1.1.0)
66
+ >
67
+ > **BeeColPy do not support Python 2.7.**
68
+
69
+ **User installation**
70
+
71
+ ~~~~~~~~~~~~~~~~~
72
+ pip install beecolpy
73
+ ~~~~~~~~~~~~~~~~~
74
+
75
+
76
+
77
+ **Usage Instructions**
78
+ ----------
79
+
80
+ **For cost functions with continuous domain:**
81
+
82
+ ~~~~~~~~~~~~~~~~~python
83
+ #Step-by-step:
84
+ #Create object and set the solver parameters:
85
+ abc_obj = abc(function,
86
+ boundaries,
87
+ colony_size=40,
88
+ scouts=0.5,
89
+ iterations=50,
90
+ min_max='min',
91
+ nan_protection=True,
92
+ log_agents=True)
93
+
94
+ #Execute algorithm:
95
+ abc_obj.fit()
96
+
97
+ #Get solution obtained after fit() execution:
98
+ solution = abc_obj.get_solution()
99
+
100
+ """
101
+ Obs.: Each time fit() was executed, the algorithm iterate
102
+ 'iterations' times resuming from last fit() execution.
103
+ """
104
+
105
+ """
106
+ Parameters
107
+ ----------
108
+ function : Name
109
+ A name of a function to minimize/maximize.
110
+ Example: if the function is:
111
+ def my_func(x): return x[0]**2 + x[1]**2 + 5*x[1]
112
+
113
+ Use "my_func" as parameter.
114
+
115
+
116
+ boundaries : List of Tuples
117
+ A list of tuples containing the lower and upper boundaries of
118
+ each dimension of function domain.
119
+
120
+ Obs.: The number of boundaries determines the dimension of
121
+ function.
122
+
123
+ Example: A function F(x1, x2) = y with:
124
+ (-5 <= x1 <= 5) and (-20 <= x2 <= 20) have the boundaries:
125
+ [(-5,5), (-20,20)]
126
+
127
+
128
+ [colony_size] : Int --optional-- (default: 40)
129
+ A value that determines the number of bees in algorithm. Half
130
+ of this amount determines the number of points analyzed (food
131
+ sources).
132
+
133
+ According articles, half of this number determines the amount
134
+ of Employed bees and other half is Onlooker bees.
135
+
136
+
137
+ [scouts] : Float --optional-- (default: 0.5)
138
+ Determines the limit of tries for scout bee discard a food
139
+ source and replace for a new one.
140
+ - If scouts = 0 :
141
+ Scout_limit = colony_size * dimension
142
+
143
+ - If scouts = (0 to 1) :
144
+ Scout_limit = colony_size * dimension * scouts
145
+ Obs.: scouts = 0.5 is used in [3] as benchmark.
146
+
147
+ - If scouts >= 1 :
148
+ Scout_limit = scouts
149
+
150
+ Obs.: Scout_limit is rounded down in all cases.
151
+
152
+
153
+ [iterations] : Int --optional-- (default: 50)
154
+ The number of iterations executed by algorithm.
155
+
156
+
157
+ [min_max] : String --optional-- (default: 'min')
158
+ Determines if algorithm will minimize or maximize the function.
159
+ - If min_max = 'min' : (default)
160
+ Locate the minimum of function.
161
+
162
+ - If min_max = 'max' :
163
+ Locate the maximum of function.
164
+
165
+
166
+ [nan_protection] : Boolean --optional-- (default: True)
167
+ If true, re-generate food sources that get NaN value as cost
168
+ during initialization or during scout events. This option
169
+ usually helps the algorithm stability because, in rare cases,
170
+ NaN values can lock the algorithm in a infinite loop.
171
+
172
+ Obs.: NaN protection can drastically increases calculation
173
+ time if analysed function has too many values of domain
174
+ returning NaN.
175
+
176
+
177
+ [log_agents] : Boolean --optional-- (default: False)
178
+ If true, beecolpy will register, before each iteration, the
179
+ position of each food source. Useful to debug but, if there a
180
+ high amount of food sources and/or iterations, this option
181
+ drastically increases memory usage.
182
+
183
+
184
+ [seed] : Int --optional-- (default: None)
185
+ If defined as an int, set the seed used in all random process.
186
+
187
+
188
+ Methods
189
+ ----------
190
+ fit()
191
+ Execute the algorithm with defined parameters.
192
+
193
+ Obs.: Returns a list with values found as minimum/maximum
194
+ coordinate.
195
+
196
+
197
+ get_solution()
198
+ Returns the value obtained after fit() the method.
199
+
200
+
201
+ get_status()
202
+ Returns a tuple with:
203
+ - Number of complete iterations executed
204
+ - Number of scout events during iterations
205
+ - Number of times that NaN protection was activated
206
+
207
+
208
+ get_agents()
209
+ Returns a list with the position of each food source during
210
+ each iteration if "log_agents = True".
211
+
212
+ Parameters
213
+ ----------
214
+ [reset_agents] : bool --optional-- (default: False)
215
+ If true, the food source position log will be cleaned in
216
+ next fit().
217
+ """
218
+ ~~~~~~~~~~~~~~~~~
219
+
220
+
221
+
222
+ **For cost function with binary domain:**
223
+
224
+ ~~~~~~~~~~~~~~~~~python
225
+ #Step-by-step:
226
+ #Create object and set the solver parameters:
227
+ bin_abc_obj = bin_abc(function,
228
+ bits_count,
229
+ method='am',
230
+ colony_size=40,
231
+ scouts=0.5,
232
+ iterations=50,
233
+ best_model_iterations=0,
234
+ min_max='min',
235
+ nan_protection=True,
236
+ transfer_function='sigmoid',
237
+ best_model_iterations=0,
238
+ log_agents=True)
239
+
240
+ #Execute algorithm:
241
+ bin_abc_obj.fit()
242
+
243
+ #Get solution after execute fit() without execute it again:
244
+ solution = bin_abc_obj.get_solution()
245
+
246
+ """
247
+ Obs.: Each time fit() was executed, the algorithm iterate
248
+ 'iterations' times resuming from last fit() execution.
249
+ """
250
+
251
+ """
252
+ Parameters
253
+ ----------
254
+ function : Name
255
+ A name of a function to minimize/maximize.
256
+
257
+ Example: if the function is:
258
+ def my_func(x): return x[0] or (x[1] and x[2])
259
+
260
+ Use "my_func" as parameter.
261
+
262
+
263
+ -=x=--=x=--=x=--=x=--=x=-
264
+
265
+ Just one of these parameters are mandatory. If you don't know
266
+ exactly how binary solvers work, just inform the number of bits
267
+ (bits_count) and the default boundaries will be used. These
268
+ boundaries usually are enough to solve most problems.
269
+
270
+ bits_count : Int
271
+ The number of bits that compose the output vector.
272
+
273
+
274
+ boundaries : List of Tuples
275
+ A list of tuples containing the lower and upper boundaries
276
+ that will be applied over sigmoid or angle modulation function
277
+ to determine the probability to bit become 1.
278
+
279
+ Example: A function F(b1, b2) = y with:
280
+ (-5 <= b1 <= 5) and (-20 <= b2 <= 20) have the boundaries:
281
+ [(-5,5), (-20,20)]
282
+
283
+ Obs.:
284
+ - If boundaries are set:
285
+ boundaries take the priority over the bits_count.
286
+
287
+ - If boundaries are not set:
288
+ boundaries became (-2,2) to each bit in AMABC method or
289
+ (-10,10) to each bit in BABC method.
290
+
291
+ -=x=--=x=--=x=--=x=--=x=-
292
+
293
+
294
+ [method] : String --optional-- (default: 'am')
295
+ Select the applied solver:
296
+ - If method = 'am' : (default)
297
+ Applied Angle Modulated ABC (AMABC).
298
+
299
+ - If method = 'bin' :
300
+ Applied Binary ABC (BABC).
301
+
302
+
303
+ [colony_size] : Int --optional-- (default: 40)
304
+ A value that determines the number of bees in algorithm. Half
305
+ of this amount determines the number of points analyzed
306
+ (food sources).
307
+
308
+ According articles, half of this number determines the amount
309
+ of Employed bees and other half is Onlooker bees.
310
+
311
+
312
+ [scouts] : Float --optional-- (default: 0.5)
313
+ Determines the limit of tries for scout bee discard a food
314
+ source and replace for a new one.
315
+ - If scouts = 0 :
316
+ Scout_limit = colony_size * dimension
317
+
318
+ - If scouts = (0 to 1) :
319
+ Scout_limit = colony_size * dimension * scouts
320
+ Obs.: scouts = 0.5 is used in [3] as benchmark.
321
+
322
+ - If scouts >= 1 :
323
+ Scout_limit = scouts
324
+
325
+ Obs.1: Scout_limit is rounded down in all cases.
326
+
327
+ Obs.2: In Binary form, the scouts tends to be more relevant
328
+ than in continuous form. If your problem are badly solved,
329
+ try to reduce the scouts value.
330
+
331
+
332
+ [iterations] : Int --optional-- (default: 50)
333
+ The number of iterations executed by algorithm.
334
+
335
+
336
+ [min_max] : String --optional-- (default: 'min')
337
+ Determines if algorithm will minimize or maximize the function.
338
+ - If min_max = 'min' : (default)
339
+ Locate the minimum of function.
340
+
341
+ - If min_max = 'max' :
342
+ Locate the maximum of function.
343
+
344
+
345
+ [nan_protection] : Boolean or Int --optional--
346
+ (default (boolean): True)
347
+ With "method='am'", this variable are used as a boolean.
348
+
349
+ With "method='bin'", this variable determines the number of
350
+ times the function are recalculated when it returns a NaN.
351
+ (default (int): 3)
352
+
353
+ If true or greater than 0, re-generate food sources that get
354
+ NaN value as cost during initialization or during scout
355
+ events. This option usually helps the algorithm stability
356
+ because, in rare cases, NaN values can lock the algorithm in
357
+ a infinite loop.
358
+
359
+ Obs.: NaN protection can drastically increases calculation
360
+ time if analysed function has too many values of domain
361
+ returning NaN.
362
+
363
+
364
+ [transfer_function] : String --optional-- (default: 'sigmoid')
365
+ Only used with "method='bin'". Defines the transfer function
366
+ used to calculate the probability for each bit becomes '1'.
367
+
368
+ The possibilities are explained on article [6]:
369
+ - If transfer_function = 'sigmoid' : (default)
370
+ S(x) = 1/(1 + exp(-x))
371
+
372
+ - If transfer_function = 'sigmoid-2x' :
373
+ S(x) = 1/(1 + exp(-2*x))
374
+
375
+ - If transfer_function = 'sigmoid-x/2' :
376
+ S(x) = 1/(1 + exp(-x/2))
377
+
378
+ - If transfer_function = 'sigmoid-x/3' :
379
+ S(x) = 1/(1 + exp(-x/3))
380
+
381
+
382
+ [result_format] : String --optional-- (default: 'best')
383
+ Only used with "method='bin'". In a stochastic method, the
384
+ result vector are represented by a probability vector with
385
+ the probability of each bit becomes "True". This property
386
+ determines how output bit vector will be estimated.
387
+ - If result_format = 'average' :
388
+ Returns the most frequent bit vector after
389
+ "best_model_iterations" simulations of the probability
390
+ vector. This approach is ideal to solve problems with
391
+ highly random elements.
392
+ Obs.: To use this method efficiently, use high
393
+ values in "best_model_iterations". Usually values
394
+ greater than 100 have better results.
395
+
396
+ - If result_format = 'best' : (default)
397
+ Returns the best result after "best_model_iterations"
398
+ simulations of the probability vector. This approach is
399
+ useful to solve highly noisy problems.
400
+
401
+
402
+ [best_model_iterations] : int --optional--
403
+ (default: iterations count)
404
+ Only used with "method='bin'". Due stochastic aspect of
405
+ Binary form of particle based metaheuristic, after execution
406
+ of ABC, the cost function will be calculated
407
+ "best_model_iterations" times and the "best" or the "most
408
+ frequent" result will be returned.
409
+ - If best_model_iterations = 0 : (default)
410
+ Tries "iterations" times.
411
+
412
+ - If best_model_iterations = N :
413
+ Tries "N" times.
414
+
415
+ Obs.: If "best_model_iterations" (or "iterations") is even,
416
+ then "best_model_iterations" is increased by one.
417
+
418
+
419
+ [log_agents] : Boolean --optional-- (default: False)
420
+ If true, beecolpy will register, before each iteration, the
421
+ position of each food source. Useful to debug but, if there a
422
+ high amount of food sources and/or iterations, this option
423
+ drastically increases memory usage.
424
+
425
+
426
+ [seed] : Int --optional-- (default: None)
427
+ If defined as an int, set the seed used in all random process.
428
+
429
+
430
+ Methods
431
+ ----------
432
+ fit()
433
+ Execute the algorithm with defined parameters.
434
+
435
+ Obs.: Returns a list with values found as minimum/maximum
436
+ coordinate.
437
+
438
+
439
+ get_solution()
440
+ Returns the value obtained after fit() the method.
441
+
442
+ Parameters
443
+ ----------
444
+ [probability_vector] : bool --optional-- (default: False)
445
+ Only used with "method='bin'". Returns the vector with
446
+ probability of each bit becomes "True". Useful to use
447
+ probability as component of stopping criteria or to
448
+ evaluate solution stability.
449
+ - If probability_vector = True :
450
+ "get_solution" returns a vector with the
451
+ probability of each bit becomes "True".
452
+
453
+ - If probability_vector = False: (default)
454
+ "get_solution" returns the solution bit vector.
455
+
456
+
457
+ get_status()
458
+ Returns a tuple with:
459
+ - Number of complete iterations executed
460
+ - Number of scout events during iterations
461
+ - Number of times that NaN protection was activated
462
+
463
+
464
+ get_agents()
465
+ Returns a list with the position of each food source during
466
+ each iteration if "log_agents = True".
467
+
468
+ Obs.: In binary form, this method returns the position of
469
+ each food source after transformation "binary -> continuous".
470
+ I.e. returns the values applied on angle modulation function
471
+ in AMABC or the values applied on transfer function in BABC.
472
+
473
+ Parameters
474
+ ----------
475
+ [reset_agents] : bool --optional-- (default: False)
476
+ If true, the food source position log will be cleaned in
477
+ next fit().
478
+ """
479
+ ~~~~~~~~~~~~~~~~~
480
+
481
+
482
+
483
+ **Example**
484
+ ----------
485
+
486
+ ~~~~~~~~~~~~~~~~~python
487
+ """
488
+ To find the minimum of sphere function on interval (-10 to 10) with
489
+ 2 dimensions in domain using default parameters:
490
+ """
491
+
492
+ from beecolpy import abc
493
+
494
+ def sphere(x):
495
+ total = 0
496
+ for i in range(len(x)):
497
+ total += x[i]**2
498
+ return total
499
+
500
+ abc_obj = abc(sphere, [(-10,10), (-10,10)]) #Load data
501
+ abc_obj.fit() #Execute the algorithm
502
+
503
+ #If you want to get the obtained solution after execute the fit() method:
504
+ solution = abc_obj.get_solution()
505
+
506
+ #If you want to get the number of iterations executed, number of times that
507
+ #scout event occur and number of times that NaN protection actuated:
508
+ iterations = abc_obj.get_status()[0]
509
+ scout = abc_obj.get_status()[1]
510
+ nan_events = abc_obj.get_status()[2]
511
+
512
+ #If you want to get a list with position of all points (food sources) used in each iteration:
513
+ food_sources = abc_obj.get_agents()
514
+
515
+ ~~~~~~~~~~~~~~~~~
516
+
517
+
518
+
519
+ **Author**
520
+ --------------
521
+
522
+ **Samuel Carlos Pessoa Oliveira** - samuelcpoliveira@gmail.com
523
+
524
+
525
+
526
+ **License**
527
+ --------------
528
+
529
+ This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
530
+
531
+
532
+
533
+ **Bibliography**
534
+ ---------------
535
+
536
+ [1] Karaboga, D. and Basturk, B., 2007 A powerful and efficient algorithm for numerical function optimization: artificial bee colony ABC) algorithm. Journal of global optimization, 39(3), pp.459-471. Doi: https://doi.org/10.1007/s10898-007-9149-x
537
+
538
+ [2] Liu, T., Zhang, L. and Zhang, J., 2013 Study of binary artificial bee colony algorithm based on particle swarm optimization. Journal of Computational Information Systems, 9(16), pp.6459-6466. Link: https://api.semanticscholar.org/CorpusID:8789571
539
+
540
+ [3] Anuar, S., Selamat, A. and Sallehuddin, R., 2016 A modified scout bee for artificial bee colony algorithm and its performance on optimization problems. Journal of King Saud University-Computer and Information Sciences, 28(4), pp. 95-406. Doi: https://doi.org/10.1016/j.jksuci.2016.03.001
541
+
542
+ [4] Kennedy, J. and Eberhart, R.C., 1997, October. A discrete binary version of the particle swarm algorithm. In 1997 IEEE International conference on systems, man, and cybernetics. Computational cybernetics and simulation (Vol. 5, pp. 4104-4108). IEEE. Doi: https://doi.org/10.1109/ICSMC.1997.637339
543
+
544
+ [5] Pampará, G. and Engelbrecht, A.P., 2011, April. Binary artificial bee colony optimization. In 2011 IEEE Symposium on Swarm Intelligence (pp. 1-8). IEEE. Doi: https://doi.org/10.1109/SIS.2011.5952562
545
+
546
+ [6] Mirjalili, S., Hashim, S., Taherzadeh, G., Mirjalili, S.Z. and Salehi, S., 2011. A study of different transfer functions for binary version of particle swarm optimization. In International Conference on Genetic and Evolutionary Methods (Vol. 1, No. 1, pp. 2-7). Link: http://hdl.handle.net/10072/48831
547
+
548
+ [7] Huang, S.C., 2015. Polygonal approximation using an artificial bee colony algorithm. Mathematical Problems in Engineering, 2015. Doi: https://doi.org/10.1155/2015/375926
@@ -0,0 +1,9 @@
1
+ beecolpy/__init__.py,sha256=TIvJOtlnp0Z1m79hIJc3VstCmy2hKOEYLximgF1Olns,74
2
+ beecolpy/beecolpy.py,sha256=7Tq9-2unnKoLtxswQuvJcN1jnWZHiwfbKRIjAInafW8,42418
3
+ beecolpy/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ beecolpy/tests/test_beecolpy.py,sha256=lFPDmEENf92EKggMNLAIsLNhhgzW1Y_WPRz53CIG0DA,22391
5
+ beecolpy-2.3.3.dist-info/licenses/LICENSE.md,sha256=hYFpsVOnBCAu__R8XgYDHnWZJDlH0Fy7GxyRSnRkXQc,1107
6
+ beecolpy-2.3.3.dist-info/METADATA,sha256=ODyH491i1V4iOIZRU8neAvditdw0NoDSN-0ZxH7fwIo,18979
7
+ beecolpy-2.3.3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ beecolpy-2.3.3.dist-info/top_level.txt,sha256=H1UrN93VXi0srVT_01ndy9xT0LIiWL-1B9SseSXFz0Q,9
9
+ beecolpy-2.3.3.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Samuel Carlos Pessoa Oliveira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ beecolpy