Skip to content

About

Particle Swarm Optimization (PSO) algorithm implementation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Particle Swarm Optimization — Hidden Intelligence in Bird Flight

PSO exploring a radial landscape PSO particles converging Swarm on multi-modal terrain

Minimal, hackable PSO playground built with pygame, numpy, and matplotlib. Tweak the fitness function, watch the swarm react, and keep iterating.

Quickstart

# using uv (recommended)
uv sync
uv run python main.py

# or plain pip
pip install -e .
python main.py

You need Python 3.13+ because this repo leans on the latest pygame wheels.

What You Get

  • Vectorized PSO core with inertia/cognitive/social parameters exposed at the top of main.py.
  • A 3D surface preview (preview_3d()) so you can sanity-check the objective before the swarm launches.
  • A grab bag of alternate functions (Gaussian, Rastrigin, Ackley, Griewank, etc.) ready to uncomment.
  • Color-mapped heat field rendered via pygame for instant feedback at 60 FPS.

Customize the Experiment

  • Objective: swap the lambda assigned to f(x, y) or plug in your own function. Keep it vectorizable for fast previews.
  • Swarm behavior: tune a, b, b_hat, and c to explore constriction vs. exploration regimes.
  • Grid resolution: adapt WINDOW_SIZE and PARTICLE_SIZE to trade off fidelity vs. speed.
  • Visualization: comment out preview_3d() if you want to skip the Matplotlib surface step.

Read More

About

Particle Swarm Optimization (PSO) algorithm implementation.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages