https://github.com/estevesx10/particle-swarm-optimization
PSO Algorithm Development (From Scratch and with Pyswarms)
https://github.com/estevesx10/particle-swarm-optimization
pso-algorithm pyswarms
Last synced: 11 months ago
JSON representation
PSO Algorithm Development (From Scratch and with Pyswarms)
- Host: GitHub
- URL: https://github.com/estevesx10/particle-swarm-optimization
- Owner: EstevesX10
- License: mit
- Created: 2024-09-16T01:35:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-11T18:47:46.000Z (11 months ago)
- Last Synced: 2025-07-11T20:37:22.655Z (11 months ago)
- Topics: pso-algorithm, pyswarms
- Language: Jupyter Notebook
- Homepage:
- Size: 27.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Particle Swarm Optimization [Python]
## Project Overview
The objective of this project is to **develop the Particle Swarm Optimization (PSO) algorithm from scratch** in Python. It aims to **implement the core principles** of PSO, including the **initialization of particles**, **velocity updates**, and **position adjustments**, while allowing particles to **converge towards optimal solutions** based on the **balance between exploration and exploitation**.
In addition to developing the PSO algorithm from scratch, I also used the ``pyswarms`` package to **test the algorithm on a few selected objective functions** which allowed to assess the **algorithm's performance**.
## Project Development (Dependencies & Execution)
This project was developed using a `Notebook`. Therefore if you're looking forward to test it out yourself, keep in mind to either use a **[Anaconda Distribution](https://www.anaconda.com/)** or a 3rd party software that helps you inspect and execute it.
Therefore, for more informations regarding the **Virtual Environment** used in Anaconda, consider checking the [DEPENDENCIES.md](https://github.com/EstevesX10/Particle-Swarm-Optimization/blob/main/DEPENDENCIES.md) file.
## Particle Swarm Optimization
``Particle Swarm Optimization (PSO)`` is an **optimization technique** inspired by the social behavior of birds and fish. It involves **particles (potential solutions)** moving through a search space influenced by both their **own best positions** and the **group's best solution**.
``Key elements`` include **particle velocity**, **inertia**, and **social and cognitive acceleration factors**, which help **balance exploration and exploitation** of the search space.
PSO requires **few hyperparameters** which makes it **versatile** and **suitable** for various tasks. ``Adaptive PSO variations`` **adjust parameters dynamically** to **improve optimization performance**.
## Objective Functions
Given the characteristics of the algorithm, I have chosen a **set of objective functions** to **test its performance** on.
``Objective Functions`` assess each **particle's position** and provide a **fitness value**, allowing the algorithm to **iteratively refine solutions** and approach the **global optimum**.
These functions are designed to **represent a variety of optimization challenges**, providing a comprehensive evaluation of **how well the algorithm adapts to different types of problem spaces**.
Objective Functions Selected
Name
Formula
3D Graph
Sphere
f(x) = ∑di=1 xi2
Rastrigin
f(x) = 10d + ∑di=1 [xi2 - 10 cos(2πxi)]
Rosenbrock
f(x) = ∑d-1i=1 [100(xi+1 - xi2)2 + (xi - 1)2]
## Project Results
Here are the results obtained by using the ``pyswarms`` package to **minimize** the previously selected **objective functions**.
PSO Results
Objective Function
Cost History
2D Particle Search
3D Particle Search
Sphere
Ratrigin
Rosenbrock
These results demonstrate how effectively the **algorithm minimizes these functions**, highlighting its **versatility** and **performance** across diverse problem landscapes.
`README.md by Gonçalo Esteves`