Skip to main content

Crate turboswarm_core

Crate turboswarm_core 

Source
Expand description

§turboswarm-core

Particle Swarm Optimization (PSO) core: extensible and modular. Pure Rust computation, with no FFI dependencies; the Python bindings live in the separate pso-py crate.

§Core idea

The PSO loop (Pso) knows nothing about any concrete variant. What changes between variants lives behind three traits (SearchSpace, Velocity, Topology). Adding a variant = implementing a trait, without touching the core. Internally, all positions and velocities are Vec<f64>; the integer/real difference lives solely in SearchSpace::decode.

§What it includes

§Minimal example

use turboswarm_core::prelude::*;

let space = ContinuousSpace::uniform(2, -5.12, 5.12);
let velocity = InertiaVelocity::new(0.729, 1.49445, 1.49445);
let params = PsoParams { seed: Some(42), ..Default::default() };

let pso = Pso::new(space, velocity, GlobalBest::new(), params);
let result = pso.minimize(|x| turboswarm_core::benchmarks::sphere(x));

assert!(result.best_value < 1e-3);

§How to extend

For a new variant, implement Velocity (template: velocity/inertia.rs); for a new topology, implement Topology by defining Topology::neighbors. See the README.md for the full guide.

Modules§

benchmarks
Standard test functions for optimization, with their known global optimum. They allow validating the optimizer and measuring the real error.
history
Record of the optimization process, for visualization and analysis.
mopso
Multi-objective PSO (MOPSO, Coello Coello & Lechuga, 2004).
params
Optimizer configuration parameters.
prelude
Convenient re-exports for common usage.
pso
The PSO optimizer. The loop knows nothing about any concrete variant: it receives a SearchSpace, a Velocity and a Topology via generics.
spaces
Search spaces: they define the domain and the integer/real distinction.
swarm
Swarm data structures.
topology
Social topologies: they define the neighborhood of each particle.
traits
Core traits of the framework.
velocity
Velocity update rules. Each one is a PSO variant.