MachineLearning/particle_swarm library

Particle Swarm Optimization (PSO) - generic

A compact, production-minded particle swarm optimizer that supports:

  • generic particle position type represented as List
  • velocity-based updates, inertia, cognitive and social coefficients
  • per-particle best and global best tracking, seeded RNG

Contract:

  • Input: initial swarm positions generator, fitness(List
  • Output: optimize returns bestPosition and bestFitness.
  • Errors: throws ArgumentError for invalid shapes. Particle Swarm Optimization (PSO) - generic over particle type T

A production-minded particle swarm optimizer that is generic over the particle representation T. The implementation internally operates on numeric vectors, but the API accepts any T provided the caller supplies mapping functions between T and List<double>.

Features:

  • generic particle type T via toVector / fromVector converters
  • inertia, cognitive and social coefficients with seeded RNG
  • maintains per-particle best and global best

Contract:

  • Input: initParticles -> List
  • Output: optimize returns a map with best (T) and bestFitness.
  • Errors: throws ArgumentError for invalid shapes.

Classes

ParticleSwarm<T>