turboswarm 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.
- turboswarm-0.1.0/Cargo.lock +406 -0
- turboswarm-0.1.0/Cargo.toml +16 -0
- turboswarm-0.1.0/LICENSE +21 -0
- turboswarm-0.1.0/PKG-INFO +149 -0
- turboswarm-0.1.0/crates/pso-core/Cargo.toml +21 -0
- turboswarm-0.1.0/crates/pso-core/README.md +40 -0
- turboswarm-0.1.0/crates/pso-core/examples/basic.rs +27 -0
- turboswarm-0.1.0/crates/pso-core/examples/parallel.rs +63 -0
- turboswarm-0.1.0/crates/pso-core/src/benchmarks/functions.rs +117 -0
- turboswarm-0.1.0/crates/pso-core/src/benchmarks/mod.rs +11 -0
- turboswarm-0.1.0/crates/pso-core/src/history.rs +28 -0
- turboswarm-0.1.0/crates/pso-core/src/lib.rs +79 -0
- turboswarm-0.1.0/crates/pso-core/src/mopso.rs +303 -0
- turboswarm-0.1.0/crates/pso-core/src/params.rs +68 -0
- turboswarm-0.1.0/crates/pso-core/src/pso.rs +547 -0
- turboswarm-0.1.0/crates/pso-core/src/spaces/continuous.rs +84 -0
- turboswarm-0.1.0/crates/pso-core/src/spaces/integer.rs +135 -0
- turboswarm-0.1.0/crates/pso-core/src/spaces/mixed.rs +128 -0
- turboswarm-0.1.0/crates/pso-core/src/spaces/mod.rs +72 -0
- turboswarm-0.1.0/crates/pso-core/src/swarm.rs +51 -0
- turboswarm-0.1.0/crates/pso-core/src/topology/global.rs +23 -0
- turboswarm-0.1.0/crates/pso-core/src/topology/mod.rs +14 -0
- turboswarm-0.1.0/crates/pso-core/src/topology/random.rs +54 -0
- turboswarm-0.1.0/crates/pso-core/src/topology/ring.rs +61 -0
- turboswarm-0.1.0/crates/pso-core/src/topology/von_neumann.rs +63 -0
- turboswarm-0.1.0/crates/pso-core/src/traits.rs +184 -0
- turboswarm-0.1.0/crates/pso-core/src/velocity/constriction.rs +69 -0
- turboswarm-0.1.0/crates/pso-core/src/velocity/fips.rs +84 -0
- turboswarm-0.1.0/crates/pso-core/src/velocity/inertia.rs +69 -0
- turboswarm-0.1.0/crates/pso-core/src/velocity/mod.rs +13 -0
- turboswarm-0.1.0/crates/pso-core/tests/convergence.rs +556 -0
- turboswarm-0.1.0/crates/pso-py/Cargo.toml +15 -0
- turboswarm-0.1.0/crates/pso-py/src/lib.rs +856 -0
- turboswarm-0.1.0/pyproject.toml +47 -0
- turboswarm-0.1.0/python/README.md +118 -0
- turboswarm-0.1.0/python/turboswarm/__init__.py +51 -0
- turboswarm-0.1.0/python/turboswarm/benchmarks.py +66 -0
- turboswarm-0.1.0/python/turboswarm/viz.py +106 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "autocfg"
|
|
7
|
+
version = "1.5.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "cfg-if"
|
|
13
|
+
version = "1.0.4"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "crossbeam-deque"
|
|
19
|
+
version = "0.8.6"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
|
22
|
+
dependencies = [
|
|
23
|
+
"crossbeam-epoch",
|
|
24
|
+
"crossbeam-utils",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[[package]]
|
|
28
|
+
name = "crossbeam-epoch"
|
|
29
|
+
version = "0.9.18"
|
|
30
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
31
|
+
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"crossbeam-utils",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "crossbeam-utils"
|
|
38
|
+
version = "0.8.21"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "either"
|
|
44
|
+
version = "1.16.0"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e"
|
|
47
|
+
|
|
48
|
+
[[package]]
|
|
49
|
+
name = "getrandom"
|
|
50
|
+
version = "0.2.17"
|
|
51
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
52
|
+
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
|
|
53
|
+
dependencies = [
|
|
54
|
+
"cfg-if",
|
|
55
|
+
"libc",
|
|
56
|
+
"wasi",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[[package]]
|
|
60
|
+
name = "heck"
|
|
61
|
+
version = "0.5.0"
|
|
62
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
63
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "indoc"
|
|
67
|
+
version = "2.0.7"
|
|
68
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
69
|
+
checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
|
|
70
|
+
dependencies = [
|
|
71
|
+
"rustversion",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[[package]]
|
|
75
|
+
name = "libc"
|
|
76
|
+
version = "0.2.186"
|
|
77
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
78
|
+
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
|
|
79
|
+
|
|
80
|
+
[[package]]
|
|
81
|
+
name = "matrixmultiply"
|
|
82
|
+
version = "0.3.10"
|
|
83
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
+
checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08"
|
|
85
|
+
dependencies = [
|
|
86
|
+
"autocfg",
|
|
87
|
+
"rawpointer",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "memoffset"
|
|
92
|
+
version = "0.9.1"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"autocfg",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
[[package]]
|
|
100
|
+
name = "ndarray"
|
|
101
|
+
version = "0.16.1"
|
|
102
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
103
|
+
checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841"
|
|
104
|
+
dependencies = [
|
|
105
|
+
"matrixmultiply",
|
|
106
|
+
"num-complex",
|
|
107
|
+
"num-integer",
|
|
108
|
+
"num-traits",
|
|
109
|
+
"portable-atomic",
|
|
110
|
+
"portable-atomic-util",
|
|
111
|
+
"rawpointer",
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
[[package]]
|
|
115
|
+
name = "num-complex"
|
|
116
|
+
version = "0.4.6"
|
|
117
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
118
|
+
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
|
119
|
+
dependencies = [
|
|
120
|
+
"num-traits",
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
[[package]]
|
|
124
|
+
name = "num-integer"
|
|
125
|
+
version = "0.1.46"
|
|
126
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
127
|
+
checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
|
|
128
|
+
dependencies = [
|
|
129
|
+
"num-traits",
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
[[package]]
|
|
133
|
+
name = "num-traits"
|
|
134
|
+
version = "0.2.19"
|
|
135
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
136
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
137
|
+
dependencies = [
|
|
138
|
+
"autocfg",
|
|
139
|
+
]
|
|
140
|
+
|
|
141
|
+
[[package]]
|
|
142
|
+
name = "numpy"
|
|
143
|
+
version = "0.22.1"
|
|
144
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
145
|
+
checksum = "edb929bc0da91a4d85ed6c0a84deaa53d411abfb387fc271124f91bf6b89f14e"
|
|
146
|
+
dependencies = [
|
|
147
|
+
"libc",
|
|
148
|
+
"ndarray",
|
|
149
|
+
"num-complex",
|
|
150
|
+
"num-integer",
|
|
151
|
+
"num-traits",
|
|
152
|
+
"pyo3",
|
|
153
|
+
"rustc-hash",
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
[[package]]
|
|
157
|
+
name = "once_cell"
|
|
158
|
+
version = "1.21.4"
|
|
159
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
160
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
161
|
+
|
|
162
|
+
[[package]]
|
|
163
|
+
name = "portable-atomic"
|
|
164
|
+
version = "1.13.1"
|
|
165
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
+
checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
|
|
167
|
+
|
|
168
|
+
[[package]]
|
|
169
|
+
name = "portable-atomic-util"
|
|
170
|
+
version = "0.2.7"
|
|
171
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
172
|
+
checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618"
|
|
173
|
+
dependencies = [
|
|
174
|
+
"portable-atomic",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
[[package]]
|
|
178
|
+
name = "ppv-lite86"
|
|
179
|
+
version = "0.2.21"
|
|
180
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
181
|
+
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
|
182
|
+
dependencies = [
|
|
183
|
+
"zerocopy",
|
|
184
|
+
]
|
|
185
|
+
|
|
186
|
+
[[package]]
|
|
187
|
+
name = "proc-macro2"
|
|
188
|
+
version = "1.0.106"
|
|
189
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
190
|
+
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
191
|
+
dependencies = [
|
|
192
|
+
"unicode-ident",
|
|
193
|
+
]
|
|
194
|
+
|
|
195
|
+
[[package]]
|
|
196
|
+
name = "pso-core"
|
|
197
|
+
version = "0.1.0"
|
|
198
|
+
dependencies = [
|
|
199
|
+
"rand",
|
|
200
|
+
"rand_chacha",
|
|
201
|
+
"rayon",
|
|
202
|
+
]
|
|
203
|
+
|
|
204
|
+
[[package]]
|
|
205
|
+
name = "pso-py"
|
|
206
|
+
version = "0.1.0"
|
|
207
|
+
dependencies = [
|
|
208
|
+
"numpy",
|
|
209
|
+
"pso-core",
|
|
210
|
+
"pyo3",
|
|
211
|
+
]
|
|
212
|
+
|
|
213
|
+
[[package]]
|
|
214
|
+
name = "pyo3"
|
|
215
|
+
version = "0.22.6"
|
|
216
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
217
|
+
checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
|
|
218
|
+
dependencies = [
|
|
219
|
+
"cfg-if",
|
|
220
|
+
"indoc",
|
|
221
|
+
"libc",
|
|
222
|
+
"memoffset",
|
|
223
|
+
"once_cell",
|
|
224
|
+
"portable-atomic",
|
|
225
|
+
"pyo3-build-config",
|
|
226
|
+
"pyo3-ffi",
|
|
227
|
+
"pyo3-macros",
|
|
228
|
+
"unindent",
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
[[package]]
|
|
232
|
+
name = "pyo3-build-config"
|
|
233
|
+
version = "0.22.6"
|
|
234
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
235
|
+
checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
|
|
236
|
+
dependencies = [
|
|
237
|
+
"once_cell",
|
|
238
|
+
"target-lexicon",
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
[[package]]
|
|
242
|
+
name = "pyo3-ffi"
|
|
243
|
+
version = "0.22.6"
|
|
244
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
245
|
+
checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
|
|
246
|
+
dependencies = [
|
|
247
|
+
"libc",
|
|
248
|
+
"pyo3-build-config",
|
|
249
|
+
]
|
|
250
|
+
|
|
251
|
+
[[package]]
|
|
252
|
+
name = "pyo3-macros"
|
|
253
|
+
version = "0.22.6"
|
|
254
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
255
|
+
checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
|
|
256
|
+
dependencies = [
|
|
257
|
+
"proc-macro2",
|
|
258
|
+
"pyo3-macros-backend",
|
|
259
|
+
"quote",
|
|
260
|
+
"syn",
|
|
261
|
+
]
|
|
262
|
+
|
|
263
|
+
[[package]]
|
|
264
|
+
name = "pyo3-macros-backend"
|
|
265
|
+
version = "0.22.6"
|
|
266
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
267
|
+
checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
|
|
268
|
+
dependencies = [
|
|
269
|
+
"heck",
|
|
270
|
+
"proc-macro2",
|
|
271
|
+
"pyo3-build-config",
|
|
272
|
+
"quote",
|
|
273
|
+
"syn",
|
|
274
|
+
]
|
|
275
|
+
|
|
276
|
+
[[package]]
|
|
277
|
+
name = "quote"
|
|
278
|
+
version = "1.0.46"
|
|
279
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
280
|
+
checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
|
|
281
|
+
dependencies = [
|
|
282
|
+
"proc-macro2",
|
|
283
|
+
]
|
|
284
|
+
|
|
285
|
+
[[package]]
|
|
286
|
+
name = "rand"
|
|
287
|
+
version = "0.8.6"
|
|
288
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
289
|
+
checksum = "5ca0ecfa931c29007047d1bc58e623ab12e5590e8c7cc53200d5202b69266d8a"
|
|
290
|
+
dependencies = [
|
|
291
|
+
"libc",
|
|
292
|
+
"rand_chacha",
|
|
293
|
+
"rand_core",
|
|
294
|
+
]
|
|
295
|
+
|
|
296
|
+
[[package]]
|
|
297
|
+
name = "rand_chacha"
|
|
298
|
+
version = "0.3.1"
|
|
299
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
300
|
+
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
|
301
|
+
dependencies = [
|
|
302
|
+
"ppv-lite86",
|
|
303
|
+
"rand_core",
|
|
304
|
+
]
|
|
305
|
+
|
|
306
|
+
[[package]]
|
|
307
|
+
name = "rand_core"
|
|
308
|
+
version = "0.6.4"
|
|
309
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
310
|
+
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
|
311
|
+
dependencies = [
|
|
312
|
+
"getrandom",
|
|
313
|
+
]
|
|
314
|
+
|
|
315
|
+
[[package]]
|
|
316
|
+
name = "rawpointer"
|
|
317
|
+
version = "0.2.1"
|
|
318
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
319
|
+
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
|
320
|
+
|
|
321
|
+
[[package]]
|
|
322
|
+
name = "rayon"
|
|
323
|
+
version = "1.12.0"
|
|
324
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
325
|
+
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
|
|
326
|
+
dependencies = [
|
|
327
|
+
"either",
|
|
328
|
+
"rayon-core",
|
|
329
|
+
]
|
|
330
|
+
|
|
331
|
+
[[package]]
|
|
332
|
+
name = "rayon-core"
|
|
333
|
+
version = "1.13.0"
|
|
334
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
335
|
+
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
|
336
|
+
dependencies = [
|
|
337
|
+
"crossbeam-deque",
|
|
338
|
+
"crossbeam-utils",
|
|
339
|
+
]
|
|
340
|
+
|
|
341
|
+
[[package]]
|
|
342
|
+
name = "rustc-hash"
|
|
343
|
+
version = "1.1.0"
|
|
344
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
345
|
+
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
346
|
+
|
|
347
|
+
[[package]]
|
|
348
|
+
name = "rustversion"
|
|
349
|
+
version = "1.0.22"
|
|
350
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
351
|
+
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|
352
|
+
|
|
353
|
+
[[package]]
|
|
354
|
+
name = "syn"
|
|
355
|
+
version = "2.0.118"
|
|
356
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
357
|
+
checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422"
|
|
358
|
+
dependencies = [
|
|
359
|
+
"proc-macro2",
|
|
360
|
+
"quote",
|
|
361
|
+
"unicode-ident",
|
|
362
|
+
]
|
|
363
|
+
|
|
364
|
+
[[package]]
|
|
365
|
+
name = "target-lexicon"
|
|
366
|
+
version = "0.12.16"
|
|
367
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
368
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
369
|
+
|
|
370
|
+
[[package]]
|
|
371
|
+
name = "unicode-ident"
|
|
372
|
+
version = "1.0.24"
|
|
373
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
374
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
375
|
+
|
|
376
|
+
[[package]]
|
|
377
|
+
name = "unindent"
|
|
378
|
+
version = "0.2.4"
|
|
379
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
380
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
381
|
+
|
|
382
|
+
[[package]]
|
|
383
|
+
name = "wasi"
|
|
384
|
+
version = "0.11.1+wasi-snapshot-preview1"
|
|
385
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
386
|
+
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
|
387
|
+
|
|
388
|
+
[[package]]
|
|
389
|
+
name = "zerocopy"
|
|
390
|
+
version = "0.8.52"
|
|
391
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
392
|
+
checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f"
|
|
393
|
+
dependencies = [
|
|
394
|
+
"zerocopy-derive",
|
|
395
|
+
]
|
|
396
|
+
|
|
397
|
+
[[package]]
|
|
398
|
+
name = "zerocopy-derive"
|
|
399
|
+
version = "0.8.52"
|
|
400
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
401
|
+
checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930"
|
|
402
|
+
dependencies = [
|
|
403
|
+
"proc-macro2",
|
|
404
|
+
"quote",
|
|
405
|
+
"syn",
|
|
406
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = ["crates/pso-core", "crates/pso-py"]
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
version = "0.1.0"
|
|
7
|
+
edition = "2021"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
authors = ["Jose L. Salmeron <joseluis.salmeron@gmail.com>"]
|
|
10
|
+
repository = "https://github.com/turboswarm/turboswarm.github.io"
|
|
11
|
+
homepage = "https://github.com/turboswarm/turboswarm.github.io"
|
|
12
|
+
|
|
13
|
+
[workspace.dependencies]
|
|
14
|
+
rand = "0.8"
|
|
15
|
+
rand_chacha = "0.3" # RNG with reproducible seed (reproducibility matters)
|
|
16
|
+
rayon = "1" # data parallelism for parallel objective evaluation
|
turboswarm-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tu Nombre
|
|
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,149 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: turboswarm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Development Status :: 4 - Beta
|
|
5
|
+
Classifier: Intended Audience :: Science/Research
|
|
6
|
+
Classifier: Intended Audience :: Developers
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Rust
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
11
|
+
Requires-Dist: numpy
|
|
12
|
+
Requires-Dist: matplotlib
|
|
13
|
+
Requires-Dist: mkdocs-material ; extra == 'docs'
|
|
14
|
+
Requires-Dist: mkdocstrings[python] ; extra == 'docs'
|
|
15
|
+
Requires-Dist: black ; extra == 'docs'
|
|
16
|
+
Requires-Dist: jupyter ; extra == 'notebooks'
|
|
17
|
+
Requires-Dist: plotly ; extra == 'notebooks'
|
|
18
|
+
Provides-Extra: docs
|
|
19
|
+
Provides-Extra: notebooks
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Summary: Particle Swarm Optimization with a Rust core
|
|
22
|
+
Keywords: pso,optimization,swarm,metaheuristics
|
|
23
|
+
Author-email: "Jose L. Salmeron" <joseluis.salmeron@gmail.com>
|
|
24
|
+
License: MIT
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
27
|
+
Project-URL: Homepage, https://github.com/turboswarm/turboswarm.github.io
|
|
28
|
+
Project-URL: Issues, https://github.com/turboswarm/turboswarm.github.io/issues
|
|
29
|
+
Project-URL: Repository, https://github.com/turboswarm/turboswarm.github.io
|
|
30
|
+
|
|
31
|
+
# turboswarm
|
|
32
|
+
|
|
33
|
+
**Particle Swarm Optimization** with a compute core in **Rust** and an API in
|
|
34
|
+
**Python**. Focused on visualization, variant comparison and clear code.
|
|
35
|
+
Supports real, integer, binary and mixed variables, constraints and
|
|
36
|
+
multi-objective optimization.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
From source (development), with [maturin](https://www.maturin.rs/):
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install maturin
|
|
44
|
+
python -m venv .venv && source .venv/bin/activate
|
|
45
|
+
maturin develop --release # compiles the Rust core and installs it
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
import turboswarm as pso
|
|
52
|
+
|
|
53
|
+
# Native benchmark (fast, in Rust, without the GIL)
|
|
54
|
+
r = pso.minimize("rastrigin", bounds=[(-5.12, 5.12)] * 2, seed=42)
|
|
55
|
+
|
|
56
|
+
# Your own function in Python
|
|
57
|
+
r = pso.minimize(lambda x: sum(xi**2 for xi in x), bounds=[(-5, 5)] * 3)
|
|
58
|
+
|
|
59
|
+
# Integer variables
|
|
60
|
+
r = pso.minimize(f, bounds=[(-10, 10)] * 2, integer=True)
|
|
61
|
+
|
|
62
|
+
# Variant and topology by name
|
|
63
|
+
r = pso.minimize("ackley", bounds=[(-32.768, 32.768)] * 2,
|
|
64
|
+
velocity="fips", topology="ring", seed=1)
|
|
65
|
+
|
|
66
|
+
print(r.best_position, r.best_value)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Parameters of `minimize`
|
|
70
|
+
|
|
71
|
+
| Parameter | Default | Description |
|
|
72
|
+
|-----------|---------|-------------|
|
|
73
|
+
| `objective` | — | callable `f(list)->float`, or name of a native benchmark |
|
|
74
|
+
| `bounds` | — | list of `(min, max)` per dimension |
|
|
75
|
+
| `integer` / `binary` | `False` | optimize over integers / `{0,1}` |
|
|
76
|
+
| `var_types` | `None` | per-dimension `"real"`/`"integer"`/`"binary"` (mixed) |
|
|
77
|
+
| `n_particles` | `30` | swarm size |
|
|
78
|
+
| `max_iter` | `100` | iterations |
|
|
79
|
+
| `w, c1, c2` | `0.729, 1.494, 1.494` | inertia, cognitive, social |
|
|
80
|
+
| `velocity` | `"inertia"` | `"inertia"`, `"constriction"`, `"fips"` |
|
|
81
|
+
| `topology` | `"global"` | `"global"`, `"ring"`, `"vonneumann"`, `"random"` |
|
|
82
|
+
| `bounds_handling` | `"clamp"` | `"clamp"`, `"reflect"`, `"wrap"`, `"reinit"` |
|
|
83
|
+
| `seed` | `None` | seed (fix it for reproducibility) |
|
|
84
|
+
| `record_history` | `True` | store the trace for visualization |
|
|
85
|
+
| `v_max` | `None` | clamp each velocity component to `[-v_max, v_max]` |
|
|
86
|
+
| `patience` / `tol` | `0` / `0.0` | stop after `patience` iters without `>tol` improvement |
|
|
87
|
+
| `max_evals` / `target` / `max_time` | `None` | stop on evaluation / value / time budget |
|
|
88
|
+
| `constraints` / `penalty` | `None` / `1e6` | inequality constraints `g(x)<=0` via penalty |
|
|
89
|
+
| `callback` | `None` | `callback(iteration, best_value)`; return `False` to stop |
|
|
90
|
+
| `vectorized` | `False` | objective receives the whole swarm as a NumPy array |
|
|
91
|
+
|
|
92
|
+
**Native benchmarks:** `sphere`, `rastrigin`, `rosenbrock`, `ackley`,
|
|
93
|
+
`griewank`, `schwefel`. Their metadata (recommended bound and optimum) are in
|
|
94
|
+
`pso.benchmark_info(name) -> (bound, optimum)`.
|
|
95
|
+
|
|
96
|
+
> FIPS performs better with local topologies (`"ring"`, `"vonneumann"`). The
|
|
97
|
+
> `"constriction"` and `"fips"` variants derive their factor from `c1 + c2`.
|
|
98
|
+
|
|
99
|
+
### Result (`PsoResult`)
|
|
100
|
+
|
|
101
|
+
- `best_position` — list of floats (whole-valued for integer/binary dims)
|
|
102
|
+
- `best_value` — float
|
|
103
|
+
- `convergence` — best value per iteration (convergence curve)
|
|
104
|
+
- `history` — `history[iter][particle][dim]` (empty if `record_history=False`)
|
|
105
|
+
- `evaluations` — number of objective evaluations performed
|
|
106
|
+
- `stop_reason` — `"max_iterations"`, `"target"`, `"max_evaluations"`,
|
|
107
|
+
`"stagnation"`, `"max_time"` or `"callback"`
|
|
108
|
+
|
|
109
|
+
### Multi-objective (MOPSO)
|
|
110
|
+
|
|
111
|
+
`minimize_multi` returns a `ParetoFront` (`.positions`, `.objectives`):
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
front = pso.minimize_multi(
|
|
115
|
+
lambda x: [sum(xi**2 for xi in x), sum((xi - 2) ** 2 for xi in x)],
|
|
116
|
+
bounds=[(-5, 5)] * 2, seed=42,
|
|
117
|
+
)
|
|
118
|
+
print(len(front)) # non-dominated solutions
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Visualization
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import matplotlib.pyplot as plt
|
|
125
|
+
|
|
126
|
+
pso.viz.plot_convergence(r); plt.show()
|
|
127
|
+
pso.viz.compare({"inertia": rA, "fips": rB}); plt.show()
|
|
128
|
+
pso.viz.plot_pareto(front); plt.show() # objective space of a Pareto front
|
|
129
|
+
|
|
130
|
+
anim = pso.viz.animate_swarm(r, pso.benchmarks.rastrigin, [(-5.12, 5.12)] * 2)
|
|
131
|
+
# in a notebook: from IPython.display import HTML; HTML(anim.to_jshtml())
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
`animate_swarm` only supports 2D problems and requires `record_history=True`.
|
|
135
|
+
|
|
136
|
+
## Documentation
|
|
137
|
+
|
|
138
|
+
A navigable documentation portal (narrative guide + API reference) is built with
|
|
139
|
+
MkDocs Material:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pip install -e ".[docs]"
|
|
143
|
+
./scripts/build-docs.sh --serve # http://127.0.0.1:8000
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT.
|
|
149
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pso-core"
|
|
3
|
+
description = "Particle Swarm Optimization core: extensible and modular"
|
|
4
|
+
version.workspace = true
|
|
5
|
+
edition.workspace = true
|
|
6
|
+
license.workspace = true
|
|
7
|
+
authors.workspace = true
|
|
8
|
+
repository.workspace = true
|
|
9
|
+
homepage.workspace = true
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
documentation = "https://docs.rs/pso-core"
|
|
12
|
+
keywords = ["pso", "optimization", "swarm", "metaheuristics"]
|
|
13
|
+
categories = ["science", "algorithms"]
|
|
14
|
+
|
|
15
|
+
[dependencies]
|
|
16
|
+
rand.workspace = true
|
|
17
|
+
rand_chacha.workspace = true
|
|
18
|
+
rayon.workspace = true
|
|
19
|
+
|
|
20
|
+
[dev-dependencies]
|
|
21
|
+
# tests use only std + the crate itself
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# pso-core
|
|
2
|
+
|
|
3
|
+
The Rust core of [**turboswarm**](https://github.com/turboswarm/turboswarm.github.io)
|
|
4
|
+
— a Particle Swarm Optimization library. Pure Rust, no FFI, zero-cost generics.
|
|
5
|
+
|
|
6
|
+
The PSO loop knows nothing about any concrete variant: everything that changes
|
|
7
|
+
lives behind three traits — `SearchSpace`, `Velocity` and `Topology`. Adding a
|
|
8
|
+
variant means implementing one trait, without touching the core.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Velocity variants: inertia, constriction (Clerc-Kennedy) and FIPS.
|
|
13
|
+
- Topologies: global, ring, Von Neumann and random.
|
|
14
|
+
- Spaces: continuous, integer (with discretization) and mixed.
|
|
15
|
+
- Multi-objective optimization (MOPSO) in `pso_core::mopso`.
|
|
16
|
+
- Parallel objective evaluation (`minimize_parallel`, via `rayon`).
|
|
17
|
+
- Run control: target / evaluation / time budgets, stagnation, callback.
|
|
18
|
+
- Benchmarks with metadata (sphere, rastrigin, rosenbrock, ackley, griewank,
|
|
19
|
+
schwefel).
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
```rust
|
|
24
|
+
use pso_core::prelude::*;
|
|
25
|
+
use pso_core::benchmarks::rastrigin;
|
|
26
|
+
|
|
27
|
+
let space = ContinuousSpace::uniform(2, -5.12, 5.12);
|
|
28
|
+
let velocity = InertiaVelocity::new(0.729, 1.49445, 1.49445);
|
|
29
|
+
let params = PsoParams { seed: Some(42), ..Default::default() };
|
|
30
|
+
|
|
31
|
+
let result = Pso::new(space, velocity, GlobalBest::new(), params).minimize(rastrigin);
|
|
32
|
+
assert!(result.best_value < 1e-3);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The Python bindings live in the `turboswarm` package
|
|
36
|
+
(`pip install turboswarm`). Full docs: <https://turboswarm.github.io/>.
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//! Usage example from Rust. Run with:
|
|
2
|
+
//! cargo run --example basic -p pso-core
|
|
3
|
+
|
|
4
|
+
use pso_core::benchmarks::rastrigin;
|
|
5
|
+
use pso_core::prelude::*;
|
|
6
|
+
|
|
7
|
+
fn main() {
|
|
8
|
+
// A 2-D box with the same range on every dimension.
|
|
9
|
+
// (For different ranges per dimension, use
|
|
10
|
+
// `ContinuousSpace::new(vec![(-5.0, 5.0), (0.0, 100.0)])`.)
|
|
11
|
+
let space = ContinuousSpace::uniform(2, -5.12, 5.12);
|
|
12
|
+
let velocity = InertiaVelocity::new(0.9, 1.49445, 1.49445).with_decay(0.4);
|
|
13
|
+
let params = PsoParams {
|
|
14
|
+
n_particles: 40,
|
|
15
|
+
max_iterations: 200,
|
|
16
|
+
seed: Some(42),
|
|
17
|
+
record_history: true,
|
|
18
|
+
..Default::default()
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let pso = Pso::new(space, velocity, GlobalBest::new(), params);
|
|
22
|
+
let result = pso.minimize(rastrigin);
|
|
23
|
+
|
|
24
|
+
println!("Best position: {:?}", result.best_position);
|
|
25
|
+
println!("Best value: {:.6}", result.best_value);
|
|
26
|
+
println!("Iterations: {}", result.history.iterations());
|
|
27
|
+
}
|