feat(algorithms): add ParticleSwarm (canonical PSO) for Vec<f64>

Eberhart & Kennedy 1995 PSO with the standard inertia-weight update:

  v[i,t+1] = w·v[i,t] + c1·r1·(pbest[i] - x[i,t]) + c2·r2·(gbest - x[i,t])
  x[i,t+1] = clamp(x[i,t] + v[i,t+1], bounds)

Single-objective only, `Vec<f64>` decisions only (PSO's velocity vector
needs a Euclidean structure that doesn't generalize cleanly to bool/perm).
Velocities are clamped to ±(hi - lo) per dim to keep particles from
exploding off into space.

Config exposes the four standard knobs — swarm size, generations,
inertia w, cognitive c1, social c2 — plus a seed. Tests cover
convergence on Sphere1D, deterministic reruns, and panic on
multi-objective.
This commit is contained in:
2026-05-05 09:51:11 -06:00
parent f77e163ac4
commit ba07361439
3 changed files with 261 additions and 2 deletions
+3 -2
View File
@@ -24,6 +24,7 @@ pub use crate::operators::{
pub use crate::algorithms::{
DifferentialEvolution, DifferentialEvolutionConfig, GeneticAlgorithm,
GeneticAlgorithmConfig, HillClimber, HillClimberConfig, Moead, MoeadConfig, Nsga2,
Nsga2Config, Nsga3, Nsga3Config, Paes, PaesConfig, RandomSearch, RandomSearchConfig,
SimulatedAnnealing, SimulatedAnnealingConfig, Spea2, Spea2Config,
Nsga2Config, Nsga3, Nsga3Config, Paes, PaesConfig, ParticleSwarm, ParticleSwarmConfig,
RandomSearch, RandomSearchConfig, SimulatedAnnealing, SimulatedAnnealingConfig, Spea2,
Spea2Config,
};