Skip to content

zeniafragaki/Particle_Swarm_Optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 

Repository files navigation

Particle Swarm Optimization

This project presents a simple implementation of the Particle Swarm Optimization (PSO) algorithm in MATLAB, applied to the Ackley benchmark function for testing global optimization.Standars Particle Swarm Optimization algorithm is defined as below :

$$ \mathbf{v}_i^{t+1} = w \mathbf{v}_i^{t} + c_1 r_1 (\mathbf{pbest}_i - \mathbf{x}_i^{t}) + c_2 r_2 (\mathbf{gbest} - \mathbf{x}_i^{t}) $$

$$ \mathbf{x}_i^{t+1} = \mathbf{x}_i^{t} + \mathbf{v}_i^{t+1} $$

The Ackley function is defined as:

$$ f(x) = -20 \cdot \exp\left( -0.2 \cdot \sqrt{ \frac{1}{n} \sum_{i=1}^{n} x_i^2 } \right) - \exp\left( \frac{1}{n} \sum_{i=1}^{n} \cos(2 \pi x_i) \right) + 20 + e $$

The results was visualized as below :

image

As shown in the plot, the swarm successfully converges to the global minimum of the Ackley function.

Repository Structure

The repository is organized as follows:

  • Main/: Contains the main PSO algorithm and related scripts.
  • ackley.m: Defines the Ackley test function used for optimization.
  • plotPSO.m: Provides visualization of the PSO optimization process.
  • pso.m: Implements the PSO algorithm.

How to Use This Repository

  1. Clone the repository to your local machine using Git:
git clone https://github.com/zeniafragaki/Particle_Swarm_Optimization.git

  1. Open MATLAB and change the working directory to the Main folder inside the cloned repo:
cd('path/to/Particle_Swarm_Optimization/Main')

*Check your path before running the algorithm

  1. Run pso.m to start the PSO algorithm.

*4.If you use this algorithm, try changing the upper and lower bounds in the parameters section of pso.m, or replace Ackley’s benchmark function to observe how the PSO results change.

About

Standard Particle Swarm Optimization with Ackleys' benchmark function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages