swarm-seek 0.1.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 (41) hide show
  1. swarm_seek-0.1.0/LICENSE +201 -0
  2. swarm_seek-0.1.0/PKG-INFO +113 -0
  3. swarm_seek-0.1.0/README.md +68 -0
  4. swarm_seek-0.1.0/pyproject.toml +107 -0
  5. swarm_seek-0.1.0/setup.cfg +4 -0
  6. swarm_seek-0.1.0/src/swarm_seek/__init__.py +14 -0
  7. swarm_seek-0.1.0/src/swarm_seek/abc.py +144 -0
  8. swarm_seek-0.1.0/src/swarm_seek/backends/__init__.py +11 -0
  9. swarm_seek-0.1.0/src/swarm_seek/backends/numpy_backend.py +56 -0
  10. swarm_seek-0.1.0/src/swarm_seek/backends/protocol.py +33 -0
  11. swarm_seek-0.1.0/src/swarm_seek/backends/registry.py +33 -0
  12. swarm_seek-0.1.0/src/swarm_seek/benchmarks/__init__.py +31 -0
  13. swarm_seek-0.1.0/src/swarm_seek/benchmarks/functions.py +200 -0
  14. swarm_seek-0.1.0/src/swarm_seek/benchmarks/oracles.py +232 -0
  15. swarm_seek-0.1.0/src/swarm_seek/colony/__init__.py +5 -0
  16. swarm_seek-0.1.0/src/swarm_seek/colony/engine.py +431 -0
  17. swarm_seek-0.1.0/src/swarm_seek/errors/__init__.py +19 -0
  18. swarm_seek-0.1.0/src/swarm_seek/errors/exceptions.py +27 -0
  19. swarm_seek-0.1.0/src/swarm_seek/integrations/__init__.py +1 -0
  20. swarm_seek-0.1.0/src/swarm_seek/space/__init__.py +9 -0
  21. swarm_seek-0.1.0/src/swarm_seek/space/continuous.py +157 -0
  22. swarm_seek-0.1.0/src/swarm_seek/space/protocol.py +31 -0
  23. swarm_seek-0.1.0/src/swarm_seek/types/__init__.py +12 -0
  24. swarm_seek-0.1.0/src/swarm_seek/types/_aliases.py +14 -0
  25. swarm_seek-0.1.0/src/swarm_seek/types/solution.py +48 -0
  26. swarm_seek-0.1.0/src/swarm_seek/variants/__init__.py +35 -0
  27. swarm_seek-0.1.0/src/swarm_seek/variants/_helpers.py +134 -0
  28. swarm_seek-0.1.0/src/swarm_seek/variants/gabc.py +225 -0
  29. swarm_seek-0.1.0/src/swarm_seek/variants/mabc.py +218 -0
  30. swarm_seek-0.1.0/src/swarm_seek/variants/original.py +169 -0
  31. swarm_seek-0.1.0/src/swarm_seek/variants/params.py +48 -0
  32. swarm_seek-0.1.0/src/swarm_seek/variants/protocol.py +62 -0
  33. swarm_seek-0.1.0/src/swarm_seek/variants/qabc.py +246 -0
  34. swarm_seek-0.1.0/src/swarm_seek/variants/registry.py +70 -0
  35. swarm_seek-0.1.0/src/swarm_seek.egg-info/PKG-INFO +113 -0
  36. swarm_seek-0.1.0/src/swarm_seek.egg-info/SOURCES.txt +39 -0
  37. swarm_seek-0.1.0/src/swarm_seek.egg-info/dependency_links.txt +1 -0
  38. swarm_seek-0.1.0/src/swarm_seek.egg-info/requires.txt +26 -0
  39. swarm_seek-0.1.0/src/swarm_seek.egg-info/top_level.txt +1 -0
  40. swarm_seek-0.1.0/tests/test_abc_facade.py +99 -0
  41. swarm_seek-0.1.0/tests/test_smoke.py +47 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.4
2
+ Name: swarm-seek
3
+ Version: 0.1.0
4
+ Summary: Literature-validated Artificial Bee Colony optimization for Python
5
+ Author-email: Travis Kessler <travis.j.kessler@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/tjkessler/swarm-seek
8
+ Project-URL: Documentation, https://swarm-seek.readthedocs.io/
9
+ Project-URL: Repository, https://github.com/tjkessler/swarm-seek
10
+ Project-URL: Issues, https://github.com/tjkessler/swarm-seek/issues
11
+ Keywords: artificial-bee-colony,abc,swarm-intelligence,optimization,metaheuristic,ask-tell
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: numpy>=1.24.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: build>=1.2.0; extra == "dev"
27
+ Requires-Dist: pytest>=8.4.0; extra == "dev"
28
+ Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.15.0; extra == "dev"
30
+ Requires-Dist: pre-commit>=4.0.0; extra == "dev"
31
+ Requires-Dist: nbmake>=0.5.0; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: sphinx>=8.0.0; extra == "docs"
34
+ Requires-Dist: furo>=2024.8.6; extra == "docs"
35
+ Requires-Dist: sphinx-copybutton>=0.5.2; extra == "docs"
36
+ Provides-Extra: numba
37
+ Requires-Dist: numba>=0.59.0; extra == "numba"
38
+ Provides-Extra: jax
39
+ Requires-Dist: jax>=0.4.0; extra == "jax"
40
+ Provides-Extra: sklearn
41
+ Requires-Dist: scikit-learn>=1.3.0; extra == "sklearn"
42
+ Provides-Extra: optuna
43
+ Requires-Dist: optuna>=3.0.0; extra == "optuna"
44
+ Dynamic: license-file
45
+
46
+ # Swarm Seek
47
+
48
+ Literature-validated Artificial Bee Colony (ABC) optimization for Python.
49
+
50
+ Swarm Seek implements Original ABC and principal peer-reviewed continuous
51
+ variants (GABC, qABC, MABC) with a NumPy core, an ask/tell API, and automated
52
+ checks against published benchmark figures.
53
+
54
+ **Status:** `0.1.0` (beta). Continuous ABC core, variants, ask/tell API, and
55
+ literature oracles. Docs: https://swarm-seek.readthedocs.io/
56
+
57
+ ## Install
58
+
59
+ Requires Python 3.10+.
60
+
61
+ ```bash
62
+ pip install swarm-seek
63
+ ```
64
+
65
+ Editable install for development:
66
+
67
+ ```bash
68
+ pip install -e ".[dev]"
69
+ ```
70
+
71
+ ## Quick start
72
+
73
+ ```python
74
+ from swarm_seek import ABC, ContinuousSpace
75
+ from swarm_seek.benchmarks import sphere
76
+
77
+ space = ContinuousSpace([(-5.0, 5.0)] * 5)
78
+ colony = ABC(space, variant="original", pop_size=20, limit=100, max_evals=5_000, seed=0)
79
+ best = colony.minimize(sphere)
80
+ print(best.fitness)
81
+ ```
82
+
83
+ Ask/tell loop:
84
+
85
+ ```python
86
+ import numpy as np
87
+
88
+ from swarm_seek import ABC, ContinuousSpace
89
+ from swarm_seek.benchmarks import sphere
90
+
91
+ space = ContinuousSpace([(-5.0, 5.0)] * 5)
92
+ colony = ABC(space, variant="gabc", pop_size=20, limit=100, max_evals=5_000, seed=0)
93
+
94
+ while not colony.converged:
95
+ candidates = colony.ask()
96
+ if candidates.size == 0:
97
+ colony.tell([])
98
+ continue
99
+ colony.tell(np.asarray(sphere(candidates), dtype=np.float64))
100
+
101
+ print(colony.best.fitness)
102
+ ```
103
+
104
+ Runnable notebooks with stated pass criteria live in [`examples/`](examples/).
105
+ Full documentation (variants, architecture, API, FAQ) builds from `docs/source/`.
106
+
107
+ ## License
108
+
109
+ Apache License 2.0. See [LICENSE](LICENSE).
110
+
111
+ ## Citation
112
+
113
+ See [`CITATION.cff`](CITATION.cff) for citation metadata.
@@ -0,0 +1,68 @@
1
+ # Swarm Seek
2
+
3
+ Literature-validated Artificial Bee Colony (ABC) optimization for Python.
4
+
5
+ Swarm Seek implements Original ABC and principal peer-reviewed continuous
6
+ variants (GABC, qABC, MABC) with a NumPy core, an ask/tell API, and automated
7
+ checks against published benchmark figures.
8
+
9
+ **Status:** `0.1.0` (beta). Continuous ABC core, variants, ask/tell API, and
10
+ literature oracles. Docs: https://swarm-seek.readthedocs.io/
11
+
12
+ ## Install
13
+
14
+ Requires Python 3.10+.
15
+
16
+ ```bash
17
+ pip install swarm-seek
18
+ ```
19
+
20
+ Editable install for development:
21
+
22
+ ```bash
23
+ pip install -e ".[dev]"
24
+ ```
25
+
26
+ ## Quick start
27
+
28
+ ```python
29
+ from swarm_seek import ABC, ContinuousSpace
30
+ from swarm_seek.benchmarks import sphere
31
+
32
+ space = ContinuousSpace([(-5.0, 5.0)] * 5)
33
+ colony = ABC(space, variant="original", pop_size=20, limit=100, max_evals=5_000, seed=0)
34
+ best = colony.minimize(sphere)
35
+ print(best.fitness)
36
+ ```
37
+
38
+ Ask/tell loop:
39
+
40
+ ```python
41
+ import numpy as np
42
+
43
+ from swarm_seek import ABC, ContinuousSpace
44
+ from swarm_seek.benchmarks import sphere
45
+
46
+ space = ContinuousSpace([(-5.0, 5.0)] * 5)
47
+ colony = ABC(space, variant="gabc", pop_size=20, limit=100, max_evals=5_000, seed=0)
48
+
49
+ while not colony.converged:
50
+ candidates = colony.ask()
51
+ if candidates.size == 0:
52
+ colony.tell([])
53
+ continue
54
+ colony.tell(np.asarray(sphere(candidates), dtype=np.float64))
55
+
56
+ print(colony.best.fitness)
57
+ ```
58
+
59
+ Runnable notebooks with stated pass criteria live in [`examples/`](examples/).
60
+ Full documentation (variants, architecture, API, FAQ) builds from `docs/source/`.
61
+
62
+ ## License
63
+
64
+ Apache License 2.0. See [LICENSE](LICENSE).
65
+
66
+ ## Citation
67
+
68
+ See [`CITATION.cff`](CITATION.cff) for citation metadata.
@@ -0,0 +1,107 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "swarm-seek"
7
+ dynamic = ["version"]
8
+ description = "Literature-validated Artificial Bee Colony optimization for Python"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [
14
+ { name = "Travis Kessler", email = "travis.j.kessler@gmail.com" },
15
+ ]
16
+ keywords = [
17
+ "artificial-bee-colony",
18
+ "abc",
19
+ "swarm-intelligence",
20
+ "optimization",
21
+ "metaheuristic",
22
+ "ask-tell",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Intended Audience :: Science/Research",
27
+ "Programming Language :: Python :: 3",
28
+ "Programming Language :: Python :: 3.10",
29
+ "Programming Language :: Python :: 3.11",
30
+ "Programming Language :: Python :: 3.12",
31
+ "Topic :: Scientific/Engineering",
32
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
33
+ "Topic :: Scientific/Engineering :: Mathematics",
34
+ ]
35
+ dependencies = [
36
+ "numpy>=1.24.0",
37
+ ]
38
+
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "build>=1.2.0",
42
+ "pytest>=8.4.0",
43
+ "pytest-cov>=6.0.0",
44
+ "ruff>=0.15.0",
45
+ "pre-commit>=4.0.0",
46
+ "nbmake>=0.5.0",
47
+ ]
48
+ docs = [
49
+ "sphinx>=8.0.0",
50
+ "furo>=2024.8.6",
51
+ "sphinx-copybutton>=0.5.2",
52
+ ]
53
+ numba = [
54
+ "numba>=0.59.0",
55
+ ]
56
+ jax = [
57
+ "jax>=0.4.0",
58
+ ]
59
+ sklearn = [
60
+ "scikit-learn>=1.3.0",
61
+ ]
62
+ optuna = [
63
+ "optuna>=3.0.0",
64
+ ]
65
+
66
+ [project.urls]
67
+ Homepage = "https://github.com/tjkessler/swarm-seek"
68
+ Documentation = "https://swarm-seek.readthedocs.io/"
69
+ Repository = "https://github.com/tjkessler/swarm-seek"
70
+ Issues = "https://github.com/tjkessler/swarm-seek/issues"
71
+
72
+ [tool.setuptools.packages.find]
73
+ where = ["src"]
74
+
75
+ [tool.setuptools.dynamic]
76
+ version = { attr = "swarm_seek.__version__" }
77
+
78
+ [tool.ruff]
79
+ target-version = "py310"
80
+ line-length = 88
81
+ src = ["src", "tests"]
82
+
83
+ [tool.ruff.lint]
84
+ select = ["E", "F", "I", "UP", "B", "SIM"]
85
+
86
+ [tool.ruff.lint.per-file-ignores]
87
+ "__init__.py" = ["F401"]
88
+
89
+ [tool.ruff.format]
90
+ quote-style = "double"
91
+ indent-style = "space"
92
+
93
+ [tool.pytest.ini_options]
94
+ testpaths = ["tests"]
95
+ addopts = "-v"
96
+ markers = [
97
+ "slow: long-running literature oracles (deselect with '-m \"not slow\"')",
98
+ ]
99
+
100
+ [tool.coverage.run]
101
+ source = ["swarm_seek"]
102
+ branch = true
103
+
104
+ [tool.coverage.report]
105
+ fail_under = 90
106
+ show_missing = true
107
+ skip_covered = false
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,14 @@
1
+ """Swarm Seek: literature-validated Artificial Bee Colony optimization."""
2
+
3
+ from swarm_seek.abc import ABC
4
+ from swarm_seek.space import ContinuousSpace
5
+ from swarm_seek.types import Solution
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ __all__ = [
10
+ "ABC",
11
+ "ContinuousSpace",
12
+ "Solution",
13
+ "__version__",
14
+ ]
@@ -0,0 +1,144 @@
1
+ """Public Artificial Bee Colony façade."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable
6
+ from typing import Any
7
+
8
+ import numpy as np
9
+
10
+ from swarm_seek.backends import BackendProtocol
11
+ from swarm_seek.colony import Colony
12
+ from swarm_seek.errors import SwarmSeekError
13
+ from swarm_seek.space import Space
14
+ from swarm_seek.types import FloatArray, Sense, Solution
15
+ from swarm_seek.variants import VariantStrategy
16
+
17
+
18
+ class ABC:
19
+ """Ergonomic ask/tell façade around :class:`~swarm_seek.colony.Colony`.
20
+
21
+ Parameters match the design sketch: choose a registered ``variant``, a
22
+ ``space``, colony size / abandonment ``limit``, optimization ``sense``,
23
+ convergence budgets, RNG ``seed``, and execution ``backend``. Extra keyword
24
+ arguments are forwarded as variant parameters (e.g. ``C``, ``r``, ``MR``,
25
+ ``SF``).
26
+
27
+ Notes
28
+ -----
29
+ Power users may construct :class:`~swarm_seek.colony.Colony` directly.
30
+ ``minimize`` is convenience sugar over the ask/tell loop.
31
+ """
32
+
33
+ def __init__(
34
+ self,
35
+ space: Space,
36
+ *,
37
+ variant: str = "original",
38
+ strategy: VariantStrategy | None = None,
39
+ backend: BackendProtocol | str = "auto",
40
+ pop_size: int = 20,
41
+ limit: int = 100,
42
+ sense: Sense = "minimize",
43
+ max_evals: int | None = None,
44
+ max_iters: int | None = None,
45
+ stall_evals: int | None = None,
46
+ seed: int | None = None,
47
+ **variant_params: Any,
48
+ ) -> None:
49
+ self._colony = Colony(
50
+ space,
51
+ variant=variant if strategy is None else None,
52
+ strategy=strategy,
53
+ backend=backend,
54
+ pop_size=pop_size,
55
+ limit=limit,
56
+ sense=sense,
57
+ max_evals=max_evals,
58
+ max_iters=max_iters,
59
+ stall_evals=stall_evals,
60
+ seed=seed,
61
+ **variant_params,
62
+ )
63
+
64
+ @property
65
+ def colony(self) -> Colony:
66
+ """Underlying :class:`~swarm_seek.colony.Colony` engine."""
67
+ return self._colony
68
+
69
+ @property
70
+ def converged(self) -> bool:
71
+ """Whether a configured stopping criterion has been met."""
72
+ return self._colony.converged
73
+
74
+ @property
75
+ def best(self) -> Solution:
76
+ """Best solution found so far."""
77
+ return self._colony.best
78
+
79
+ @property
80
+ def n_evals(self) -> int:
81
+ """Objective evaluations consumed."""
82
+ return self._colony.n_evals
83
+
84
+ @property
85
+ def n_iters(self) -> int:
86
+ """Completed employed→onlooker→scout cycles."""
87
+ return self._colony.n_iters
88
+
89
+ def ask(self) -> FloatArray:
90
+ """Return candidates that need evaluation this step."""
91
+ return self._colony.ask()
92
+
93
+ def tell(self, fitnesses: FloatArray | list[float]) -> None:
94
+ """Consume objective values for the last ``ask`` batch."""
95
+ self._colony.tell(fitnesses)
96
+
97
+ def minimize(
98
+ self,
99
+ objective: Callable[[FloatArray], FloatArray | list[float]],
100
+ *,
101
+ max_evals: int | None = None,
102
+ max_iters: int | None = None,
103
+ stall_evals: int | None = None,
104
+ ) -> Solution:
105
+ """Run ask/tell until convergence and return the best solution.
106
+
107
+ Parameters
108
+ ----------
109
+ objective
110
+ Callable mapping candidate array ``(n, d)`` to fitnesses ``(n,)``.
111
+ max_evals, max_iters, stall_evals
112
+ Optional budget overrides applied only when the colony has not yet
113
+ started (no ``tell`` yet). If the run already started, existing
114
+ colony budgets are used and overrides are rejected.
115
+
116
+ Returns
117
+ -------
118
+ Solution
119
+ Best solution at termination.
120
+ """
121
+ if max_evals is not None or max_iters is not None or stall_evals is not None:
122
+ try:
123
+ self._colony.configure_budgets(
124
+ max_evals=max_evals,
125
+ max_iters=max_iters,
126
+ stall_evals=stall_evals,
127
+ )
128
+ except SwarmSeekError as exc:
129
+ msg = (
130
+ "Budget overrides to minimize() are only allowed before "
131
+ "the first ask/tell."
132
+ )
133
+ if "before the first ask" in str(exc):
134
+ raise SwarmSeekError(msg) from exc
135
+ raise
136
+
137
+ while not self._colony.converged:
138
+ candidates = self._colony.ask()
139
+ if candidates.size == 0:
140
+ self._colony.tell([])
141
+ continue
142
+ fitnesses = np.asarray(objective(candidates), dtype=np.float64)
143
+ self._colony.tell(fitnesses)
144
+ return self._colony.best
@@ -0,0 +1,11 @@
1
+ """Execution backends for population array operations (NumPy default)."""
2
+
3
+ from swarm_seek.backends.numpy_backend import NumpyBackend
4
+ from swarm_seek.backends.protocol import BackendProtocol
5
+ from swarm_seek.backends.registry import get_backend
6
+
7
+ __all__ = [
8
+ "BackendProtocol",
9
+ "NumpyBackend",
10
+ "get_backend",
11
+ ]