whalepy 1.0.0__tar.gz

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.
Files changed (83) hide show
  1. whalepy-1.0.0/LICENSE +28 -0
  2. whalepy-1.0.0/MANIFEST.in +4 -0
  3. whalepy-1.0.0/PKG-INFO +652 -0
  4. whalepy-1.0.0/README.md +623 -0
  5. whalepy-1.0.0/doc/api/adaptive_woa.rst +15 -0
  6. whalepy-1.0.0/doc/api/core.rst +56 -0
  7. whalepy-1.0.0/doc/api/cwoa.rst +15 -0
  8. whalepy-1.0.0/doc/api/exponential_decay_woa.rst +15 -0
  9. whalepy-1.0.0/doc/api/gaussian_woa.rst +15 -0
  10. whalepy-1.0.0/doc/api/levy_walk_woa.rst +15 -0
  11. whalepy-1.0.0/doc/api/modified_spiral_woa.rst +15 -0
  12. whalepy-1.0.0/doc/api/mutation_woa.rst +15 -0
  13. whalepy-1.0.0/doc/api/opposition_woa.rst +15 -0
  14. whalepy-1.0.0/doc/api/single_dimensional_woa.rst +15 -0
  15. whalepy-1.0.0/doc/api/woa.rst +15 -0
  16. whalepy-1.0.0/doc/api/worst_individual_disturbance_woa.rst +15 -0
  17. whalepy-1.0.0/doc/api.rst +35 -0
  18. whalepy-1.0.0/doc/examples.rst +184 -0
  19. whalepy-1.0.0/doc/getting_started.rst +27 -0
  20. whalepy-1.0.0/doc/index.rst +57 -0
  21. whalepy-1.0.0/doc/installation.rst +17 -0
  22. whalepy-1.0.0/doc/variants.rst +65 -0
  23. whalepy-1.0.0/doc/woa.rst +22 -0
  24. whalepy-1.0.0/setup.cfg +4 -0
  25. whalepy-1.0.0/setup.py +30 -0
  26. whalepy-1.0.0/whalepy/WOAAlgs/__init__.py +25 -0
  27. whalepy-1.0.0/whalepy/WOAAlgs/adaptive_woa.py +107 -0
  28. whalepy-1.0.0/whalepy/WOAAlgs/base.py +167 -0
  29. whalepy-1.0.0/whalepy/WOAAlgs/cwoa.py +146 -0
  30. whalepy-1.0.0/whalepy/WOAAlgs/data/__init__.py +29 -0
  31. whalepy-1.0.0/whalepy/WOAAlgs/data/alg_data.py +344 -0
  32. whalepy-1.0.0/whalepy/WOAAlgs/exponential_decay_woa.py +75 -0
  33. whalepy-1.0.0/whalepy/WOAAlgs/gaussian_woa.py +69 -0
  34. whalepy-1.0.0/whalepy/WOAAlgs/levy_walk_woa.py +81 -0
  35. whalepy-1.0.0/whalepy/WOAAlgs/methods/__init__.py +0 -0
  36. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_adaptive_woa.py +78 -0
  37. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_cwoa.py +141 -0
  38. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_exponential_decay_woa.py +23 -0
  39. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_gaussian_woa.py +17 -0
  40. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_levy_walk_woa.py +105 -0
  41. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_modified_spiral_woa.py +101 -0
  42. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_mutation_woa.py +93 -0
  43. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_opposition_woa.py +12 -0
  44. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_single_dimensional_woa.py +21 -0
  45. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_woa.py +66 -0
  46. whalepy-1.0.0/whalepy/WOAAlgs/methods/methods_worst_individual_disturbance_woa.py +20 -0
  47. whalepy-1.0.0/whalepy/WOAAlgs/modified_spiral_woa.py +78 -0
  48. whalepy-1.0.0/whalepy/WOAAlgs/mutation_woa.py +132 -0
  49. whalepy-1.0.0/whalepy/WOAAlgs/opposition_woa.py +89 -0
  50. whalepy-1.0.0/whalepy/WOAAlgs/single_dimensional_woa.py +88 -0
  51. whalepy-1.0.0/whalepy/WOAAlgs/woa.py +69 -0
  52. whalepy-1.0.0/whalepy/WOAAlgs/worst_individual_disturbance_woa.py +96 -0
  53. whalepy-1.0.0/whalepy/__init__.py +69 -0
  54. whalepy-1.0.0/whalepy/functions/__init__.py +3 -0
  55. whalepy-1.0.0/whalepy/functions/function_loader.py +137 -0
  56. whalepy-1.0.0/whalepy/functions/functions_info/ackley.json +6 -0
  57. whalepy-1.0.0/whalepy/functions/functions_info/eggholder.json +6 -0
  58. whalepy-1.0.0/whalepy/functions/functions_info/griewank.json +6 -0
  59. whalepy-1.0.0/whalepy/functions/functions_info/michalewicz.json +6 -0
  60. whalepy-1.0.0/whalepy/functions/functions_info/rana.json +6 -0
  61. whalepy-1.0.0/whalepy/functions/functions_info/rastrigin.json +6 -0
  62. whalepy-1.0.0/whalepy/functions/functions_info/rosenbrock.json +6 -0
  63. whalepy-1.0.0/whalepy/functions/functions_info/schwefel.json +6 -0
  64. whalepy-1.0.0/whalepy/functions/functions_info/sphere.json +6 -0
  65. whalepy-1.0.0/whalepy/helpers/__init__.py +4 -0
  66. whalepy-1.0.0/whalepy/helpers/logger.py +16 -0
  67. whalepy-1.0.0/whalepy/helpers/metric_helper.py +41 -0
  68. whalepy-1.0.0/whalepy/models/__init__.py +19 -0
  69. whalepy-1.0.0/whalepy/models/algorithm_result.py +41 -0
  70. whalepy-1.0.0/whalepy/models/enums/__init__.py +4 -0
  71. whalepy-1.0.0/whalepy/models/enums/boundary_constrain.py +82 -0
  72. whalepy-1.0.0/whalepy/models/enums/optimization.py +10 -0
  73. whalepy-1.0.0/whalepy/models/fitness_function.py +73 -0
  74. whalepy-1.0.0/whalepy/models/population.py +79 -0
  75. whalepy-1.0.0/whalepy/models/stop_condition/__init__.py +5 -0
  76. whalepy-1.0.0/whalepy/models/stop_condition/lambda_stop_condition.py +27 -0
  77. whalepy-1.0.0/whalepy/models/stop_condition/never_stop_condition.py +17 -0
  78. whalepy-1.0.0/whalepy/models/stop_condition/stop_condition.py +31 -0
  79. whalepy-1.0.0/whalepy/models/whale.py +42 -0
  80. whalepy-1.0.0/whalepy.egg-info/PKG-INFO +652 -0
  81. whalepy-1.0.0/whalepy.egg-info/SOURCES.txt +81 -0
  82. whalepy-1.0.0/whalepy.egg-info/dependency_links.txt +1 -0
  83. whalepy-1.0.0/whalepy.egg-info/top_level.txt +1 -0
whalepy-1.0.0/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, the whalepy authors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,4 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include whalepy/functions/functions_info *.json
4
+ recursive-include doc *.rst
whalepy-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,652 @@
1
+ Metadata-Version: 2.4
2
+ Name: whalepy
3
+ Version: 1.0.0
4
+ Summary: WhalePy: A Python library of whale optimization algorithm variants for continuous optimization
5
+ Home-page: https://github.com/kajadudek/whalepy
6
+ Author: Kaja Dudek, Natalia Luberda, Wojciech Ksiazek
7
+ Author-email: wojciech.ksiazek@pk.edu.pl
8
+ License: BSD-3-Clause
9
+ Keywords: whale optimization algorithm,metaheuristics,swarm intelligence,optimization
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
14
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
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-python
28
+ Dynamic: summary
29
+
30
+ # whalepy
31
+
32
+ `whalepy` is a research-oriented Python toolbox for the Whale Optimization Algorithm (WOA) family.
33
+
34
+ The project now includes working implementations of plain/basic WOA, Adaptive WOA, Chaotic WOA,
35
+ Mutation-Based WOA, Modified Spiral WOA, Levy Walk WOA, Gaussian Mutation WOA, Opposition-Based
36
+ WOA, Single-Dimensional WOA, Worst-Individual-Disturbance WOA, and Exponential Decay WOA for
37
+ continuous benchmark problems.
38
+
39
+ The following variants have been implemented:
40
+
41
+ | No. | Algorithm | Year | Publication |
42
+ |-----|---------------------------------------------------------------|------|-----------------------------------------------------|
43
+ | 1 | WOA (Whale Optimization Algorithm) | 2016 | Mirjalili & Lewis [1] |
44
+ | 2 | AdaptiveWOA (Adaptive Whale Optimization Algorithm) | 2016 | Trivedi et al. [2], Chen et al. [3], Sun et al. [4] |
45
+ | 3 | CWOA (Chaotic WOA) | 2018 | Kaur & Arora [5] |
46
+ | 4 | MutationWOA (Mutation-Based WOA, DE/rand/1) | 2019 | Mostafa Bozorgi & Yazdani [6] |
47
+ | 5 | ModifiedSpiralWOA (Modified Spiral WOA) | 2018 | Sun et al. [7] |
48
+ | 6 | LevyWalkWOA (Levy Flight WOA) | 2017 | Ling et al. [8] |
49
+ | 7 | GaussianWOA (Gaussian Mutation WOA, GM-WOA) | 2019 | Luo et al. [9] |
50
+ | 8 | OppositionBasedWOA (Opposition-Based WOA) | 2018 | Alamri et al. [10] |
51
+ | 9 | SingleDimensionalWOA (WOA with Single-Dimensional Swimming) | 2020 | Du et al. [11] |
52
+ | 10 | WorstIndividualDisturbanceWOA (Individual Disturbance WOA) | 2022 | Qiao et al. [12] |
53
+ | 11 | ExponentialDecayWOA (WOA with Exponential Convergence Factor) | 2022 | Sun et al. [4] |
54
+
55
+ The scaffold uses a WOA-specific domain model built around `Whale` objects rather than generic evolutionary
56
+ abstractions.
57
+
58
+ Adaptive WOA extends the plain WOA loop with adaptive control schedules. In this project, the adaptive variant
59
+ supports nonlinear decay of the convergence coefficient `a`, an optional inertia-like weight in the leader
60
+ attraction step, and an optional adaptive spiral probability that increasingly favors exploitation later in the
61
+ run.
62
+
63
+ Chaotic WOA replaces selected random draws in WOA with deterministic chaotic sequences. In this project, the
64
+ chaotic variant supports logistic, tent, and sine maps, optional chaotic population initialization, chaotic
65
+ coefficient generation, chaotic branch probability, chaotic spiral values, and optional chaotic modulation of
66
+ the convergence coefficient `a`.
67
+
68
+ Modified Spiral WOA keeps the standard WOA exploration behavior and changes only the exploitation spiral around
69
+ the leader (the best solution found so far). In this project, the variant supports both the standard logarithmic spiral and a practical
70
+ Archimedean-style spiral that shrinks more gradually and covers the local neighborhood more evenly.
71
+
72
+ Mutation-Based WOA augments the standard WOA movement with DE-inspired mutation. In this project, the mutation
73
+ variant keeps the normal WOA candidate, optionally creates a mutation candidate with `DE/rand/1`, evaluates both,
74
+ and keeps the better one according to the optimization mode.
75
+
76
+ Levy Walk WOA modifies the exploration phase with Levy-flight-based random walks. In this project, the Levy
77
+ variant uses Mantegna-style heavy-tailed steps during exploration while keeping standard WOA-like exploitation
78
+ around the leader (the best solution found so far).
79
+
80
+ Gaussian Mutation WOA (GM-WOA) runs the standard WOA update unchanged, then applies a multiplicative
81
+ Gaussian mutation `X' = X^A * (1 + G)` (element-wise) with `G ~ N(0, I)` to every whale, where `X^A` is
82
+ the position produced by the base WOA step. The mutated candidate replaces the current position only if it
83
+ improves the fitness (greedy selection). Because the perturbation is proportional to `|X^A_i|`, coordinates
84
+ near zero are barely changed while coordinates far from the origin can move substantially. Implementation
85
+ follows Luo et al. (2019).
86
+
87
+ Opposition-Based WOA reuses the base WOA main loop unchanged and only modifies population initialization.
88
+ A random population of size N is generated, an opposite candidate `x_opp = lb + ub - x` is produced for
89
+ each whale, both sets are evaluated, and the best N individuals from the resulting pool of 2N candidates
90
+ form the starting population.
91
+
92
+ Single-Dimensional WOA replaces the classical encircling-prey step with the single-dimensional swimming
93
+ mechanism from Du et al. (2020). Instead of updating the full position vector, a single randomly
94
+ selected coordinate `d` is updated via `X_d(t+1) = X*_d(t) - A * |C * X*_d(t) - X_d(t)|`, while all
95
+ other coordinates stay unchanged. The exploration branch and the spiral branch are inherited from the
96
+ base WOA without modification.
97
+
98
+ Worst-Individual-Disturbance WOA disturbs the classical encircling step with information about the
99
+ worst individual in the population, following the individual-disturbance strategy from Qiao et al.
100
+ (2022). The encircling update `X_new = X_best - A*D` is replaced with
101
+ `X_new = r_4 * X_best - A*D + (1 - r_4) * X_worst`, where `r_4` is drawn uniformly from `[0, 1]`
102
+ .This introduces information about the worst individual into the encircling update while retaining the best individual as a reference point.
103
+ The exploration branch and the spiral branch stay identical to the base WOA.
104
+
105
+ Exponential WOA replaces the standard linear schedule of the convergence coefficient a
106
+ with a nonlinear schedule based on an exponential function.
107
+ The remaining WOA movement mechanisms are unchanged.
108
+
109
+ ## Installation
110
+
111
+ Basic installation:
112
+
113
+ ```bash
114
+ pip install .
115
+ ```
116
+
117
+ ## Usage
118
+
119
+ Common usage pattern:
120
+
121
+ ```python
122
+ config = VariantData(...)
123
+ algorithm = Variant(config)
124
+ result = algorithm.run()
125
+ ```
126
+
127
+ Top-level imports are available for all implemented variants:
128
+
129
+ ```python
130
+ from whalepy import (
131
+ AdaptiveWOA,
132
+ AdaptiveWOAData,
133
+ BoundaryConstraint,
134
+ CWOA,
135
+ CWOAData,
136
+ ExponentialDecayWOA,
137
+ ExponentialDecayWOAData,
138
+ FunctionLoader,
139
+ GaussianWOA,
140
+ GaussianWOAData,
141
+ LevyWalkWOA,
142
+ LevyWalkWOAData,
143
+ ModifiedSpiralWOA,
144
+ ModifiedSpiralWOAData,
145
+ MutationWOA,
146
+ MutationWOAData,
147
+ OppositionBasedWOA,
148
+ OppositionWOAData,
149
+ OptimizationType,
150
+ SingleDimensionalWOA,
151
+ SingleDimensionalWOAData,
152
+ WOA,
153
+ WOAData,
154
+ WorstIndividualDisturbanceWOA,
155
+ WorstIndividualDisturbanceWOAData,
156
+ run_algorithm,
157
+ )
158
+ ```
159
+
160
+ Basic WOA example:
161
+
162
+ ```python
163
+ from whalepy import FunctionLoader, WOA, WOAData
164
+
165
+ loader = FunctionLoader()
166
+ config = WOAData(
167
+ population_size=25,
168
+ max_iter=80,
169
+ max_nfe=2200,
170
+ dimension=5,
171
+ lb=[-5.0] * 5,
172
+ ub=[5.0] * 5,
173
+ function=loader.load_callable("sphere"),
174
+ seed=7,
175
+ )
176
+
177
+ algorithm = WOA(config)
178
+ result = algorithm.run()
179
+ print(result.best_fitness_value)
180
+ ```
181
+
182
+ Stopping rule:
183
+
184
+ - `max_iter` is the primary loop budget
185
+ - `max_nfe` is an additional evaluation cap
186
+ - if both are provided, the algorithm stops when either limit is reached first
187
+ - most variants spend one evaluation per whale per iteration, but GM-WOA and Opposition-Based WOA
188
+ spend more, so they use up `max_nfe` faster — see their notes below
189
+
190
+ Result:
191
+
192
+ - `result.best_whale` and `result.best_fitness_value` describe the best solution found during the whole run;
193
+ this solution is also the leader `X*` used in the position updates
194
+ - `result.history` contains the best fitness value found so far after the initialization and after each iteration
195
+ - `result.worst_whale`, `result.mean_fitness_value` and `result.std_fitness_value` describe the final population
196
+
197
+ Function handling:
198
+
199
+ - use `FunctionLoader().load_callable("sphere")` for built-in benchmarks
200
+ - or pass a plain Python callable with `function=my_objective`
201
+
202
+ Boundary handling:
203
+
204
+ - all variants accept `boundary_constraints_fun`
205
+ - built-in choices include `BoundaryConstraint.CLIP`, `BoundaryConstraint.REFLECT`, and
206
+ `BoundaryConstraint.RANDOM_RESET`
207
+
208
+ Adaptive WOA usage:
209
+
210
+ ```python
211
+ from whalepy import AdaptiveWOA, AdaptiveWOAData, FunctionLoader
212
+
213
+ loader = FunctionLoader()
214
+ config = AdaptiveWOAData(
215
+ population_size=25,
216
+ max_iter=80,
217
+ max_nfe=2200,
218
+ dimension=5,
219
+ lb=[-5.0] * 5,
220
+ ub=[5.0] * 5,
221
+ function=loader.load_callable("ackley"),
222
+ seed=7,
223
+ a_strategy="cosine",
224
+ use_inertia_weight=True,
225
+ adaptive_probability=True,
226
+ p_start=0.5,
227
+ p_end=0.9,
228
+ )
229
+
230
+ result = AdaptiveWOA(config).run()
231
+ print(result.best_fitness_value)
232
+ ```
233
+
234
+ Adaptive WOA notes:
235
+
236
+ - `a_strategy="cosine"` uses a cosine decay for the convergence coefficient
237
+ - `a_strategy="logarithmic"` uses a logarithmic decay for the convergence coefficient
238
+ - `use_inertia_weight=True` enables a growing weight on the best-whale attraction term
239
+ - `adaptive_probability=True` gradually shifts more updates toward the spiral exploitation branch
240
+
241
+ Chaotic WOA usage:
242
+
243
+ ```python
244
+ from whalepy import CWOA, CWOAData, FunctionLoader
245
+
246
+ loader = FunctionLoader()
247
+ config = CWOAData(
248
+ population_size=25,
249
+ max_iter=100,
250
+ max_nfe=2600,
251
+ dimension=5,
252
+ lb=[-5.0] * 5,
253
+ ub=[5.0] * 5,
254
+ function=loader.load_callable("ackley"),
255
+ seed=7,
256
+ chaotic_map="logistic",
257
+ chaotic_seed=0.37,
258
+ use_chaotic_initialization=True,
259
+ use_chaotic_probability=True,
260
+ use_chaotic_coefficients=True,
261
+ use_chaotic_spiral=True,
262
+ )
263
+
264
+ result = CWOA(config).run()
265
+ print(result.best_fitness_value)
266
+ ```
267
+
268
+ Chaotic WOA notes:
269
+
270
+ - `chaotic_map="logistic"` uses the logistic map with `logistic_a=4.0` by default
271
+ - `chaotic_map="tent"` uses the tent map with the built-in `0.7 / 1.4286` schedule
272
+ - `chaotic_map="sine"` uses the sine map with `sine_a=4.0` by default
273
+ - chaotic values can replace standard random draws for initialization, `r`, `p`, and `l`
274
+ - `use_chaotic_a=True` optionally modulates the base convergence coefficient with chaos
275
+
276
+ Mutation-Based WOA usage:
277
+
278
+ ```python
279
+ from whalepy import FunctionLoader, MutationWOA, MutationWOAData
280
+
281
+ loader = FunctionLoader()
282
+ config = MutationWOAData(
283
+ population_size=30,
284
+ max_iter=100,
285
+ max_nfe=3500,
286
+ dimension=5,
287
+ lb=[-5.0] * 5,
288
+ ub=[5.0] * 5,
289
+ function=loader.load_callable("rastrigin"),
290
+ seed=7,
291
+ mutation_strategy="de_rand_1",
292
+ mutation_factor=0.6,
293
+ mutation_probability=0.35,
294
+ use_mutation_selection=True,
295
+ )
296
+
297
+ result = MutationWOA(config).run()
298
+ print(result.best_fitness_value)
299
+ ```
300
+
301
+ Modified Spiral WOA usage:
302
+
303
+ ```python
304
+ from whalepy import FunctionLoader, ModifiedSpiralWOA, ModifiedSpiralWOAData
305
+
306
+ loader = FunctionLoader()
307
+ config = ModifiedSpiralWOAData(
308
+ population_size=30,
309
+ max_iter=120,
310
+ max_nfe=3800,
311
+ dimension=5,
312
+ lb=[-5.0] * 5,
313
+ ub=[5.0] * 5,
314
+ function=loader.load_callable("ackley"),
315
+ seed=7,
316
+ spiral_mode="archimedean",
317
+ spiral_b=1.0,
318
+ spiral_step=0.25,
319
+ spiral_shrink_factor=0.75,
320
+ )
321
+
322
+ result = ModifiedSpiralWOA(config).run()
323
+ print(result.best_fitness_value)
324
+ ```
325
+
326
+ Levy Walk WOA usage:
327
+
328
+ ```python
329
+ from whalepy import FunctionLoader, LevyWalkWOA, LevyWalkWOAData
330
+
331
+ loader = FunctionLoader()
332
+ config = LevyWalkWOAData(
333
+ population_size=30,
334
+ max_iter=120,
335
+ max_nfe=3800,
336
+ dimension=5,
337
+ lb=[-5.0] * 5,
338
+ ub=[5.0] * 5,
339
+ function=loader.load_callable("ackley"),
340
+ seed=7,
341
+ levy_beta=1.5,
342
+ levy_scale=0.05,
343
+ use_levy_exploration=True,
344
+ levy_mode="exploration_only",
345
+ )
346
+
347
+ result = LevyWalkWOA(config).run()
348
+ print(result.best_fitness_value)
349
+ ```
350
+
351
+ Levy Walk WOA notes:
352
+
353
+ - `levy_beta` controls the heaviness of the Levy tail
354
+ - `levy_scale` controls the overall exploration step size
355
+ - `use_levy_exploration=True` enables Levy-flight exploration when `|A| >= 1`
356
+ - `levy_mode="exploration_only"` uses only the Levy move in the exploration branch
357
+ - `levy_mode="hybrid"` blends a standard WOA exploration candidate with a Levy-flight perturbation
358
+
359
+ Gaussian WOA usage:
360
+
361
+ ```python
362
+ from whalepy import FunctionLoader, GaussianWOA, GaussianWOAData
363
+
364
+ loader = FunctionLoader()
365
+ config = GaussianWOAData(
366
+ population_size=30,
367
+ max_iter=120,
368
+ max_nfe=3800,
369
+ dimension=5,
370
+ lb=[-5.0] * 5,
371
+ ub=[5.0] * 5,
372
+ function=loader.load_callable("ackley"),
373
+ seed=7,
374
+ )
375
+
376
+ result = GaussianWOA(config).run()
377
+ print(result.best_fitness_value)
378
+ ```
379
+
380
+ Gaussian Mutation WOA (GM-WOA) notes:
381
+
382
+ - runs the standard WOA update on the whole population, producing positions `X^A`
383
+ - then applies a multiplicative Gaussian mutation `X' = X^A * (1 + G)` (element-wise, `G ~ N(0, I)`)
384
+ to every whale, following Luo et al. (2019)
385
+ - the mutated candidate is accepted only if it improves the fitness (greedy selection); otherwise the
386
+ standard WOA position `X^A` is kept
387
+ - the perturbation scale on coordinate `i` is proportional to `|X^A_i|`, so points near the origin are
388
+ perturbed only slightly and points far from it can move substantially
389
+ - the base WOA operators (encircling, spiral update, random exploration) are unchanged; there are no
390
+ additional parameters beyond those inherited from `WOAData`
391
+ - one iteration costs two evaluations per whale (the WOA step plus the mutated candidate), so with the
392
+ settings above the run completes 62 full iterations and may enter a partial 63rd one before
393
+ reaching `max_nfe=3800`
394
+ - to allow the same number of full iterations as the other variants, GM-WOA requires approximately
395
+ twice the evaluation budget, since each iteration evaluates both the standard WOA candidate and the
396
+ Gaussian-mutated candidate
397
+
398
+ Opposition-Based WOA usage:
399
+
400
+ ```python
401
+ from whalepy import FunctionLoader, OppositionBasedWOA, OppositionWOAData
402
+
403
+ loader = FunctionLoader()
404
+ config = OppositionWOAData(
405
+ population_size=30,
406
+ max_iter=120,
407
+ max_nfe=3800,
408
+ dimension=5,
409
+ lb=[-5.0] * 5,
410
+ ub=[5.0] * 5,
411
+ function=loader.load_callable("ackley"),
412
+ seed=7,
413
+ use_obl_initialization=True,
414
+ )
415
+
416
+ result = OppositionBasedWOA(config).run()
417
+ print(result.best_fitness_value)
418
+ ```
419
+
420
+ Opposition-Based WOA notes:
421
+
422
+ - `use_obl_initialization=True` (default) generates an opposite candidate `x_opp = lb + ub - x` for every
423
+ random whale and keeps the best N individuals from the combined pool of 2N candidates as the starting
424
+ population
425
+ - `use_obl_initialization=False` disables the OBL step and makes the algorithm behave exactly like base WOA
426
+ - the main loop is inherited from base WOA without modification
427
+ - initialization costs `2 * population_size` evaluations instead of `population_size`, so `max_nfe`
428
+ must be at least that large or the algorithm raises a `ValueError`
429
+
430
+ Single-Dimensional WOA usage:
431
+
432
+ ```python
433
+ from whalepy import FunctionLoader, SingleDimensionalWOA, SingleDimensionalWOAData
434
+
435
+ loader = FunctionLoader()
436
+ config = SingleDimensionalWOAData(
437
+ population_size=30,
438
+ max_iter=120,
439
+ max_nfe=3800,
440
+ dimension=5,
441
+ lb=[-5.0] * 5,
442
+ ub=[5.0] * 5,
443
+ function=loader.load_callable("ackley"),
444
+ seed=7,
445
+ )
446
+
447
+ result = SingleDimensionalWOA(config).run()
448
+ print(result.best_fitness_value)
449
+ ```
450
+
451
+ Single-Dimensional WOA notes:
452
+
453
+ - implements only the single-dimensional swimming mechanism from Du et al. (2020, Symmetry 12(11), 1892)
454
+ - whenever the base WOA would run its encircling-prey update (`p < 0.5` and `|A| < 1`), a single
455
+ randomly selected coordinate `d` is updated via `X_d(t+1) = X*_d(t) - A * |C * X*_d(t) - X_d(t)|`
456
+ - all other coordinates keep their current values
457
+ - the exploration branch and the spiral update are identical to the base WOA
458
+ - there are no additional configuration parameters beyond those inherited from `WOAData`
459
+
460
+ Worst-Individual-Disturbance WOA usage:
461
+
462
+ ```python
463
+ from whalepy import (
464
+ FunctionLoader,
465
+ WorstIndividualDisturbanceWOA,
466
+ WorstIndividualDisturbanceWOAData,
467
+ )
468
+
469
+ loader = FunctionLoader()
470
+ config = WorstIndividualDisturbanceWOAData(
471
+ population_size=30,
472
+ max_iter=120,
473
+ max_nfe=3800,
474
+ dimension=5,
475
+ lb=[-5.0] * 5,
476
+ ub=[5.0] * 5,
477
+ function=loader.load_callable("ackley"),
478
+ seed=7,
479
+ )
480
+
481
+ result = WorstIndividualDisturbanceWOA(config).run()
482
+ print(result.best_fitness_value)
483
+ ```
484
+
485
+ Worst-Individual-Disturbance WOA notes:
486
+
487
+ - implements the individual-disturbance strategy from Qiao et al. (2022), eq. 9
488
+ - the classical encircling formula `X_new = X_best - A*D` is replaced with
489
+ `X_new = r_4 * X_best - A*D + (1 - r_4) * X_worst`, where `r_4` is drawn uniformly from `[0, 1]`
490
+ - only the individual-disturbance component is retained; the neighborhood mutation search proposed
491
+ alongside it in the same paper is not applied
492
+ - the exploration branch and the spiral update are identical to the base WOA
493
+ - there are no additional configuration parameters beyond those inherited from `WOAData`
494
+
495
+ Exponential Decay WOA usage:
496
+
497
+ ```python
498
+ from whalepy import ExponentialDecayWOA, ExponentialDecayWOAData, FunctionLoader
499
+
500
+ loader = FunctionLoader()
501
+ config = ExponentialDecayWOAData(
502
+ population_size=30,
503
+ max_iter=120,
504
+ max_nfe=3800,
505
+ dimension=5,
506
+ lb=[-5.0] * 5,
507
+ ub=[5.0] * 5,
508
+ function=loader.load_callable("ackley"),
509
+ seed=7,
510
+ a_initial=2.0,
511
+ a_final=0.0,
512
+ k=0.5,
513
+ )
514
+
515
+ result = ExponentialDecayWOA(config).run()
516
+ print(result.best_fitness_value)
517
+ ```
518
+
519
+ Exponential Decay WOA notes:
520
+
521
+ - implements the nonlinear convergence coefficient from Sun et al. (2022, eq. 12):
522
+ `a(t) = a_initial - (a_initial - a_final) * (exp(tau^k) - 1) / (e - 1)`
523
+ - if `T` denotes the total number of scheduled iterations, then `tau = t / (T - 1)` for
524
+ `t = 0, ..., T - 1`
525
+ - boundary conditions are exact: `a(0) == a_initial` and `a(T - 1) == a_final`
526
+ - `k > 0` shapes the curve: smaller values make `a` drop quickly early in the run, larger values keep
527
+ it high for longer (at the halfway point, `k=0.3` gives `a ≈ 0.54` while `k=0.9` gives `a ≈ 1.18`)
528
+ - the useful range is problem-dependent, so `k` is exposed as a configuration parameter
529
+ - the example above uses `k=0.5` for demonstration; the benchmark experiments run for this project
530
+ used `k=0.7`
531
+ - only the update rule for `a` is taken from Sun et al.; the rest of the algorithm
532
+ (encircling, spiral update, random exploration) is identical to the base WOA
533
+
534
+ Optional convenience helper:
535
+
536
+ ```python
537
+ from whalepy import WOA, WOAData, run_algorithm
538
+
539
+ result = run_algorithm(WOA, WOAData(...))
540
+ ```
541
+
542
+ ## Benchmarking
543
+
544
+ The repository includes a simple benchmark runner for comparing all implemented variants on the same benchmark
545
+ setup.
546
+
547
+ Run the full benchmark suite:
548
+
549
+ ```bash
550
+ python benchmarks/benchmark_runner.py
551
+ ```
552
+
553
+ Run a smaller smoke benchmark:
554
+
555
+ ```bash
556
+ python benchmarks/benchmark_runner.py --smoke
557
+ ```
558
+
559
+ Write per-run results to CSV:
560
+
561
+ ```bash
562
+ python benchmarks/benchmark_runner.py --csv benchmarks/results/benchmark_results.csv
563
+ ```
564
+
565
+ The benchmark runner compares:
566
+
567
+ - WOA
568
+ - AdaptiveWOA
569
+ - CWOA
570
+ - MutationWOA
571
+ - ModifiedSpiralWOA
572
+ - LevyWalkWOA
573
+ - GaussianWOA
574
+ - OppositionBasedWOA
575
+ - SingleDimensionalWOA
576
+ - WorstIndividualDisturbanceWOA
577
+ - ExponentialDecayWOA
578
+
579
+ The default registry includes these benchmark functions:
580
+
581
+ - Ackley
582
+ - Schwefel
583
+ - Griewank
584
+ - Michalewicz
585
+ - Rastrigin
586
+ - Rana
587
+ - EggHolder
588
+ - Rosenbrock
589
+
590
+ Reported metrics include:
591
+
592
+ - algorithm name
593
+ - function name
594
+ - dimension
595
+ - run count
596
+ - best fitness across runs
597
+ - mean best fitness across runs
598
+ - standard deviation of best fitness
599
+ - average runtime
600
+ - average completed epochs
601
+ - average function evaluations
602
+
603
+ ## Project Layout
604
+
605
+ ```text
606
+ benchmarks/
607
+ whalepy/
608
+ WOAAlgs/
609
+ models/
610
+ functions/
611
+ helpers/
612
+ examples/
613
+ doc/
614
+ ```
615
+
616
+ ## Status
617
+
618
+ Implemented now:
619
+
620
+ - plain/basic WOA
621
+ - adaptive WOA with nonlinear `a`, adaptive inertia weight, and optional adaptive spiral probability
622
+ - chaotic WOA with logistic, tent, and sine maps plus optional chaotic initialization and parameter draws
623
+ - mutation-based WOA with DE/rand/1 candidate generation and fitness-based selection
624
+ - modified spiral WOA with configurable logarithmic and Archimedean-style exploitation spirals
625
+ - Levy walk WOA with Levy-flight exploration using Mantegna's algorithm
626
+ - Gaussian Mutation WOA (GM-WOA) that appends a multiplicative Gaussian perturbation
627
+ `X^A * (1 + G)` with greedy selection after each standard WOA update
628
+ - opposition-based WOA that seeds the population with the best N individuals from N random whales and their
629
+ opposite counterparts
630
+ - single-dimensional WOA that replaces the encircling-prey step with a single-coordinate update from
631
+ Du et al. (2020)
632
+ - worst-individual-disturbance WOA that perturbs the encircling step with information from the worst
633
+ individual, following Qiao et al. (2022)
634
+ - exponential decay WOA with an exponential decay schedule for the convergence coefficient
635
+ - built-in Ackley, Schwefel, Griewank, Michalewicz, Rastrigin, Rana, EggHolder, and Rosenbrock benchmark callables, with
636
+ Sphere still available for compatibility
637
+ - WOA-specific `Whale` and `Population` models
638
+
639
+ ## References
640
+
641
+ 1. Mirjalili, S., Lewis, A., 2016. The Whale Optimization Algorithm. Advances in Engineering Software 95, 51–67. https://doi.org/10.1016/j.advengsoft.2016.01.008
642
+ 2. Trivedi, I.N., Pradeep, J., Narottam, J., Arvind, K., Dilip, L., 2016. Novel Adaptive Whale Optimization Algorithm for Global Optimization. Indian Journal of Science and Technology 9. https://doi.org/10.17485/ijst/2016/v9i38/101939
643
+ 3. Chen, H., Yang, C., Heidari, A.A., Zhao, X., 2020. An efficient double adaptive random spare reinforced whale optimization algorithm. Expert Systems with Applications 154, 113018. https://doi.org/10.1016/j.eswa.2019.113018
644
+ 4. Sun, G., Shang, Y., Yuan, K., Gao, H., 2022. An Improved Whale Optimization Algorithm Based on Nonlinear Parameters and Feedback Mechanism. Int J Comput Intell Syst 15. https://doi.org/10.1007/s44196-022-00092-7
645
+ 5. Kaur, G., Arora, S., 2018. Chaotic whale optimization algorithm. Journal of Computational Design and Engineering 5, 275–284. https://doi.org/10.1016/j.jcde.2017.12.006
646
+ 6. Mostafa Bozorgi, S., Yazdani, S., 2019. IWOA: An improved whale optimization algorithm for optimization problems. Journal of Computational Design and Engineering 6, 243–259. https://doi.org/10.1016/j.jcde.2019.02.002
647
+ 7. Sun, W., Wang, J., Wei, X., 2018. An Improved Whale Optimization Algorithm Based on Different Searching Paths and Perceptual Disturbance. Symmetry 10, 210. https://doi.org/10.3390/sym10060210
648
+ 8. Ling, Y., Zhou, Y., Luo, Q., 2017. Lévy Flight Trajectory-Based Whale Optimization Algorithm for Global Optimization. IEEE Access 5, 6168–6186. https://doi.org/10.1109/access.2017.2695498
649
+ 9. Luo, J., Chen, H., Heidari, A.A., Xu, Y., Zhang, Q., Li, C., 2019. Multi-strategy boosted mutative whale-inspired optimization approaches. Applied Mathematical Modelling 73, 109–123. https://doi.org/10.1016/j.apm.2019.03.046
650
+ 10. Alamri, H.S., Alsariera, Y.A., Zamli, K.Z., 2018. Opposition-Based Whale Optimization Algorithm. adv sci lett 24, 7461–7464. https://doi.org/10.1166/asl.2018.12959
651
+ 11. Du, P., Cheng, W., Liu, N., Zhang, H., Lu, J., 2020. A Modified Whale Optimization Algorithm with Single-Dimensional Swimming for Global Optimization Problems. Symmetry 12, 1892. https://doi.org/10.3390/sym12111892
652
+ 12. Qiao, S., Yu, H., Heidari, A.A., El-Saleh, A.A., Cai, Z., Xu, X., Mafarja, M., Chen, H., 2022. Individual disturbance and neighborhood mutation search enhanced whale optimization: performance design for engineering problems. Journal of Computational Design and Engineering 9, 1817–1851. https://doi.org/10.1093/jcde/qwac081