DOI: 10.13140/RG.2.2.16986.88000
This repository contains the standard Particle Swarm Optimization code (matlab M-file) for optimizing the benchmark function:
.
├── img
| ├── benchmark.gif
| ├── convergence-2d.png
| ├── convergence-30d.png
| ├── logo.jpg
| └── trajectory.png
├── _config.yml
├── LICENSE
├── pso.m —— [function of particle swarm optimization]
├── README.md
└── test.m —— [a test for 'pso.m']
[f_best, x_best] = pso ( J, d, xlmt, n, T )where
Jis the function handle of the objective functiondis the dimension of the design variablexlmtis the limit of the design variable; is a matrix withdrows and 2 column, and the first column contains lower limits of all dimension while the second upper ones.nis the population size of the particle swarmTis the maximum iteration times.f_bestis the fitness of the optimal solutiong_bestis the optimal solution
For instance, a benchmark Rastrigin is chosen for a test:
Here, this benchmark is coded as a function handle
J = @(X) sum( X.^2 - 10*cos(2*pi*X) + 10 );where X is a d-by-n matrix.
To run the test by executing
test.mThe test including two runs:
-
30-
dbenchmarkThe results includes an optimal solution, its fitness and an execution time. Also, a plot of the convergence curve of fitness is shown.
-
2-
dbenchmarkThe results includes an optimal solution, its fitness and an execution time. Also, a plot of the convergence curve of fitness, a plot of the trajectory of global optimal are shown.
[1] Article: Particle swarm optimization (PSO). A tutorial
[2] Author's post (Chinese simplified): 粒子群优化及其Matlab实现
[3] Repo: BenchmarkFcns



