tyrannis 0.1.0a1__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 (46) hide show
  1. tyrannis-0.1.0a1/LICENSE +28 -0
  2. tyrannis-0.1.0a1/PKG-INFO +306 -0
  3. tyrannis-0.1.0a1/README.md +244 -0
  4. tyrannis-0.1.0a1/pyproject.toml +86 -0
  5. tyrannis-0.1.0a1/pyproject.toml.orig +110 -0
  6. tyrannis-0.1.0a1/src/tyrannis/__init__.py +5 -0
  7. tyrannis-0.1.0a1/src/tyrannis/algorithm/__init__.py +7 -0
  8. tyrannis-0.1.0a1/src/tyrannis/algorithm/bee_colony.py +529 -0
  9. tyrannis-0.1.0a1/src/tyrannis/algorithm/pso.py +377 -0
  10. tyrannis-0.1.0a1/src/tyrannis/backend/__init__.py +36 -0
  11. tyrannis-0.1.0a1/src/tyrannis/backend/distributed/__init__.py +0 -0
  12. tyrannis-0.1.0a1/src/tyrannis/backend/distributed/communication/__init__.py +0 -0
  13. tyrannis-0.1.0a1/src/tyrannis/backend/distributed/communication/no_communication.py +86 -0
  14. tyrannis-0.1.0a1/src/tyrannis/backend/distributed/communication/spark_communication.py +646 -0
  15. tyrannis-0.1.0a1/src/tyrannis/backend/distributed/spark_distributed.py +314 -0
  16. tyrannis-0.1.0a1/src/tyrannis/backend/local.py +69 -0
  17. tyrannis-0.1.0a1/src/tyrannis/backend/parallel/__init__.py +0 -0
  18. tyrannis-0.1.0a1/src/tyrannis/backend/parallel/spark_parallel.py +390 -0
  19. tyrannis-0.1.0a1/src/tyrannis/core/__init__.py +7 -0
  20. tyrannis-0.1.0a1/src/tyrannis/core/algorithm.py +654 -0
  21. tyrannis-0.1.0a1/src/tyrannis/core/backend.py +214 -0
  22. tyrannis-0.1.0a1/src/tyrannis/core/backend_communication.py +467 -0
  23. tyrannis-0.1.0a1/src/tyrannis/core/backend_distributed.py +283 -0
  24. tyrannis-0.1.0a1/src/tyrannis/core/backend_migration.py +793 -0
  25. tyrannis-0.1.0a1/src/tyrannis/core/backend_parallel.py +273 -0
  26. tyrannis-0.1.0a1/src/tyrannis/core/processor.py +498 -0
  27. tyrannis-0.1.0a1/src/tyrannis/core/results.py +50 -0
  28. tyrannis-0.1.0a1/src/tyrannis/core/signals.py +12 -0
  29. tyrannis-0.1.0a1/src/tyrannis/core/space.py +555 -0
  30. tyrannis-0.1.0a1/src/tyrannis/main.py +607 -0
  31. tyrannis-0.1.0a1/src/tyrannis/migration/__init__.py +7 -0
  32. tyrannis-0.1.0a1/src/tyrannis/migration/global_best.py +640 -0
  33. tyrannis-0.1.0a1/src/tyrannis/migration/island_isolation.py +108 -0
  34. tyrannis-0.1.0a1/src/tyrannis/migration/island_migration.py +1115 -0
  35. tyrannis-0.1.0a1/src/tyrannis/processor/__init__.py +9 -0
  36. tyrannis-0.1.0a1/src/tyrannis/processor/joblib.py +269 -0
  37. tyrannis-0.1.0a1/src/tyrannis/processor/process.py +303 -0
  38. tyrannis-0.1.0a1/src/tyrannis/processor/serial.py +108 -0
  39. tyrannis-0.1.0a1/src/tyrannis/processor/threads.py +174 -0
  40. tyrannis-0.1.0a1/src/tyrannis/space/__init__.py +28 -0
  41. tyrannis-0.1.0a1/src/tyrannis/space/binary.py +285 -0
  42. tyrannis-0.1.0a1/src/tyrannis/space/categorical.py +424 -0
  43. tyrannis-0.1.0a1/src/tyrannis/space/continuous.py +127 -0
  44. tyrannis-0.1.0a1/src/tyrannis/space/integer.py +276 -0
  45. tyrannis-0.1.0a1/src/tyrannis/space/mixed.py +194 -0
  46. tyrannis-0.1.0a1/src/tyrannis/space/permutation.py +480 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Samuel Carlos Pessoa Oliveira
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,306 @@
1
+ Metadata-Version: 2.3
2
+ Name: tyrannis
3
+ Version: 0.1.0a1
4
+ Summary: Flexible optimization framework for particle-based population algorithms, supporting diverse search spaces, optimization strategies, and execution backends.
5
+ Keywords: optimization,metaheuristics,population-based optimization,particle-based optimization,swarm intelligence,particle swarm optimization,PSO,artificial bee colony optimization,ABC,parallel optimization,distributed optimization,island model,mixed search space
6
+ Author: Samuel Carlos Pessoa Oliveira
7
+ License: BSD 3-Clause License
8
+
9
+ Copyright (c) 2026, Samuel Carlos Pessoa Oliveira
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice, this
15
+ list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright notice,
18
+ this list of conditions and the following disclaimer in the documentation
19
+ and/or other materials provided with the distribution.
20
+
21
+ 3. Neither the name of the copyright holder nor the names of its
22
+ contributors may be used to endorse or promote products derived from
23
+ this software without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
+ Classifier: Development Status :: 3 - Alpha
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: Intended Audience :: Science/Research
38
+ Classifier: License :: OSI Approved :: BSD License
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Programming Language :: Python :: 3.14
44
+ Classifier: Topic :: Scientific/Engineering
45
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
46
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
47
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
48
+ Requires-Dist: numpy>=2.1.3,<3.0.0
49
+ Requires-Dist: scipy>=1.15.3,<2.0.0
50
+ Requires-Dist: cloudpickle>=3.0.0,<4.0.0
51
+ Requires-Dist: joblib>=1.4.2,<2.0.0
52
+ Requires-Dist: cachetools>=5.5.1 ; extra == 'cache'
53
+ Requires-Dist: pyspark>=4.1.3 ; extra == 'spark'
54
+ Requires-Dist: pandas>=2.2.3 ; extra == 'spark'
55
+ Requires-Dist: pyarrow>=19.0.1 ; extra == 'spark'
56
+ Requires-Python: >=3.11, <=3.14
57
+ Project-URL: Repository, https://github.com/renard162/tyrannis_optimizer
58
+ Project-URL: Issues, https://github.com/renard162/tyrannis_optimizer/issues
59
+ Provides-Extra: cache
60
+ Provides-Extra: spark
61
+ Description-Content-Type: text/markdown
62
+
63
+ # Tyrannis
64
+
65
+ **A flexible metaheuristic optimization framework built for diverse search spaces and scalable execution.**
66
+
67
+ Tyrannis is a Python framework for solving optimization problems with population-based metaheuristic algorithms while keeping the problem definition independent from the execution strategy. Define your search space, choose an optimization algorithm, and decide how the workload should run—from a simple local execution to parallel or distributed processing. Tyrannis also provides support for mixed-variable optimization, allowing continuous, integer, binary, categorical, and permutation variables to coexist in the same problem.
68
+
69
+ ## Installation
70
+
71
+ ### Basic installation
72
+
73
+ For a local installation with the standard execution capabilities:
74
+
75
+ ```bash
76
+ pip install tyrannis
77
+ ```
78
+
79
+ This installation provides the core framework, including local execution and the basic LRU and disk caching mechanisms.
80
+
81
+ ### Advanced caching
82
+
83
+ To enable the additional caching capabilities:
84
+
85
+ ```bash
86
+ pip install "tyrannis[cache]"
87
+ ```
88
+
89
+ The `cache` extra installs the additional dependencies required by Tyrannis' advanced cache resources. Without this extra, only the basic LRU and disk cache mechanisms are available.
90
+
91
+ ### Distributed processing with Spark
92
+
93
+ To enable distributed processing with Spark:
94
+
95
+ ```bash
96
+ pip install "tyrannis[spark]"
97
+ ```
98
+
99
+ This installs the dependencies required by the Spark backend. Distributed execution with Spark requires an appropriate Spark infrastructure to be usable.
100
+
101
+ ### Combining extras
102
+
103
+ Extras can be installed together:
104
+
105
+ ```bash
106
+ pip install "tyrannis[cache,spark]"
107
+ ```
108
+
109
+ ## Public API
110
+
111
+ The core optimization requires only three components: an **optimizer**, a **search space**, and an **optimization algorithm**. The processor, backend, and migration components are optional and can be added to control how the optimization is executed, parallelized, distributed, and coordinated.
112
+
113
+ ### Algorithms
114
+
115
+ `tyrannis.algorithm`
116
+
117
+ Algorithms are the optimization methods used to search for the best solution within the defined search space.
118
+
119
+ | Import | Description |
120
+ | --------------------- | ----------------------------------------------------------------------------------------- |
121
+ | `PSO` | Particle Swarm Optimization algorithm for population-based continuous and encoded search. |
122
+ | `ArtificialBeeColony` | Artificial Bee Colony algorithm inspired by the foraging behavior of honey bees. |
123
+
124
+ ### Spaces
125
+
126
+ `tyrannis.space`
127
+
128
+ Spaces define the search space of the optimization problem, including the variables, their possible values or boundaries, and the cost function that is optimized.
129
+
130
+ | Import | Description |
131
+ | ------------- | -------------------------------------------------------------------------------------------------- |
132
+ | `Continuous` | Defines a continuous search space bounded by numerical lower and upper limits. |
133
+ | `Integer` | Defines an integer search space bounded by numerical lower and upper limits. |
134
+ | `Binary` | Defines a binary search space whose variables can take the values `0` or `1`. |
135
+ | `Categorical` | Defines a categorical search space based on a finite set of discrete choices. |
136
+ | `Permutation` | Defines a search space for permutation-based optimization problems. |
137
+ | `Mixed` | Combines multiple search spaces, allowing optimization problems with heterogeneous variable types. |
138
+
139
+ ### Processors
140
+
141
+ `tyrannis.processor`
142
+
143
+ Processors define how the optimization algorithm is executed on each machine involved in the optimization, including whether particle processing is performed serially or in parallel.
144
+
145
+ | Import | Description |
146
+ | ------------- | ------------------------------------------------------------ |
147
+ | `Joblib` | Executes particle processing using Joblib-based parallelism. |
148
+ | `ProcessPool` | Executes particle processing using multiple processes. |
149
+ | `ThreadsPool` | Executes particle processing using a pool of threads. |
150
+
151
+ ### Backends
152
+
153
+ `tyrannis.backend`
154
+
155
+ Backends define how the processing of the optimization algorithm is distributed between machines, determining how the optimization workload and population are organized across the available execution resources.
156
+
157
+ | Import | Description |
158
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
159
+ | `SparkParallel` | Executes optimization using distributed processing with Spark on a single island. |
160
+ | `SparkDistributed` | Executes optimization using distributed processing with Spark across multiple islands, supporting distributed population and migration. |
161
+
162
+ ### Migrations
163
+
164
+ `tyrannis.migration`
165
+
166
+ Migrations define how the machines participating in distributed optimization communicate and exchange information about the optimization process, allowing solutions to move between islands.
167
+
168
+ | Import | Description |
169
+ | ----------------- | ----------------------------------------------------------------------------------------------- |
170
+ | `GlobalBest` | Shares the globally best solution between islands during distributed optimization. |
171
+ | `IslandMigration` | Provides migration of solutions between islands according to the configured migration strategy. |
172
+
173
+ ## Examples
174
+
175
+ ### Basic optimization
176
+
177
+ A simple continuous optimization problem can be configured by defining a search space, selecting an algorithm, and creating an optimizer:
178
+
179
+ ```python
180
+ from tyrannis import Optimizer
181
+ from tyrannis.algorithm import PSO
182
+ from tyrannis.space import Continuous
183
+
184
+
185
+ def cost_function(x, y):
186
+ return x**2 + y**2
187
+
188
+
189
+ space = Continuous(
190
+ boundaries={"x": (-10, 10), "y": (-10, 10)},
191
+ cost_function=cost_function
192
+ )
193
+
194
+ algorithm = PSO()
195
+
196
+ optimizer = Optimizer(
197
+ space=space,
198
+ algorithm=algorithm,
199
+ n_iterations=100,
200
+ n_particles=50
201
+ )
202
+
203
+ optimizer.fit()
204
+
205
+ print(optimizer.best_solution)
206
+ # {"x": 0.0, "y": 0.0}
207
+
208
+ print(optimizer.best_fitness)
209
+ # 0.0
210
+ ```
211
+
212
+ ### Mixed search space and parallel processing
213
+
214
+ Tyrannis can combine different variable types in the same optimization problem. In this example, a continuous variable and a categorical variable are optimized together using the Artificial Bee Colony algorithm and a Joblib processor:
215
+
216
+ ```python
217
+ from tyrannis import Optimizer
218
+ from tyrannis.algorithm import ArtificialBeeColony
219
+ from tyrannis.processor import Joblib
220
+ from tyrannis.space import Categorical, Continuous, Mixed
221
+
222
+
223
+ def cost_function(x, category):
224
+ category_target = {
225
+ "low": 0.0,
226
+ "medium": 1.0,
227
+ "high": 2.0,
228
+ }
229
+ return (x - category_target[category]) ** 2
230
+
231
+
232
+ space = Mixed(
233
+ spaces={
234
+ "x": Continuous((-5.0, 5.0)),
235
+ "category": Categorical(("low", "medium", "high"))
236
+ },
237
+ cost_function=cost_function
238
+ )
239
+
240
+ algorithm = ArtificialBeeColony()
241
+ processor = Joblib(joblib_backend="loky")
242
+
243
+ optimizer = Optimizer(
244
+ space=space,
245
+ algorithm=algorithm,
246
+ processor=processor,
247
+ n_iterations=100,
248
+ n_particles=50
249
+ )
250
+
251
+ optimizer.fit()
252
+
253
+ print(optimizer.best_solution)
254
+ # {"x": 0.0, "category": "low"}
255
+
256
+ print(optimizer.best_fitness)
257
+ # 0.0
258
+ ```
259
+
260
+ In this example, no backend is specified, so the optimization runs locally. The `Joblib` processor parallelizes particle evaluation across the available CPUs.
261
+
262
+ ## Status
263
+
264
+ Tyrannis is currently in the **alpha stage of development**. The core architecture and initial optimization capabilities are already available, but the API and implementation are still evolving.
265
+
266
+ The following features are planned for future releases.
267
+
268
+ ### Roadmap
269
+
270
+ #### Algorithms
271
+
272
+ * PSOGSA
273
+ * Genetic Algorithm
274
+ * GSA — Gravitational Search Algorithm
275
+ * Differential Evolution
276
+ * CMA-ES — Covariance Matrix Adaptation Evolution Strategy
277
+ * Ant Colony Optimization
278
+ * Grey Wolf Optimization
279
+ * Whale Optimization Algorithm
280
+
281
+ #### Spaces
282
+
283
+ * Ordinal
284
+ * Set
285
+ * Graph
286
+
287
+ #### Backends
288
+
289
+ * MPI
290
+ * Ray
291
+ * Dask
292
+
293
+ #### Migration
294
+
295
+ * Diffusion
296
+
297
+ #### Testing
298
+
299
+ * Construction and maintenance of unit tests
300
+ * Construction and maintenance of integration tests
301
+ * Increased coverage of algorithms, spaces, processors, backends, and migration strategies
302
+ * Validation of distributed execution behavior
303
+
304
+ ## License
305
+
306
+ Tyrannis is distributed under the BSD 3-Clause License.
@@ -0,0 +1,244 @@
1
+ # Tyrannis
2
+
3
+ **A flexible metaheuristic optimization framework built for diverse search spaces and scalable execution.**
4
+
5
+ Tyrannis is a Python framework for solving optimization problems with population-based metaheuristic algorithms while keeping the problem definition independent from the execution strategy. Define your search space, choose an optimization algorithm, and decide how the workload should run—from a simple local execution to parallel or distributed processing. Tyrannis also provides support for mixed-variable optimization, allowing continuous, integer, binary, categorical, and permutation variables to coexist in the same problem.
6
+
7
+ ## Installation
8
+
9
+ ### Basic installation
10
+
11
+ For a local installation with the standard execution capabilities:
12
+
13
+ ```bash
14
+ pip install tyrannis
15
+ ```
16
+
17
+ This installation provides the core framework, including local execution and the basic LRU and disk caching mechanisms.
18
+
19
+ ### Advanced caching
20
+
21
+ To enable the additional caching capabilities:
22
+
23
+ ```bash
24
+ pip install "tyrannis[cache]"
25
+ ```
26
+
27
+ The `cache` extra installs the additional dependencies required by Tyrannis' advanced cache resources. Without this extra, only the basic LRU and disk cache mechanisms are available.
28
+
29
+ ### Distributed processing with Spark
30
+
31
+ To enable distributed processing with Spark:
32
+
33
+ ```bash
34
+ pip install "tyrannis[spark]"
35
+ ```
36
+
37
+ This installs the dependencies required by the Spark backend. Distributed execution with Spark requires an appropriate Spark infrastructure to be usable.
38
+
39
+ ### Combining extras
40
+
41
+ Extras can be installed together:
42
+
43
+ ```bash
44
+ pip install "tyrannis[cache,spark]"
45
+ ```
46
+
47
+ ## Public API
48
+
49
+ The core optimization requires only three components: an **optimizer**, a **search space**, and an **optimization algorithm**. The processor, backend, and migration components are optional and can be added to control how the optimization is executed, parallelized, distributed, and coordinated.
50
+
51
+ ### Algorithms
52
+
53
+ `tyrannis.algorithm`
54
+
55
+ Algorithms are the optimization methods used to search for the best solution within the defined search space.
56
+
57
+ | Import | Description |
58
+ | --------------------- | ----------------------------------------------------------------------------------------- |
59
+ | `PSO` | Particle Swarm Optimization algorithm for population-based continuous and encoded search. |
60
+ | `ArtificialBeeColony` | Artificial Bee Colony algorithm inspired by the foraging behavior of honey bees. |
61
+
62
+ ### Spaces
63
+
64
+ `tyrannis.space`
65
+
66
+ Spaces define the search space of the optimization problem, including the variables, their possible values or boundaries, and the cost function that is optimized.
67
+
68
+ | Import | Description |
69
+ | ------------- | -------------------------------------------------------------------------------------------------- |
70
+ | `Continuous` | Defines a continuous search space bounded by numerical lower and upper limits. |
71
+ | `Integer` | Defines an integer search space bounded by numerical lower and upper limits. |
72
+ | `Binary` | Defines a binary search space whose variables can take the values `0` or `1`. |
73
+ | `Categorical` | Defines a categorical search space based on a finite set of discrete choices. |
74
+ | `Permutation` | Defines a search space for permutation-based optimization problems. |
75
+ | `Mixed` | Combines multiple search spaces, allowing optimization problems with heterogeneous variable types. |
76
+
77
+ ### Processors
78
+
79
+ `tyrannis.processor`
80
+
81
+ Processors define how the optimization algorithm is executed on each machine involved in the optimization, including whether particle processing is performed serially or in parallel.
82
+
83
+ | Import | Description |
84
+ | ------------- | ------------------------------------------------------------ |
85
+ | `Joblib` | Executes particle processing using Joblib-based parallelism. |
86
+ | `ProcessPool` | Executes particle processing using multiple processes. |
87
+ | `ThreadsPool` | Executes particle processing using a pool of threads. |
88
+
89
+ ### Backends
90
+
91
+ `tyrannis.backend`
92
+
93
+ Backends define how the processing of the optimization algorithm is distributed between machines, determining how the optimization workload and population are organized across the available execution resources.
94
+
95
+ | Import | Description |
96
+ | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | `SparkParallel` | Executes optimization using distributed processing with Spark on a single island. |
98
+ | `SparkDistributed` | Executes optimization using distributed processing with Spark across multiple islands, supporting distributed population and migration. |
99
+
100
+ ### Migrations
101
+
102
+ `tyrannis.migration`
103
+
104
+ Migrations define how the machines participating in distributed optimization communicate and exchange information about the optimization process, allowing solutions to move between islands.
105
+
106
+ | Import | Description |
107
+ | ----------------- | ----------------------------------------------------------------------------------------------- |
108
+ | `GlobalBest` | Shares the globally best solution between islands during distributed optimization. |
109
+ | `IslandMigration` | Provides migration of solutions between islands according to the configured migration strategy. |
110
+
111
+ ## Examples
112
+
113
+ ### Basic optimization
114
+
115
+ A simple continuous optimization problem can be configured by defining a search space, selecting an algorithm, and creating an optimizer:
116
+
117
+ ```python
118
+ from tyrannis import Optimizer
119
+ from tyrannis.algorithm import PSO
120
+ from tyrannis.space import Continuous
121
+
122
+
123
+ def cost_function(x, y):
124
+ return x**2 + y**2
125
+
126
+
127
+ space = Continuous(
128
+ boundaries={"x": (-10, 10), "y": (-10, 10)},
129
+ cost_function=cost_function
130
+ )
131
+
132
+ algorithm = PSO()
133
+
134
+ optimizer = Optimizer(
135
+ space=space,
136
+ algorithm=algorithm,
137
+ n_iterations=100,
138
+ n_particles=50
139
+ )
140
+
141
+ optimizer.fit()
142
+
143
+ print(optimizer.best_solution)
144
+ # {"x": 0.0, "y": 0.0}
145
+
146
+ print(optimizer.best_fitness)
147
+ # 0.0
148
+ ```
149
+
150
+ ### Mixed search space and parallel processing
151
+
152
+ Tyrannis can combine different variable types in the same optimization problem. In this example, a continuous variable and a categorical variable are optimized together using the Artificial Bee Colony algorithm and a Joblib processor:
153
+
154
+ ```python
155
+ from tyrannis import Optimizer
156
+ from tyrannis.algorithm import ArtificialBeeColony
157
+ from tyrannis.processor import Joblib
158
+ from tyrannis.space import Categorical, Continuous, Mixed
159
+
160
+
161
+ def cost_function(x, category):
162
+ category_target = {
163
+ "low": 0.0,
164
+ "medium": 1.0,
165
+ "high": 2.0,
166
+ }
167
+ return (x - category_target[category]) ** 2
168
+
169
+
170
+ space = Mixed(
171
+ spaces={
172
+ "x": Continuous((-5.0, 5.0)),
173
+ "category": Categorical(("low", "medium", "high"))
174
+ },
175
+ cost_function=cost_function
176
+ )
177
+
178
+ algorithm = ArtificialBeeColony()
179
+ processor = Joblib(joblib_backend="loky")
180
+
181
+ optimizer = Optimizer(
182
+ space=space,
183
+ algorithm=algorithm,
184
+ processor=processor,
185
+ n_iterations=100,
186
+ n_particles=50
187
+ )
188
+
189
+ optimizer.fit()
190
+
191
+ print(optimizer.best_solution)
192
+ # {"x": 0.0, "category": "low"}
193
+
194
+ print(optimizer.best_fitness)
195
+ # 0.0
196
+ ```
197
+
198
+ In this example, no backend is specified, so the optimization runs locally. The `Joblib` processor parallelizes particle evaluation across the available CPUs.
199
+
200
+ ## Status
201
+
202
+ Tyrannis is currently in the **alpha stage of development**. The core architecture and initial optimization capabilities are already available, but the API and implementation are still evolving.
203
+
204
+ The following features are planned for future releases.
205
+
206
+ ### Roadmap
207
+
208
+ #### Algorithms
209
+
210
+ * PSOGSA
211
+ * Genetic Algorithm
212
+ * GSA — Gravitational Search Algorithm
213
+ * Differential Evolution
214
+ * CMA-ES — Covariance Matrix Adaptation Evolution Strategy
215
+ * Ant Colony Optimization
216
+ * Grey Wolf Optimization
217
+ * Whale Optimization Algorithm
218
+
219
+ #### Spaces
220
+
221
+ * Ordinal
222
+ * Set
223
+ * Graph
224
+
225
+ #### Backends
226
+
227
+ * MPI
228
+ * Ray
229
+ * Dask
230
+
231
+ #### Migration
232
+
233
+ * Diffusion
234
+
235
+ #### Testing
236
+
237
+ * Construction and maintenance of unit tests
238
+ * Construction and maintenance of integration tests
239
+ * Increased coverage of algorithms, spaces, processors, backends, and migration strategies
240
+ * Validation of distributed execution behavior
241
+
242
+ ## License
243
+
244
+ Tyrannis is distributed under the BSD 3-Clause License.
@@ -0,0 +1,86 @@
1
+ [project]
2
+ name = "tyrannis"
3
+ version = "0.1.0a1"
4
+ description = "Flexible optimization framework for particle-based population algorithms, supporting diverse search spaces, optimization strategies, and execution backends."
5
+ readme = "README.md"
6
+ classifiers = [
7
+ "Development Status :: 3 - Alpha",
8
+ "Intended Audience :: Developers",
9
+ "Intended Audience :: Science/Research",
10
+ "License :: OSI Approved :: BSD License",
11
+ "Programming Language :: Python :: 3",
12
+ "Programming Language :: Python :: 3.11",
13
+ "Programming Language :: Python :: 3.12",
14
+ "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
16
+ "Topic :: Scientific/Engineering",
17
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
18
+ "Topic :: Scientific/Engineering :: Information Analysis",
19
+ "Topic :: Scientific/Engineering :: Mathematics",
20
+ ]
21
+ keywords = [
22
+ "optimization",
23
+ "metaheuristics",
24
+ "population-based optimization",
25
+ "particle-based optimization",
26
+ "swarm intelligence",
27
+ "particle swarm optimization",
28
+ "PSO",
29
+ "artificial bee colony optimization",
30
+ "ABC",
31
+ "parallel optimization",
32
+ "distributed optimization",
33
+ "island model",
34
+ "mixed search space",
35
+ ]
36
+ requires-python = ">=3.11,<=3.14"
37
+ dependencies = [
38
+ "numpy>=2.1.3,<3.0.0",
39
+ "scipy>=1.15.3,<2.0.0",
40
+ "cloudpickle>=3.0.0,<4.0.0",
41
+ "joblib>=1.4.2,<2.0.0",
42
+ ]
43
+
44
+ [project.license]
45
+ file = "LICENSE"
46
+
47
+ [[project.authors]]
48
+ name = "Samuel Carlos Pessoa Oliveira"
49
+
50
+ [project.optional-dependencies]
51
+ cache = ["cachetools>=5.5.1"]
52
+ spark = [
53
+ "pyspark>=4.1.3",
54
+ "pandas>=2.2.3",
55
+ "pyarrow>=19.0.1",
56
+ ]
57
+
58
+ [project.urls]
59
+ Repository = "https://github.com/renard162/tyrannis_optimizer"
60
+ Issues = "https://github.com/renard162/tyrannis_optimizer/issues"
61
+
62
+ [project.scripts]
63
+ tyrannis = "tyrannis:main"
64
+
65
+ [build-system]
66
+ requires = ["uv_build>=0.12.5,<0.13.0"]
67
+ build-backend = "uv_build"
68
+
69
+ [dependency-groups]
70
+ dev = [
71
+ "coverage>=7.16.0",
72
+ "pytest>=9.1.1",
73
+ "pytest-cov>=7.1.0",
74
+ ]
75
+
76
+ [tool.pytest.ini_options]
77
+ testpaths = [
78
+ "tests/unit",
79
+ "tests/integration",
80
+ ]
81
+ pythonpath = ["tests"]
82
+ addopts = "--import-mode=importlib"
83
+
84
+ [tool.coverage.run]
85
+ branch = true
86
+ omit = ["src/tyrannis/examples/*"]