This repository contains a standard implementation of the Particle Swarm Optimization (PSO) algorithm. To evaluate the effectiveness of this nonlinear optimization technique, the 2D version of the Michalewicz function has been utilized. Additionally, the repository features a 3D visualization of the algorithm, providing a clearer demonstration of how PSO operates. All code and simulations have been developed in the MATLAB environment.
Particle Swarm Optimization (PSO) is a nature-inspired optimization algorithm, particularly influenced by the behavior of flocks of birds. It was developed by Kennedy and Eberhart in the late 1990s and has gained significant fame since then [1]. As a swarm intelligence algorithm, PSO utilizes multiple "agents" also known as particles, that move randomly within the search space to explore and identify the optimal solution
Visualization of the algorithm for swarm of 10 particles finding global minima on Michalewicz function
Each swarm particle updates its current position and velocity at each time step
For a single swarm, the position of the
where
The velocity is calculated as:
where
-
Inertia coefficient (
$w$ )
This parameter represents the inertia weight of the particle, which indicates the particle's tendency to maintain its previous speed. This term is often referred to as controlling the particle's momentum -
Nostalgia constant (
$c_{1}$ )
The nostalgia constant, or cognitive term, represents each particle's personal experience and acts as an amplification of its personal best, making it tend to keep its best position so far. -
Envy constant (
$c_{2}$ )
The envy constant, or social term, determines the influence of the entire swarm. This means each particle tries to mimic the neighboring particles to move as a whole based on the global best.
To test the algorithm, a benchmark function in nonlinear optimization, i.e. the Michalewicz function is employed [3]. This function is characterized by many local minima and a single global minima, making the search process quite challenging. Mathematically, for a d-dimensional space, the function can be expressed as follows [4]:
where
For demonstration purposes, the 2D version is used in this repository where the true global minima (for a
As a stopping criterion, a total of 100 iterations was chosen however, the algorithm converges in the first 30.
[1] J. Kennedy and R. Eberhart, “Particle swarm optimization,” in Proceedings of ICNN’95 - International Conference on Neural Networks, Perth, WA, Australia: IEEE, 1995, pp. 1942–1948. doi: 10.1109/ICNN.1995.488968.
[2] A. Kapnopoulos and A. Alexandridis, “A cooperative particle swarm optimization approach for tuning an MPC-based quadrotor trajectory tracking scheme,” Aerospace Science and Technology, vol. 127, p. 107725, Aug. 2022, doi: 10.1016/j.ast.2022.107725.
[3] X.-S. Yang, Nature-inspired optimization algorithms, First edition. in Elsevier insights. Amsterdam Boston Heidelberg London New York Oxford Paris San Diego San Francisco Singapore Sydney Tokyo: Elsevier, 2014.
[4] M. Molga and C. Smutnicki, Test functions for optimization needs, 2005
