File Exchange

image thumbnail

Particle Swarm Optimization (PSO) - GUI Simulator

version (103 KB) by Víctor Martínez-Cagigal
GUI that provides a highly-customized Particle Swarm Optimization simulator.


Updated 29 Jan 2016

View Version History

View License

This Graphic User Interface (GUI) provides a highly customized simulator of a classical collective intelligence algorithm: Particle Swarm Optimization (PSO).
Execute ‘main.m’ for running the main GUI program. As shown in the thumbnail, the program allows the user to configure the most important parameters of the PSO.
First of all, it is necessary to set the target search function. The GUI offers twelve different benchmark functions: a paraboloid, Griewank, Rastrigin, Rosenbrock, Bukin, Log-sumcan, Ackley, Drop-wave, Holder-table and Levy. Also, if ‘custom’ is selected, a new window will appear in order to configure the customized function in terms of a two-dimensional MATLAB expression @(x,y).
Once the target function is plotted, it is time to set the swarm parameters, such as the population size, the generation limit, the precision (error tolerance), and the velocity factors (percentage of the region of interest limits): inertia weight, individual confidence factor and swarm confidence factor.

Finally, pressing the ‘run’ button, the algorithm will start. Depending on the type of optimization previously selected, the fitness is the inverse of the function evaluation (minimization) or not (maximization). The GUI presents 3 different graphs: 3D-function graph (upper left), contour function with swarm evolution (upper right) and fitness monitoring (bottom). Swarm particles are displayed as black dots, while the best position ever found by the swarm is displayed as a red cross-hair.

Cite As

Víctor Martínez-Cagigal (2021). Particle Swarm Optimization (PSO) - GUI Simulator (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (8)

alpes ari

alpes ari

This simulator doesn't work proper with Holder Table function. İn simulation simulator find minimum values at out of the limits.

@Natalia Poll, Obviously... The Rastrigin function should be minimized.

Natalia Poll

This simulator doesnt work with Rastrigin function in type of optimization: maximization - no solution found.

shdotcom shdotcom

I have found the reason of this error. I should press on "Plot it" button before "Run" button
Great job. Thank you

shdotcom shdotcom

Dear Víctor Martínez,

would you please check this error.

Struct contents reference from a non-struct array object.
Error in main>run_button_Callback (line 189)
param.xy_lim = FUN.xy_lim;
Error in gui_mainfcn (line 95)

Error in main (line 42)
gui_mainfcn(gui_State, varargin{:});

Error in>@(hObject,eventdata)main('run_button_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

I am using Matlab 2017a

Sajjad Hussain

Is it possible to use this algorithm for constrained optimization problems?

ahmad almasri

MATLAB Release Compatibility
Created with R2015a
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!