Implementation of a particle swarm optimizer with different extensions such as:
- static and dynamic/adaptive parameters,
- various population topologies, and
- novel modification with intra-swarm hierarchical structure (monarchy-based PSO).
fnc
,fnc_select
: function and function ID (1...11), respectively.dim
: dimension of search space (recommended: 2).lb
,ub
: lower and upper bound of search space.N
: number of particles in swarm.max_iter
: maximum number of allowed iterations.w
,a1
,a2
: hyperparameters/acceleration coefficients.vel_rel
: maximum allowed velocity of particles.CODE_SELECT
: encoding of PSO and swarm properties.- 1st char (gPSO or lPSO?): [g = global PSO; l = local PSO]
- 2nd char (Topology?): [r = ring; w = wheel; n = von Neumann; x = random; f = full-mesh (gPSO)]
- 3d char (Hyperparameter?): [0 = static hyperparameter; 1 = adaptive/dynamic hyperparameter]
- Example: 'ln0' corresponds to local PSO (
l
) with static/constant hyperparameters (0
) and von-Neumann swarm topology (n
).
Particle.m
: class holding the properties and functions of object Particle.SwarmOptimizer_TB.m
: Simple PSO algorithm that finds optimum/minimum (glob_best_F
,glob_best_pos
) to objective function (fnc
). Additionally, it returns the number of required iterations (iter
), the total number of required fitness-function evaluationsfnc_eval
, and a messagemessage
that indicates if PSO ran successfully or not.SwarmOptimizer_Monarchy.m
: Monarchy-based PSO algorithm that finds optimum/minimum (glob_best_F
,glob_best_pos
) to objective function (fnc
), the number of required iterations (iter
), the total number of required fitness-function evaluationsfnc_eval
, and a messagemessage
that indicates if PSO ran successfully or not. Attention: hyperparametersw
,a1
anda2
are vectors with 2 elements as we have two classes of particles.test_functions_2D.m
: selection of benchmark function.x1
andx2
correspond to the optimising parameter, andCASE
corresponds to ID of selected benchmark (allowed values: 1...11).StoppingCriteria.m
: function evaluating the stopping criterion.get_Topology.m
: generates swarm topology and stores it in a cell array for efficient access.
-> Note: to change the citerion, change 'type'-variable within function (iftype = 1
then PSO stops if no better solution found in a certain amount of iterations , and iftype = 2
then PSO stops if no significant improvement of solution detected).random_point.m
: generates random point in boundslb
,up
with a resolution of 0.001.
testbench.m
: function that runs and evaluates the simple PSO algorithm based on correctness, execution time, and the number of required iterations and function evaluations. Relevant parameters required for optimizer must be set by user (fnc
,dim
,lb
,ub
,N
,max_iter
,w
,a1
,a2
,vel_rel
,fnc_select
, andCODE_SELECT
).testbench_Monarchy.m
: same functionality astestbench.m
; however, it executes and evaluates the novel monarchy-based PSO.run_MATLAB.m
: function that solves optimization problem unsing the built-in MATLAB PSO algorithm and returns found optimum, number of evalutations and iterations, and the required CPU_time.
-
plot_Optimizer.m
: Executes single PSO run with user-specified parameter such as hyperparameters (w
,a1
anda2
), benchmark functionselect_CASE
or swarm topologyCODE_SELECT_topography
. IfPLOT = true
then entire process is plotted, ifMOVIE = true
then PSO execution is stored as .avi-file, and ifMONARCHY = true
then monarachy-based PSO is executed instead of a standard PSO.
Available PSO parameters:w
,a1
anda2
are PSO hyperparameter,dim
defines search space dimension,select_CASE
defines benchmark function,max_iter
defines maximum number of allowed iterations,N
defines number of particles in swarm,CODE_SELECT_topography
defines the swarm topography, andvel_rel
defines maximum velocity of particles relative to search space.
-
plot_benchmarks.m
: plot available (2-dim) benchmark functions (values: 1..11). -
make_movie.m
: generates a video from the stored paramters and stores it as .avi-file.
The following functions are only for debugging and parameter optimization. Each particle position is stored in each iteration - PSO algorithm execution can be then observed using the function plot_Optimizer.m
. Do not use these functions for actual optimization problems - they are slow, memory intensive functions.
PSO_Plot.m
: function that executes simple PSO (seeSwarmOptimizer_TB.m
).PSO_Plot_Monarchy.m
: function that executes monarchy-based PSO (seeSwarmOptimizer_Monarchy.m
).