The realization of the standard particle swarm optimization (PSO) algorithm is based on the particle Swarm algorithm (2)----the standard particle swarm optimization algorithm. It is mainly divided into 3 functions. The first function is the particle swarm initialization function
Initswarm (Swarmsize .....) ADAPTFUNC) Its main function is to initialize particles of particle swarm, and set the velocity and position of particles in a certain range. The data structures used in this function are as follows:
The table Parswarm records the position of the particle, the velocity and the current fitness value, we use W to represent the position, the velocity with V, and F to represent the current fitness value. Here we assume that the number of particles is n, and the dimension of each particle is d.
W1,1 |
W1,2 |
... |
W1,d |
V1,1 |
V1,2 |
... |
V1,d-1 |
V1,d |
F1 |
A 1th particle. |
w 2,2 |
|
w 2,d |
v 2,1 |
v 2,2 |
|
v 2,d-1 |
v 2,d |
f 2 |
2nd particle |
|
|
|
|
|
|
|
|
|
|
|
w n-1,2 |
|
w n-1,d-1 |
v n-1,1 |
v n-1,2 |
|
v n-1,d-1 |
v n-1,d |
f N-1 |
N-1 particle |
Wn,1 |
Wn,2 |
... |
Wn,d |
Vn,1 |
Vn,2 |
... |
Vn,d-1 |
Vn,d |
FN |
Nth particle |
The table Optswarm records the optimal solution of each particle's history (the best fitness for particle history) and the global optimal solution for all the particles. The global optimal solution is represented by the WG, and the w.,1 represents the historical optimal solution of each particle. The first n rows in the particle swarm initialization stage table Optswarm are the same as in the table Parswarm, and the WG's value is the row for the maximum value of the fitness value in the table Parswarm.
wj,1 |
wj,2 |
... |
Wj,d-1 |
Wj,d |
The historical optimal solution of a 1th particle |
wk,1 |
wk,2 |
... |
Wk,d-1 |
Wk,d |
The historical optimal solution of a 2nd particle |
... |
... |
... |
... |
... |
... |
wl,1 |
wl,2 |
... |
Wl,d-1 |
Wl,d |
The historical optimal solution of the first N-1 particle |
wm,1 |
wm,2 |
... |
Wm,d-1 |
Wm,d |
The historical optimal solution of nth particle |
wg,1 |
wg,2 |
... |
Wg,d-1 |
Wg,d |
The historical optimal solution of global particles |