Artificial Intelligence Particle Swarm Optimization new

Particle Swarm Optimization

Collective intelligence finds optimal solutions

Iteration 0
Best Fitness -
Best Position -

Particle Swarm Optimization (PSO)

PSO is a population-based optimization algorithm inspired by the social behavior of bird flocking or fish schooling. Particles explore a search space, sharing information about promising regions.

Core Concepts:

  • Particle: A candidate solution with position and velocity in the search space
  • Personal Best (pBest): Best position found by each individual particle
  • Global Best (gBest): Best position found by the entire swarm
  • Velocity Update: Particles adjust their movement based on pBest and gBest

Velocity Update Formula:

v(t+1) = w * v(t) + c1 * r1 * (pBest - x) + c2 * r2 * (gBest - x)

Where:

  • w: Inertia weight (momentum from previous velocity)
  • c1: Cognitive weight (attraction to personal best)
  • c2: Social weight (attraction to global best)
  • r1, r2: Random factors for exploration

Test Functions:

  • Sphere: Simple convex function, global minimum at origin
  • Rastrigin: Highly multimodal, many local minima (tests exploration)
  • Rosenbrock: Narrow curved valley (tests precision)
  • Ackley: Nearly flat outer region with central hole (tests convergence)

Why It Works:

  • Exploration: Random factors and inertia help escape local minima
  • Exploitation: Attraction to best positions refines solutions
  • Information Sharing: Swarm collectively discovers good regions
© 2013 - 2026 Cylian 🤖 Claude
About

Particle Swarm Optimization

Interactive demonstration of PSO algorithm for 2D function optimization.

Features

  • Test Functions: Sphere, Rastrigin, Rosenbrock, Ackley
  • Visualization: Contour lines, heatmap, particles with velocity vectors
  • Best Markers: Personal best (small) and global best (large)
  • Convergence Graph: Track fitness improvement over iterations
  • Configurable Parameters: Swarm size, inertia, cognitive/social weights

Technical Details

  • Swarm size: 30 particles (configurable)
  • Inertia weight: 0.7 (configurable, 0.4-0.9)
  • Cognitive weight: 1.5 (attraction to personal best)
  • Social weight: 1.5 (attraction to global best)
  • Velocity clamping: Prevents particles from escaping search space

Keyboard Shortcuts

  • Space: Start/Pause
  • R: Reset

Generation Prompt

Create a Particle Swarm Optimization demo for 2D function optimization.

Requirements:
- Particles exploring 2D search space with velocity vectors
- Test functions: Sphere, Rastrigin, Rosenbrock, Ackley
- Heatmap/contour visualization of the objective function
- Each particle tracks personal best position
- Swarm shares global best position
- Configurable: swarm size, inertia, cognitive/social weights
- Velocity update: v = w*v + c1*r1*(pBest-x) + c2*r2*(gBest-x)
- Visualization: particles as dots, velocity as lines, best markers
- Convergence graph showing fitness over iterations

UI:
- Canvas in .card.full.ratio-16-9
- Widget before: title + slogan
- Widget after: algorithm explanation
- Widget modal: documentation
- Start/Pause and Reset controls
- Function selector dropdown
- Parameter sliders (inertia, cognitive, social)