image thumbnail

Tutorial: Genetic Algorithm and Particle Swarm Optimization

version (4.81 KB) by Karl Ezra Pilario
GA and PSO: Code with comments for understanding the algorithms.


Updated Thu, 19 May 2022 02:55:11 +0000

View License

This submission contains standard implementations of GA and PSO for minimizing various 2-D test functions. The code is intended for students who wish to learn GA and PSO code line by line. Users can change a few parameters to see the effects on the algorithm behavior.
The outputs of PSOtutor.m and GAtutor.m are:
  1. Simulation: Plot of all candidates as a moving scatter plot on the search space.
  2. Performance: Plot of worst, median, and best solutions against the elapsed iterations.
  3. Final Answer: Global minima where the run has converged.

Cite As

Karl Ezra Pilario (2022). Tutorial: Genetic Algorithm and Particle Swarm Optimization (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!