A list,

Particle swarm Optimization (PSO) is an evolutionary computation technology. It comes from the study of predation behavior in flocks of birds. The basic idea of particle swarm optimization algorithm is to find the optimal solution through the cooperation and information sharing among individuals in the group. The advantage of PSO is that it is simple and easy to implement without many parameters adjustment. It has been widely used in function optimization, neural network training, fuzzy system control and other applications of genetic algorithms.

2. Analysis of particle swarm optimization

2.1 Basic Ideas

Particle swarm optimization (PSO) simulates a bird in a flock by designing a massless particle that has only two properties: speed and position. Speed represents how fast the bird moves, and position represents the direction of the bird. Each particle separately searches for the optimal solution in the search space, and records it as the current individual extreme value, and shares the individual extreme value with other particles in the whole particle swarm, and finds the optimal individual extreme value as the current global optimal solution of the whole particle swarm. All particles in a swarm adjust their speed and position based on the current individual extremum they find and the current global optimal solution shared by the whole swarm. The following GIF vividly shows the process of the PSO algorithm:



2 Update Rules

PSO initializes as a group of random particles (random solutions). Then find the optimal solution through iteration. At each iteration, the particle updates itself by tracking two “extreme values” (PBest, GBest). After finding these two optimal values, the particle updates its velocity and position by using the formula below.



The first part of formula (1) is called [memory term], which represents the influence of the magnitude and direction of the last speed. The second part of Formula (1) is called [self cognition term], which is a vector pointing from the current point to the particle’s own best point, indicating that the particle’s action comes from its own experience. The third part of Formula (1) is called [group cognition term], which is a vector from the current point to the best point of the population, reflecting the cooperation and knowledge sharing among particles. The particle is determined by its own experience and the best experience of its companions. Based on the above two formulas, the standard form of PSO is formed.



Formula (2) and Formula (3) are regarded as standard PSO algorithms.

3. Process and pseudocode of PSO algorithm

Ii. Source code

SR=1000; % Searching range RNS=1; The ratio of The number of Particles to The searching range M=RNS*SR; % group size W=0.5; Inertia weight anaesthetist C1=5; % Accelerated constant C2=5; % Accelerated constant RVR=0.02; % The ratio of The maximum velocity to The searching range RCS=0.01; The ratio of The convergent interval to The searching range CI=RCS*SR; % Convergence interval Convergent interval PT=0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001; % Pause time Pause time RNPA=0.5; The ratio of The negative half axis to The positive half axis x=SR*rand(1,M);
 y=SR*rand(1,M);
 z=SR*rand(1,M); px=x; py=y; pz=z; Vx =RVR*SR*rand(1,M);
 vxmax=RVR*SR*(zeros(1,M)+1);
 vy=RVR*SR*rand(1,M);
 vymax=RVR*SR*(zeros(1,M)+1);
 vz=RVR*SR*rand(1,M);
 vzmax=RVR*SR*(zeros(1,M)+1);
 ox=SR*rand*(zeros(1,M)+1);
 oy=SR*rand*(zeros(1,M)+1);
 oz=SR*rand*(zeros(1,M)+1); % Randomly generated valley location above the initialization process sx=abs(x-ox);
 sy=abs(x-oy);
 sz=abs(x-oz); % Evaluate fitness of each particle [r,c]=find(sx==min(min(sx))); gx=x(r,c)*(zeros(1,M)+1);
 [r,c]=find(sy==min(min(sy)));
 gy=y(r,c)*(zeros(1,M)+1);
 [r,c]=find(sz==min(min(sz)));
 gz=z(r,c)*(zeros(1,M)+1);
while(Max (Max (sx)) > CI) | | (Max (Max (sy)) > CI) | | (Max (Max (sz)) > CI) convergence interval OS x = % determine results0.1*SR*rand*(zeros(1,M)+1);
      oy=0.1*SR*rand*(zeros(1,M)+1);
      oz=0.1*SR*rand*(zeros(1,M)+1);
      plot3(ox,oy,oz,'r*');
      title('3d Particle Swarm Optimization Convergence Demonstration');
      text(ox,oy,oz,'Random target point');
      xlabel('X'),
      ylabel('Y'),
      zlabel('Z');
      axis([-RNPA*SR SR -RNPA*SR SR -RNPA*SR SR]);
      grid on;
      hold on;
      plot3(x,y,z,'b*');
      hold off;
      pause(PT);
      if max(max(sx))>CI
         vx=W*vx+C1*rand*(px-x)+C2*rand*(gx-x); % give v a change based on the algorithm equation. Because the interval length is small, the inertia and self-cognition ability of particles are weakened, and the social ability is strengthened to obtain the optimal solution as soon as possiblewhile  max(max(vx))>RVR*SR||min(min(vx))<-RVR*SR
                if max(max(vx))>RVR*SR
                   [r,c]=find(vx==max(max(vx)));
                   vx(r,c)=RVR*SR;
                end
                if min(min(vx))<-RVR*SR
                   [r,c]=find(vx==min(min(vx))); vx(r,c)=-RVR*SR; End % is the size of the limit v, to avoid particles flying over the good solution or into the local optimal value end x=x+vx;for i=1:M
             if abs(x(1,i)-ox(1,i))<sx(1,i)
                px(1,i)=x(1,i);
             end
         end
         sx=abs(x-ox);
         [r,c]=find(sx==min(min(sx)));
         gx=x(r,c)*(zeros(1,M)+1);
      end
      if max(max(sy))>CI
         vy=W*vy+C1*rand*(py-y)+C2*rand*(gy-y);
         while  max(max(vy))>RVR*SR||min(min(vy))<-RVR*SR
                if max(max(vy))>RVR*SR
                   [r,c]=find(vy==max(max(vy)));
                   vy(r,c)=RVR*SR;          
                end
                if min(min(vy))<-RVR*SR
                   [r,c]=find(vy==min(min(vy))); vy(r,c)=-RVR*SR; The size of v is limited above end% to avoid particles flying over the good solution or falling into local optimal value.for i=1:M
             if abs(y(1,i)-oy(1,i))<sy(1,i)
                py(1,i)=y(1,i);
             end
         end
         sy=abs(y-oy);
         [r,c]=find(sy==min(min(sy)));
         gy=y(r,c)*(zeros(1,M)+1);
      end
      if max(max(sz))>CI
         vz=W*vz+C1*rand*(pz-z)+C2*rand*(gz-z);
         while  max(max(vz))>RVR*SR||min(min(vz))<-RVR*SR
                if max(max(vz))>RVR*SR
                   [r,c]=find(vz==max(max(vz)));
                   vz(r,c)=RVR*SR; 
                end
                if min(min(vz))<-RVR*SR
                   [r,c]=find(vz==min(min(vz))); vz(r,c)=-RVR*SR; End % is used to limit the size of v to avoid particles flying over the good solution or falling into the local optimal value endCopy the code

3. Operation results



Fourth, note

Version: 2014a complete code or write plus 1564658423