otorchmizer 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.
- otorchmizer-1.0.0/LICENSE +21 -0
- otorchmizer-1.0.0/PKG-INFO +356 -0
- otorchmizer-1.0.0/README.md +319 -0
- otorchmizer-1.0.0/otorchmizer/__init__.py +5 -0
- otorchmizer-1.0.0/otorchmizer/core/__init__.py +10 -0
- otorchmizer-1.0.0/otorchmizer/core/agent_view.py +89 -0
- otorchmizer-1.0.0/otorchmizer/core/block.py +145 -0
- otorchmizer-1.0.0/otorchmizer/core/device.py +223 -0
- otorchmizer-1.0.0/otorchmizer/core/function.py +94 -0
- otorchmizer-1.0.0/otorchmizer/core/node.py +360 -0
- otorchmizer-1.0.0/otorchmizer/core/optimizer.py +175 -0
- otorchmizer-1.0.0/otorchmizer/core/population.py +250 -0
- otorchmizer-1.0.0/otorchmizer/core/space.py +131 -0
- otorchmizer-1.0.0/otorchmizer/functions/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/functions/constrained.py +87 -0
- otorchmizer-1.0.0/otorchmizer/functions/multi_objective/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/functions/multi_objective/standard.py +52 -0
- otorchmizer-1.0.0/otorchmizer/functions/multi_objective/weighted.py +58 -0
- otorchmizer-1.0.0/otorchmizer/math/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/math/distribution.py +81 -0
- otorchmizer-1.0.0/otorchmizer/math/general.py +138 -0
- otorchmizer-1.0.0/otorchmizer/math/hyper.py +74 -0
- otorchmizer-1.0.0/otorchmizer/math/random.py +156 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/boolean/__init__.py +3 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/boolean/boolean.py +174 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/__init__.py +11 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/bsa.py +96 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/de.py +93 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/ep.py +102 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/es.py +94 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/foa.py +172 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/ga.py +152 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/hs.py +273 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/iwo.py +129 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/evolutionary/rra.py +136 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/__init__.py +7 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/aoa.py +112 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/cem.py +94 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/doa.py +90 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/gs.py +33 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/misc/hc.py +73 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/__init__.py +13 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/aeo.py +99 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/ao.py +104 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/coa.py +105 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/epo.py +87 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/gco.py +103 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/gwo.py +70 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/hho.py +108 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/osa.py +72 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/ppa.py +99 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/pvs.py +81 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/population/rfo.py +121 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/__init__.py +23 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/aso.py +90 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/bh.py +61 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/eo.py +132 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/gsa.py +86 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/mvo.py +108 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/sa.py +83 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/science_extra.py +547 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/wca.py +119 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/science/wdo.py +85 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/social/__init__.py +3 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/social/social.py +370 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/__init__.py +31 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/abc.py +123 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/abo.py +88 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/af.py +102 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/ba.py +123 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/boa.py +94 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/bwo.py +122 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/cs.py +110 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/csa.py +101 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/eho.py +110 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/fa.py +126 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/ffoa.py +65 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/fpa.py +105 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/fso.py +134 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/goa.py +113 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/js.py +107 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/kh.py +161 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/mfo.py +76 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/mrfo.py +105 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/pio.py +90 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/pso.py +335 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/sbo.py +108 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/sca.py +78 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/sfo.py +119 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/sos.py +100 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/ssa.py +60 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/sso.py +129 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/stoa.py +74 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/waoa.py +76 -0
- otorchmizer-1.0.0/otorchmizer/optimizers/swarm/woa.py +90 -0
- otorchmizer-1.0.0/otorchmizer/otorchmizer.py +197 -0
- otorchmizer-1.0.0/otorchmizer/spaces/__init__.py +9 -0
- otorchmizer-1.0.0/otorchmizer/spaces/boolean.py +45 -0
- otorchmizer-1.0.0/otorchmizer/spaces/graph.py +22 -0
- otorchmizer-1.0.0/otorchmizer/spaces/grid.py +88 -0
- otorchmizer-1.0.0/otorchmizer/spaces/hyper_complex.py +48 -0
- otorchmizer-1.0.0/otorchmizer/spaces/pareto.py +61 -0
- otorchmizer-1.0.0/otorchmizer/spaces/search.py +47 -0
- otorchmizer-1.0.0/otorchmizer/spaces/tree.py +136 -0
- otorchmizer-1.0.0/otorchmizer/utils/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/utils/callback.py +135 -0
- otorchmizer-1.0.0/otorchmizer/utils/constant.py +30 -0
- otorchmizer-1.0.0/otorchmizer/utils/exception.py +51 -0
- otorchmizer-1.0.0/otorchmizer/utils/history.py +109 -0
- otorchmizer-1.0.0/otorchmizer/utils/logging.py +63 -0
- otorchmizer-1.0.0/otorchmizer/visualization/__init__.py +1 -0
- otorchmizer-1.0.0/otorchmizer/visualization/convergence.py +68 -0
- otorchmizer-1.0.0/otorchmizer/visualization/surface.py +54 -0
- otorchmizer-1.0.0/otorchmizer.egg-info/PKG-INFO +356 -0
- otorchmizer-1.0.0/otorchmizer.egg-info/SOURCES.txt +142 -0
- otorchmizer-1.0.0/otorchmizer.egg-info/dependency_links.txt +1 -0
- otorchmizer-1.0.0/otorchmizer.egg-info/requires.txt +12 -0
- otorchmizer-1.0.0/otorchmizer.egg-info/top_level.txt +2 -0
- otorchmizer-1.0.0/pyproject.toml +64 -0
- otorchmizer-1.0.0/setup.cfg +4 -0
- otorchmizer-1.0.0/setup.py +3 -0
- otorchmizer-1.0.0/tests/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/core/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/core/test_block.py +103 -0
- otorchmizer-1.0.0/tests/otorchmizer/core/test_core.py +175 -0
- otorchmizer-1.0.0/tests/otorchmizer/core/test_new_features.py +318 -0
- otorchmizer-1.0.0/tests/otorchmizer/core/test_node.py +204 -0
- otorchmizer-1.0.0/tests/otorchmizer/functions/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/functions/test_functions.py +172 -0
- otorchmizer-1.0.0/tests/otorchmizer/math/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/math/test_math.py +103 -0
- otorchmizer-1.0.0/tests/otorchmizer/optimizers/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/optimizers/test_all_optimizers.py +208 -0
- otorchmizer-1.0.0/tests/otorchmizer/optimizers/test_optimizers.py +226 -0
- otorchmizer-1.0.0/tests/otorchmizer/spaces/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/spaces/test_spaces.py +191 -0
- otorchmizer-1.0.0/tests/otorchmizer/test_integration.py +73 -0
- otorchmizer-1.0.0/tests/otorchmizer/test_regressions.py +215 -0
- otorchmizer-1.0.0/tests/otorchmizer/utils/__init__.py +1 -0
- otorchmizer-1.0.0/tests/otorchmizer/utils/test_utils.py +257 -0
- otorchmizer-1.0.0/tests/otorchmizer/visualization/__init__.py +0 -0
- otorchmizer-1.0.0/tests/otorchmizer/visualization/test_visualization.py +90 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Gustavo de Rosa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: otorchmizer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A PyTorch-based library for nature-inspired meta-heuristic optimization
|
|
5
|
+
Author-email: Gustavo Rosa <gustavo.rosa@unesp.br>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/gugarosa/otorchmizer
|
|
8
|
+
Project-URL: Documentation, https://otorchmizer.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/gugarosa/otorchmizer
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/gugarosa/otorchmizer/issues
|
|
11
|
+
Keywords: optimization,meta-heuristic,pytorch,gpu,nature-inspired
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: torch>=2.0.0
|
|
26
|
+
Requires-Dist: matplotlib>=3.5.0
|
|
27
|
+
Requires-Dist: networkx>=2.8
|
|
28
|
+
Requires-Dist: tqdm>=4.60.0
|
|
29
|
+
Requires-Dist: dill>=0.3.6
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-benchmark; extra == "dev"
|
|
33
|
+
Requires-Dist: coverage>=6.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pre-commit>=3.0; extra == "dev"
|
|
35
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# Otorchmizer: A PyTorch-Powered Nature-Inspired Optimizer
|
|
39
|
+
|
|
40
|
+
[](https://www.python.org/downloads/)
|
|
41
|
+
[](https://pytorch.org/)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
|
|
44
|
+
## Welcome to Otorchmizer.
|
|
45
|
+
|
|
46
|
+
Did you ever reach a bottleneck in your computational experiments? Are you tired of waiting hours for meta-heuristic optimization runs? If yes, Otorchmizer is the real deal! This package provides an easy-to-go implementation of **91 meta-heuristic optimization algorithms** — all powered by PyTorch tensors for GPU-accelerated performance. From populations to search spaces, from internal functions to external communication, we will foster all research related to optimizing stuff.
|
|
47
|
+
|
|
48
|
+
Otorchmizer is the modernized successor to [Opytimizer](https://github.com/gugarosa/opytimizer), delivering **up to 2,311× speedup** by replacing NumPy with PyTorch.
|
|
49
|
+
|
|
50
|
+
Use Otorchmizer if you need a library or wish to:
|
|
51
|
+
* Create your optimization algorithm with automatic GPU support;
|
|
52
|
+
* Design or use pre-loaded optimization tasks at scale;
|
|
53
|
+
* Run the same code on CPU, single-GPU, or multi-GPU seamlessly;
|
|
54
|
+
* Leverage `torch.compile` and CUDA Graphs for maximum throughput;
|
|
55
|
+
* Mix-and-match different strategies to solve your problem;
|
|
56
|
+
* Because it is fun to optimize things — even faster.
|
|
57
|
+
|
|
58
|
+
Otorchmizer is compatible with: **Python 3.10+** and **PyTorch 2.0+**.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Package guidelines
|
|
63
|
+
|
|
64
|
+
1. The very first information you need is in the very **next** section.
|
|
65
|
+
2. **Installing** is also easy if you wish to read the code and bump yourself into, follow along.
|
|
66
|
+
3. Note that there might be some **additional** steps in order to use our solutions.
|
|
67
|
+
4. If there is a problem, please do not **hesitate**, call us.
|
|
68
|
+
5. Finally, we focus on **minimization**. Take that in mind when designing your problem.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Citation
|
|
73
|
+
|
|
74
|
+
If you use Otorchmizer to fulfill any of your needs, please cite the original Opytimizer paper:
|
|
75
|
+
|
|
76
|
+
```BibTex
|
|
77
|
+
@misc{rosa2019opytimizer,
|
|
78
|
+
title={Opytimizer: A Nature-Inspired Python Optimizer},
|
|
79
|
+
author={Gustavo H. de Rosa, Douglas Rodrigues and João P. Papa},
|
|
80
|
+
year={2019},
|
|
81
|
+
eprint={1912.13002},
|
|
82
|
+
archivePrefix={arXiv},
|
|
83
|
+
primaryClass={cs.NE}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Getting started: 60 seconds with Otorchmizer
|
|
90
|
+
|
|
91
|
+
First of all. We have examples. Yes, they are commented. Just browse to `examples/`, chose your subpackage, and follow the example. We have high-level examples for most tasks we could think of, including GPU acceleration, `torch.compile`, and multi-GPU population splitting.
|
|
92
|
+
|
|
93
|
+
Alternatively, if you wish to learn even more, please take a minute:
|
|
94
|
+
|
|
95
|
+
Otorchmizer is based on the following structure, and you should pay attention to its tree:
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
- otorchmizer
|
|
99
|
+
- core
|
|
100
|
+
- agent_view
|
|
101
|
+
- block
|
|
102
|
+
- device
|
|
103
|
+
- function
|
|
104
|
+
- node
|
|
105
|
+
- optimizer
|
|
106
|
+
- population
|
|
107
|
+
- space
|
|
108
|
+
- functions
|
|
109
|
+
- constrained
|
|
110
|
+
- multi_objective
|
|
111
|
+
- math
|
|
112
|
+
- distribution
|
|
113
|
+
- general
|
|
114
|
+
- hyper
|
|
115
|
+
- random
|
|
116
|
+
- optimizers
|
|
117
|
+
- boolean
|
|
118
|
+
- evolutionary
|
|
119
|
+
- misc
|
|
120
|
+
- population
|
|
121
|
+
- science
|
|
122
|
+
- social
|
|
123
|
+
- swarm
|
|
124
|
+
- spaces
|
|
125
|
+
- boolean
|
|
126
|
+
- graph
|
|
127
|
+
- grid
|
|
128
|
+
- hyper_complex
|
|
129
|
+
- pareto
|
|
130
|
+
- search
|
|
131
|
+
- tree
|
|
132
|
+
- utils
|
|
133
|
+
- callback
|
|
134
|
+
- constant
|
|
135
|
+
- exception
|
|
136
|
+
- history
|
|
137
|
+
- logging
|
|
138
|
+
- visualization
|
|
139
|
+
- convergence
|
|
140
|
+
- surface
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Core
|
|
144
|
+
|
|
145
|
+
Core is the core. Essentially, it is the parent of everything. You should find parent classes defining the basis of our structure. They should provide variables and methods that will help to construct other modules. The key innovation is the **Population** class, which stores all agent data as contiguous PyTorch tensors `(n_agents, n_variables, n_dimensions)`, enabling vectorized operations and GPU parallelism. Also featured here is the **DeviceManager**, which handles CPU/GPU/multi-GPU resolution, mixed-precision, and CUDA Graph capture.
|
|
146
|
+
|
|
147
|
+
### Functions
|
|
148
|
+
|
|
149
|
+
Instead of using raw and straightforward functions, why not try this module? Compose high-level abstract functions or even new function-based ideas in order to solve your problems. Functions are auto-vectorized across the entire population via `torch.vmap` — you write a single-agent function, and we handle the batching.
|
|
150
|
+
|
|
151
|
+
### Math
|
|
152
|
+
|
|
153
|
+
Just because we are computing stuff does not mean that we do not need math. Math is the mathematical package containing low-level math implementations. From random numbers to distribution generation, you can find your needs on this module — all backed by PyTorch tensors for device-agnostic computation.
|
|
154
|
+
|
|
155
|
+
### Optimizers
|
|
156
|
+
|
|
157
|
+
This is why we are called Otorchmizer. This is the heart of heuristics, where you can find **91 meta-heuristic optimization techniques** across 7 families — swarm intelligence, evolutionary algorithms, science-inspired methods, and more. Every algorithm uses batched tensor operations, meaning the same code runs on CPU and GPU without modification.
|
|
158
|
+
|
|
159
|
+
### Spaces
|
|
160
|
+
|
|
161
|
+
One can see the space as the place that agents will update their positions and evaluate a fitness function. However, the newest approaches may consider a different type of space. Thinking about that, we are glad to support diverse space implementations.
|
|
162
|
+
|
|
163
|
+
### Utils
|
|
164
|
+
|
|
165
|
+
This is a utility package. Common things shared across the application should be implemented here. It is better to implement once and use as you wish than re-implementing the same thing repeatedly.
|
|
166
|
+
|
|
167
|
+
### Visualization
|
|
168
|
+
|
|
169
|
+
Everyone needs images and plots to help visualize what is happening, correct? This package will provide every visual-related method for you. Check a specific variable convergence, your fitness function convergence, plot benchmark function surfaces, and much more!
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Installation
|
|
174
|
+
|
|
175
|
+
We believe that everything has to be easy. Not tricky or daunting, Otorchmizer will be the one-to-go package that you will need, from the first installation to the daily tasks implementing needs. If you may just run the following under your most preferred Python environment (raw, conda, virtualenv, whatever):
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
pip install -e .
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Environment configuration
|
|
184
|
+
|
|
185
|
+
Note that sometimes, there is a need for additional implementation. If needed, from here, you will be the one to know all of its details.
|
|
186
|
+
|
|
187
|
+
### Ubuntu
|
|
188
|
+
|
|
189
|
+
No specific additional commands are needed.
|
|
190
|
+
|
|
191
|
+
### Windows
|
|
192
|
+
|
|
193
|
+
No specific additional commands are needed.
|
|
194
|
+
|
|
195
|
+
### MacOS
|
|
196
|
+
|
|
197
|
+
No specific additional commands are needed.
|
|
198
|
+
|
|
199
|
+
### GPU Support
|
|
200
|
+
|
|
201
|
+
For GPU acceleration, install PyTorch with CUDA support:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
pip install torch --index-url https://download.pytorch.org/whl/cu121
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## How-To-Use: Minimal Example
|
|
210
|
+
|
|
211
|
+
Take a look at a quick working example of Otorchmizer. Note that we are not passing many extra arguments nor additional information to the procedure. For more complex examples, please check our `examples/` folder.
|
|
212
|
+
|
|
213
|
+
```python
|
|
214
|
+
import torch
|
|
215
|
+
|
|
216
|
+
from otorchmizer import Otorchmizer
|
|
217
|
+
from otorchmizer.core import Function, Space
|
|
218
|
+
from otorchmizer.optimizers.swarm import PSO
|
|
219
|
+
|
|
220
|
+
def sphere(x):
|
|
221
|
+
return (x ** 2).sum(dim=(-1, -2))
|
|
222
|
+
|
|
223
|
+
n_agents = 20
|
|
224
|
+
n_variables = 2
|
|
225
|
+
lower_bound = [-10, -10]
|
|
226
|
+
upper_bound = [10, 10]
|
|
227
|
+
|
|
228
|
+
space = Space(n_agents=n_agents, n_variables=n_variables,
|
|
229
|
+
lower_bound=lower_bound, upper_bound=upper_bound)
|
|
230
|
+
space.build()
|
|
231
|
+
|
|
232
|
+
optimizer = PSO()
|
|
233
|
+
function = Function(sphere)
|
|
234
|
+
|
|
235
|
+
opt = Otorchmizer(space, optimizer, function)
|
|
236
|
+
opt.start(n_iterations=1000)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## GPU Usage
|
|
242
|
+
|
|
243
|
+
Running on GPU requires only a single parameter change — all algorithms, spaces, and functions work identically:
|
|
244
|
+
|
|
245
|
+
```python
|
|
246
|
+
# Automatically uses GPU if available, otherwise falls back to CPU
|
|
247
|
+
space = Space(n_agents=1000, n_variables=100,
|
|
248
|
+
lower_bound=-10.0, upper_bound=10.0,
|
|
249
|
+
device="auto")
|
|
250
|
+
space.build()
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
For even more performance, enable `torch.compile` JIT acceleration:
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
optimizer = PSO()
|
|
257
|
+
optimizer.compile(space.population)
|
|
258
|
+
optimizer.torch_compile(mode="reduce-overhead")
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Why Otorchmizer over Opytimizer?
|
|
264
|
+
|
|
265
|
+
Otorchmizer is a drop-in modernization of Opytimizer. The same algorithms, the same API style, but with a fundamentally different computational engine:
|
|
266
|
+
|
|
267
|
+
| | Opytimizer | Otorchmizer |
|
|
268
|
+
|---|---|---|
|
|
269
|
+
| **Backend** | NumPy | PyTorch |
|
|
270
|
+
| **Agent storage** | `List[Agent]` (Python objects) | `Population` tensor `(n, v, d)` |
|
|
271
|
+
| **Update loop** | `for agent in agents:` (Python) | Batched tensor ops (vectorized) |
|
|
272
|
+
| **GPU support** | ❌ None | ✅ CUDA, multi-GPU, CUDA Graphs |
|
|
273
|
+
| **Mixed precision** | ❌ float64 only | ✅ float16, bfloat16, float32, float64 |
|
|
274
|
+
| **JIT compilation** | ❌ None | ✅ `torch.compile` |
|
|
275
|
+
| **Algorithms** | 92 | 91 (3 specialized deferred) |
|
|
276
|
+
| **CPU speedup** | 1× (baseline) | **50–1,055×** |
|
|
277
|
+
| **GPU speedup** | — | **up to 2,311×** |
|
|
278
|
+
|
|
279
|
+
For a detailed migration guide, see [`docs/MIGRATION_GUIDE.md`](docs/MIGRATION_GUIDE.md).
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Algorithms (91 total)
|
|
284
|
+
|
|
285
|
+
| Family | Count | Algorithms |
|
|
286
|
+
|--------|-------|-----------|
|
|
287
|
+
| **Swarm** | 33 | ABC, ABO, AF, AIWPSO, BA, BOA, BWO, CS, CSA, EHO, FA, FFOA, FPA, FSO, GOA, JS, KH, MFO, MRFO, PIO, PSO, RPSO, SAVPSO, SBO, SCA, SFO, SOS, SSA, SSO, STOA, VPSO, WAOA, WOA |
|
|
288
|
+
| **Evolutionary** | 14 | BSA, DE, EP, ES, FOA, GA, GHS, GOGHS, HS, IHS, IWO, NGHS, RRA, SGHS |
|
|
289
|
+
| **Misc** | 5 | AOA, CEM, DOA, GS, HC |
|
|
290
|
+
| **Population** | 11 | AEO, AO, COA, EPO, GCO, GWO, HHO, OSA, PPA, PVS, RFO |
|
|
291
|
+
| **Science** | 19 | AIG, ASO, BH, CDO, EFO, EO, ESA, GSA, HGSO, LSA, MOA, MVO, SA, SMA, TEO, TWO, WCA, WDO, WEO |
|
|
292
|
+
| **Social** | 6 | BSO, CI, ISA, MVPA, QSA, SSD |
|
|
293
|
+
| **Boolean** | 3 | BMRFO, BPSO, UMDA |
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Benchmarks
|
|
298
|
+
|
|
299
|
+
Results from 432 paired configurations across 3 backends (NumPy, PyTorch CPU, PyTorch GPU on an NVIDIA RTX 4070):
|
|
300
|
+
|
|
301
|
+
| Metric | Value |
|
|
302
|
+
|--------|-------|
|
|
303
|
+
| Average CPU speedup | **173×** |
|
|
304
|
+
| Peak CPU speedup | **1,055×** (GA, 1000 agents, 100 dims) |
|
|
305
|
+
| Average GPU speedup | **169×** |
|
|
306
|
+
| Peak GPU speedup | **2,311×** (HC, 1000 agents, 100 dims) |
|
|
307
|
+
| Convergence quality | Parity with original |
|
|
308
|
+
|
|
309
|
+
GPU execution time stays **nearly constant** (~0.03–0.08s) regardless of problem size, while NumPy grows linearly.
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
# Quick CPU-only benchmarks
|
|
313
|
+
python report/benchmarks/run_benchmarks.py --quick
|
|
314
|
+
|
|
315
|
+
# Full benchmark suite with GPU
|
|
316
|
+
python report/benchmarks/run_benchmarks.py --extended --gpu
|
|
317
|
+
|
|
318
|
+
# Generate all 13 visualization plots
|
|
319
|
+
python report/benchmarks/plot_results.py --input report/benchmarks/results_extended.json \
|
|
320
|
+
--outdir report/benchmarks/plots_extended
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
See the full [Migration Report](report/REPORT.md) for detailed analysis, tables, and all 13 benchmark plots.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Testing
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
python -m pytest tests/ -v
|
|
331
|
+
# 197 passed
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Documentation
|
|
337
|
+
|
|
338
|
+
| Resource | Description |
|
|
339
|
+
|----------|-------------|
|
|
340
|
+
| [Migration Guide](docs/MIGRATION_GUIDE.md) | For existing Opytimizer users — API mapping, code examples, FAQ |
|
|
341
|
+
| [Architecture Guide](ARCHITECTURE.md) | Full design document covering Population, UpdateContext, DeviceManager |
|
|
342
|
+
| [Migration Report](report/REPORT.md) | Detailed performance analysis with 13 benchmark plots |
|
|
343
|
+
| [API Reference](docs/) | Sphinx auto-generated docs (`cd docs && make html`) |
|
|
344
|
+
| [Examples](examples/) | Commented examples for core, optimizers, applications, GPU, and math |
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Support
|
|
349
|
+
|
|
350
|
+
We know that we do our best, but it is inevitable to acknowledge that we make mistakes. If you ever need to report a bug, report a problem, talk to us, please do so! We will be available at our bests at this repository.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## License
|
|
355
|
+
|
|
356
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Otorchmizer: A PyTorch-Powered Nature-Inspired Optimizer
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://pytorch.org/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
## Welcome to Otorchmizer.
|
|
8
|
+
|
|
9
|
+
Did you ever reach a bottleneck in your computational experiments? Are you tired of waiting hours for meta-heuristic optimization runs? If yes, Otorchmizer is the real deal! This package provides an easy-to-go implementation of **91 meta-heuristic optimization algorithms** — all powered by PyTorch tensors for GPU-accelerated performance. From populations to search spaces, from internal functions to external communication, we will foster all research related to optimizing stuff.
|
|
10
|
+
|
|
11
|
+
Otorchmizer is the modernized successor to [Opytimizer](https://github.com/gugarosa/opytimizer), delivering **up to 2,311× speedup** by replacing NumPy with PyTorch.
|
|
12
|
+
|
|
13
|
+
Use Otorchmizer if you need a library or wish to:
|
|
14
|
+
* Create your optimization algorithm with automatic GPU support;
|
|
15
|
+
* Design or use pre-loaded optimization tasks at scale;
|
|
16
|
+
* Run the same code on CPU, single-GPU, or multi-GPU seamlessly;
|
|
17
|
+
* Leverage `torch.compile` and CUDA Graphs for maximum throughput;
|
|
18
|
+
* Mix-and-match different strategies to solve your problem;
|
|
19
|
+
* Because it is fun to optimize things — even faster.
|
|
20
|
+
|
|
21
|
+
Otorchmizer is compatible with: **Python 3.10+** and **PyTorch 2.0+**.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Package guidelines
|
|
26
|
+
|
|
27
|
+
1. The very first information you need is in the very **next** section.
|
|
28
|
+
2. **Installing** is also easy if you wish to read the code and bump yourself into, follow along.
|
|
29
|
+
3. Note that there might be some **additional** steps in order to use our solutions.
|
|
30
|
+
4. If there is a problem, please do not **hesitate**, call us.
|
|
31
|
+
5. Finally, we focus on **minimization**. Take that in mind when designing your problem.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Citation
|
|
36
|
+
|
|
37
|
+
If you use Otorchmizer to fulfill any of your needs, please cite the original Opytimizer paper:
|
|
38
|
+
|
|
39
|
+
```BibTex
|
|
40
|
+
@misc{rosa2019opytimizer,
|
|
41
|
+
title={Opytimizer: A Nature-Inspired Python Optimizer},
|
|
42
|
+
author={Gustavo H. de Rosa, Douglas Rodrigues and João P. Papa},
|
|
43
|
+
year={2019},
|
|
44
|
+
eprint={1912.13002},
|
|
45
|
+
archivePrefix={arXiv},
|
|
46
|
+
primaryClass={cs.NE}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Getting started: 60 seconds with Otorchmizer
|
|
53
|
+
|
|
54
|
+
First of all. We have examples. Yes, they are commented. Just browse to `examples/`, chose your subpackage, and follow the example. We have high-level examples for most tasks we could think of, including GPU acceleration, `torch.compile`, and multi-GPU population splitting.
|
|
55
|
+
|
|
56
|
+
Alternatively, if you wish to learn even more, please take a minute:
|
|
57
|
+
|
|
58
|
+
Otorchmizer is based on the following structure, and you should pay attention to its tree:
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
- otorchmizer
|
|
62
|
+
- core
|
|
63
|
+
- agent_view
|
|
64
|
+
- block
|
|
65
|
+
- device
|
|
66
|
+
- function
|
|
67
|
+
- node
|
|
68
|
+
- optimizer
|
|
69
|
+
- population
|
|
70
|
+
- space
|
|
71
|
+
- functions
|
|
72
|
+
- constrained
|
|
73
|
+
- multi_objective
|
|
74
|
+
- math
|
|
75
|
+
- distribution
|
|
76
|
+
- general
|
|
77
|
+
- hyper
|
|
78
|
+
- random
|
|
79
|
+
- optimizers
|
|
80
|
+
- boolean
|
|
81
|
+
- evolutionary
|
|
82
|
+
- misc
|
|
83
|
+
- population
|
|
84
|
+
- science
|
|
85
|
+
- social
|
|
86
|
+
- swarm
|
|
87
|
+
- spaces
|
|
88
|
+
- boolean
|
|
89
|
+
- graph
|
|
90
|
+
- grid
|
|
91
|
+
- hyper_complex
|
|
92
|
+
- pareto
|
|
93
|
+
- search
|
|
94
|
+
- tree
|
|
95
|
+
- utils
|
|
96
|
+
- callback
|
|
97
|
+
- constant
|
|
98
|
+
- exception
|
|
99
|
+
- history
|
|
100
|
+
- logging
|
|
101
|
+
- visualization
|
|
102
|
+
- convergence
|
|
103
|
+
- surface
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Core
|
|
107
|
+
|
|
108
|
+
Core is the core. Essentially, it is the parent of everything. You should find parent classes defining the basis of our structure. They should provide variables and methods that will help to construct other modules. The key innovation is the **Population** class, which stores all agent data as contiguous PyTorch tensors `(n_agents, n_variables, n_dimensions)`, enabling vectorized operations and GPU parallelism. Also featured here is the **DeviceManager**, which handles CPU/GPU/multi-GPU resolution, mixed-precision, and CUDA Graph capture.
|
|
109
|
+
|
|
110
|
+
### Functions
|
|
111
|
+
|
|
112
|
+
Instead of using raw and straightforward functions, why not try this module? Compose high-level abstract functions or even new function-based ideas in order to solve your problems. Functions are auto-vectorized across the entire population via `torch.vmap` — you write a single-agent function, and we handle the batching.
|
|
113
|
+
|
|
114
|
+
### Math
|
|
115
|
+
|
|
116
|
+
Just because we are computing stuff does not mean that we do not need math. Math is the mathematical package containing low-level math implementations. From random numbers to distribution generation, you can find your needs on this module — all backed by PyTorch tensors for device-agnostic computation.
|
|
117
|
+
|
|
118
|
+
### Optimizers
|
|
119
|
+
|
|
120
|
+
This is why we are called Otorchmizer. This is the heart of heuristics, where you can find **91 meta-heuristic optimization techniques** across 7 families — swarm intelligence, evolutionary algorithms, science-inspired methods, and more. Every algorithm uses batched tensor operations, meaning the same code runs on CPU and GPU without modification.
|
|
121
|
+
|
|
122
|
+
### Spaces
|
|
123
|
+
|
|
124
|
+
One can see the space as the place that agents will update their positions and evaluate a fitness function. However, the newest approaches may consider a different type of space. Thinking about that, we are glad to support diverse space implementations.
|
|
125
|
+
|
|
126
|
+
### Utils
|
|
127
|
+
|
|
128
|
+
This is a utility package. Common things shared across the application should be implemented here. It is better to implement once and use as you wish than re-implementing the same thing repeatedly.
|
|
129
|
+
|
|
130
|
+
### Visualization
|
|
131
|
+
|
|
132
|
+
Everyone needs images and plots to help visualize what is happening, correct? This package will provide every visual-related method for you. Check a specific variable convergence, your fitness function convergence, plot benchmark function surfaces, and much more!
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Installation
|
|
137
|
+
|
|
138
|
+
We believe that everything has to be easy. Not tricky or daunting, Otorchmizer will be the one-to-go package that you will need, from the first installation to the daily tasks implementing needs. If you may just run the following under your most preferred Python environment (raw, conda, virtualenv, whatever):
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
pip install -e .
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Environment configuration
|
|
147
|
+
|
|
148
|
+
Note that sometimes, there is a need for additional implementation. If needed, from here, you will be the one to know all of its details.
|
|
149
|
+
|
|
150
|
+
### Ubuntu
|
|
151
|
+
|
|
152
|
+
No specific additional commands are needed.
|
|
153
|
+
|
|
154
|
+
### Windows
|
|
155
|
+
|
|
156
|
+
No specific additional commands are needed.
|
|
157
|
+
|
|
158
|
+
### MacOS
|
|
159
|
+
|
|
160
|
+
No specific additional commands are needed.
|
|
161
|
+
|
|
162
|
+
### GPU Support
|
|
163
|
+
|
|
164
|
+
For GPU acceleration, install PyTorch with CUDA support:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
pip install torch --index-url https://download.pytorch.org/whl/cu121
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## How-To-Use: Minimal Example
|
|
173
|
+
|
|
174
|
+
Take a look at a quick working example of Otorchmizer. Note that we are not passing many extra arguments nor additional information to the procedure. For more complex examples, please check our `examples/` folder.
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
import torch
|
|
178
|
+
|
|
179
|
+
from otorchmizer import Otorchmizer
|
|
180
|
+
from otorchmizer.core import Function, Space
|
|
181
|
+
from otorchmizer.optimizers.swarm import PSO
|
|
182
|
+
|
|
183
|
+
def sphere(x):
|
|
184
|
+
return (x ** 2).sum(dim=(-1, -2))
|
|
185
|
+
|
|
186
|
+
n_agents = 20
|
|
187
|
+
n_variables = 2
|
|
188
|
+
lower_bound = [-10, -10]
|
|
189
|
+
upper_bound = [10, 10]
|
|
190
|
+
|
|
191
|
+
space = Space(n_agents=n_agents, n_variables=n_variables,
|
|
192
|
+
lower_bound=lower_bound, upper_bound=upper_bound)
|
|
193
|
+
space.build()
|
|
194
|
+
|
|
195
|
+
optimizer = PSO()
|
|
196
|
+
function = Function(sphere)
|
|
197
|
+
|
|
198
|
+
opt = Otorchmizer(space, optimizer, function)
|
|
199
|
+
opt.start(n_iterations=1000)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## GPU Usage
|
|
205
|
+
|
|
206
|
+
Running on GPU requires only a single parameter change — all algorithms, spaces, and functions work identically:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
# Automatically uses GPU if available, otherwise falls back to CPU
|
|
210
|
+
space = Space(n_agents=1000, n_variables=100,
|
|
211
|
+
lower_bound=-10.0, upper_bound=10.0,
|
|
212
|
+
device="auto")
|
|
213
|
+
space.build()
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
For even more performance, enable `torch.compile` JIT acceleration:
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
optimizer = PSO()
|
|
220
|
+
optimizer.compile(space.population)
|
|
221
|
+
optimizer.torch_compile(mode="reduce-overhead")
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Why Otorchmizer over Opytimizer?
|
|
227
|
+
|
|
228
|
+
Otorchmizer is a drop-in modernization of Opytimizer. The same algorithms, the same API style, but with a fundamentally different computational engine:
|
|
229
|
+
|
|
230
|
+
| | Opytimizer | Otorchmizer |
|
|
231
|
+
|---|---|---|
|
|
232
|
+
| **Backend** | NumPy | PyTorch |
|
|
233
|
+
| **Agent storage** | `List[Agent]` (Python objects) | `Population` tensor `(n, v, d)` |
|
|
234
|
+
| **Update loop** | `for agent in agents:` (Python) | Batched tensor ops (vectorized) |
|
|
235
|
+
| **GPU support** | ❌ None | ✅ CUDA, multi-GPU, CUDA Graphs |
|
|
236
|
+
| **Mixed precision** | ❌ float64 only | ✅ float16, bfloat16, float32, float64 |
|
|
237
|
+
| **JIT compilation** | ❌ None | ✅ `torch.compile` |
|
|
238
|
+
| **Algorithms** | 92 | 91 (3 specialized deferred) |
|
|
239
|
+
| **CPU speedup** | 1× (baseline) | **50–1,055×** |
|
|
240
|
+
| **GPU speedup** | — | **up to 2,311×** |
|
|
241
|
+
|
|
242
|
+
For a detailed migration guide, see [`docs/MIGRATION_GUIDE.md`](docs/MIGRATION_GUIDE.md).
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
|
|
246
|
+
## Algorithms (91 total)
|
|
247
|
+
|
|
248
|
+
| Family | Count | Algorithms |
|
|
249
|
+
|--------|-------|-----------|
|
|
250
|
+
| **Swarm** | 33 | ABC, ABO, AF, AIWPSO, BA, BOA, BWO, CS, CSA, EHO, FA, FFOA, FPA, FSO, GOA, JS, KH, MFO, MRFO, PIO, PSO, RPSO, SAVPSO, SBO, SCA, SFO, SOS, SSA, SSO, STOA, VPSO, WAOA, WOA |
|
|
251
|
+
| **Evolutionary** | 14 | BSA, DE, EP, ES, FOA, GA, GHS, GOGHS, HS, IHS, IWO, NGHS, RRA, SGHS |
|
|
252
|
+
| **Misc** | 5 | AOA, CEM, DOA, GS, HC |
|
|
253
|
+
| **Population** | 11 | AEO, AO, COA, EPO, GCO, GWO, HHO, OSA, PPA, PVS, RFO |
|
|
254
|
+
| **Science** | 19 | AIG, ASO, BH, CDO, EFO, EO, ESA, GSA, HGSO, LSA, MOA, MVO, SA, SMA, TEO, TWO, WCA, WDO, WEO |
|
|
255
|
+
| **Social** | 6 | BSO, CI, ISA, MVPA, QSA, SSD |
|
|
256
|
+
| **Boolean** | 3 | BMRFO, BPSO, UMDA |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Benchmarks
|
|
261
|
+
|
|
262
|
+
Results from 432 paired configurations across 3 backends (NumPy, PyTorch CPU, PyTorch GPU on an NVIDIA RTX 4070):
|
|
263
|
+
|
|
264
|
+
| Metric | Value |
|
|
265
|
+
|--------|-------|
|
|
266
|
+
| Average CPU speedup | **173×** |
|
|
267
|
+
| Peak CPU speedup | **1,055×** (GA, 1000 agents, 100 dims) |
|
|
268
|
+
| Average GPU speedup | **169×** |
|
|
269
|
+
| Peak GPU speedup | **2,311×** (HC, 1000 agents, 100 dims) |
|
|
270
|
+
| Convergence quality | Parity with original |
|
|
271
|
+
|
|
272
|
+
GPU execution time stays **nearly constant** (~0.03–0.08s) regardless of problem size, while NumPy grows linearly.
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Quick CPU-only benchmarks
|
|
276
|
+
python report/benchmarks/run_benchmarks.py --quick
|
|
277
|
+
|
|
278
|
+
# Full benchmark suite with GPU
|
|
279
|
+
python report/benchmarks/run_benchmarks.py --extended --gpu
|
|
280
|
+
|
|
281
|
+
# Generate all 13 visualization plots
|
|
282
|
+
python report/benchmarks/plot_results.py --input report/benchmarks/results_extended.json \
|
|
283
|
+
--outdir report/benchmarks/plots_extended
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
See the full [Migration Report](report/REPORT.md) for detailed analysis, tables, and all 13 benchmark plots.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Testing
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
python -m pytest tests/ -v
|
|
294
|
+
# 197 passed
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Documentation
|
|
300
|
+
|
|
301
|
+
| Resource | Description |
|
|
302
|
+
|----------|-------------|
|
|
303
|
+
| [Migration Guide](docs/MIGRATION_GUIDE.md) | For existing Opytimizer users — API mapping, code examples, FAQ |
|
|
304
|
+
| [Architecture Guide](ARCHITECTURE.md) | Full design document covering Population, UpdateContext, DeviceManager |
|
|
305
|
+
| [Migration Report](report/REPORT.md) | Detailed performance analysis with 13 benchmark plots |
|
|
306
|
+
| [API Reference](docs/) | Sphinx auto-generated docs (`cd docs && make html`) |
|
|
307
|
+
| [Examples](examples/) | Commented examples for core, optimizers, applications, GPU, and math |
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## Support
|
|
312
|
+
|
|
313
|
+
We know that we do our best, but it is inevitable to acknowledge that we make mistakes. If you ever need to report a bug, report a problem, talk to us, please do so! We will be available at our bests at this repository.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
Apache 2.0 — see [LICENSE](LICENSE).
|