{"id":29970484,"url":"https://github.com/estevesx10/particle-swarm-optimization","last_synced_at":"2025-08-04T05:10:49.103Z","repository":{"id":304230803,"uuid":"857936976","full_name":"EstevesX10/Particle-Swarm-Optimization","owner":"EstevesX10","description":"PSO Algorithm Development (From Scratch and with Pyswarms)","archived":false,"fork":false,"pushed_at":"2025-07-11T18:47:46.000Z","size":29304,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-11T20:37:22.655Z","etag":null,"topics":["pso-algorithm","pyswarms"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EstevesX10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-09-16T01:35:17.000Z","updated_at":"2025-07-11T18:47:49.000Z","dependencies_parsed_at":"2025-07-11T20:47:34.476Z","dependency_job_id":null,"html_url":"https://github.com/EstevesX10/Particle-Swarm-Optimization","commit_stats":null,"previous_names":["estevesx10/particle-swarm-optimization"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/EstevesX10/Particle-Swarm-Optimization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstevesX10%2FParticle-Swarm-Optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstevesX10%2FParticle-Swarm-Optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstevesX10%2FParticle-Swarm-Optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstevesX10%2FParticle-Swarm-Optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EstevesX10","download_url":"https://codeload.github.com/EstevesX10/Particle-Swarm-Optimization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EstevesX10%2FParticle-Swarm-Optimization/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268653835,"owners_count":24285071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-04T02:00:09.867Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pso-algorithm","pyswarms"],"created_at":"2025-08-04T05:10:48.285Z","updated_at":"2025-08-04T05:10:49.064Z","avatar_url":"https://github.com/EstevesX10.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eParticle Swarm Optimization [Python]\u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\" width=\"100%\"\u003e\n    \u003cimg src=\"./Particle Swarm Optimization/Assets/PSO.gif\" width=\"55%\" /\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Made%20with-Python-9ACFC3?style=for-the-badge\u0026logo=Python\u0026logoColor=9ACFC3\"\u003e\n    \u003c/a\u003e\n    \u003ca\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Made%20with-Jupyter-9ACFC3?style=for-the-badge\u0026logo=Jupyter\u0026logoColor=9ACFC3\"\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/EstevesX10/Particle-Swarm-Optimization/blob/main/LICENSE\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/EstevesX10/Particle-Swarm-Optimization?style=flat\u0026logo=gitbook\u0026logoColor=9ACFC3\u0026label=License\u0026color=9ACFC3\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/repo-size/EstevesX10/Particle-Swarm-Optimization?style=flat\u0026logo=googlecloudstorage\u0026logoColor=9ACFC3\u0026logoSize=auto\u0026label=Repository%20Size\u0026color=9ACFC3\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/stars/EstevesX10/Particle-Swarm-Optimization?style=flat\u0026logo=adafruit\u0026logoColor=9ACFC3\u0026logoSize=auto\u0026label=Stars\u0026color=9ACFC3\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://github.com/EstevesX10/Particle-Swarm-Optimization/blob/main/DEPENDENCIES.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Dependencies-DEPENDENCIES.md-white?style=flat\u0026logo=anaconda\u0026logoColor=9ACFC3\u0026logoSize=auto\u0026color=9ACFC3\"\u003e \n    \u003c/a\u003e\n\u003c/div\u003e\n\n## Project Overview\n\nThe 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**.\n\nIn 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**.\n\n## Project Development (Dependencies \u0026 Execution)\n\nThis 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. \n\nTherefore, 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.\n\n## Particle Swarm Optimization\n\n``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**. \n\n``Key elements`` include **particle velocity**, **inertia**, and **social and cognitive acceleration factors**, which help **balance exploration and exploitation** of the search space. \n\nPSO requires **few hyperparameters** which makes it **versatile** and **suitable** for various tasks. ``Adaptive PSO variations`` **adjust parameters dynamically** to **improve optimization performance**.\n\n## Objective Functions\n\nGiven the characteristics of the algorithm, I have chosen a **set of objective functions** to **test its performance** on. \n\n``Objective Functions`` assess each **particle's position** and provide a **fitness value**, allowing the algorithm to **iteratively refine solutions** and approach the **global optimum**.\n\nThese 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**.\n\n\u003ctable width=\"100%\"\u003e\n  \u003ctr\u003e\n    \u003cth colspan=\"3\" height=\"100%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n            Objective Functions Selected\n        \u003c/div\u003e\n    \u003c/th\u003e\n  \u003c/tr\u003e\n  \n  \u003ctr\u003e\n    \u003ctd width=\"25%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eName\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"25%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eFormula\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"25%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003e3D Graph\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"5%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eSphere\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"40%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n            f(x) = \u0026sum;\u003csup\u003ed\u003c/sup\u003e\u003csub\u003ei=1\u003c/sub\u003e x\u003csub\u003ei\u003c/sub\u003e\u003csup\u003e2\u003c/sup\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"55%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/Assets/SphereFunction.png\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"5%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eRastrigin\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"40%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n            f(x) = 10d + \u0026sum;\u003csup\u003ed\u003c/sup\u003e\u003csub\u003ei=1\u003c/sub\u003e [x\u003csub\u003ei\u003c/sub\u003e\u003csup\u003e2\u003c/sup\u003e - 10 cos(2\u0026pi;x\u003csub\u003ei\u003c/sub\u003e)]\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"55%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/Assets/RastriginFunction.png\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"5%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eRosenbrock\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"40%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n            f(x) = \u0026sum;\u003csup\u003ed-1\u003c/sup\u003e\u003csub\u003ei=1\u003c/sub\u003e [100(x\u003csub\u003ei+1\u003c/sub\u003e - x\u003csub\u003ei\u003c/sub\u003e\u003csup\u003e2\u003c/sup\u003e)\u003csup\u003e2\u003c/sup\u003e + (x\u003csub\u003ei\u003c/sub\u003e - 1)\u003csup\u003e2\u003c/sup\u003e]\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"55%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/Assets/RosenbrockFunction.png\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n\u003c/table\u003e\n\n## Project Results\n\nHere are the results obtained by using the ``pyswarms`` package to **minimize** the previously selected **objective functions**.\n\n\u003ctable width=\"100%\"\u003e\n  \u003ctr\u003e\n    \u003cth colspan=\"4\" height=\"100%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n            PSO Results\n        \u003c/div\u003e\n    \u003c/th\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eObjective Function\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eCost History\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"20%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003e2D Particle Search\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003e3D Particle Search\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eSphere\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Cost History/SphereCostHistory.png\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/2D_SphereParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"50%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/3D_SphereParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eRatrigin\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Cost History/RastriginCostHistory.png\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\".//Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/2D_RastriginParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\".//Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/3D_RastriginParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\n  \u003ctr\u003e\n    \u003ctd width=\"10%\"\u003e\n        \u003cdiv align=\"center\"\u003e\n        \u003cb\u003eRosenbrock\u003c/b\u003e\n        \u003c/div\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Cost History/RosenbrockCostHistory.png\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/2D_RosenbrockParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n    \u003ctd width=\"30%\"\u003e\n        \u003cp align=\"center\"\u003e\u003cimg src=\"./Particle Swarm Optimization/PSO with Pyswarms/Particle Searches/3D_RosenbrockParticlesSearch.gif\" height=\"auto\"/\u003e\n        \u003c/p\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nThese results demonstrate how effectively the **algorithm minimizes these functions**, highlighting its **versatility** and **performance** across diverse problem landscapes.\n\n\u003cdiv align=\"right\"\u003e\n\u003csub\u003e\n\n\u003c!-- \u003csup\u003e\u003c/sup\u003e --\u003e\n`README.md by Gonçalo Esteves`\n\u003c/sub\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festevesx10%2Fparticle-swarm-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Festevesx10%2Fparticle-swarm-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Festevesx10%2Fparticle-swarm-optimization/lists"}