A list,
What is discrete particle swarm optimization? Particle Swarm Optimization Algorithm (PSO) Particle initial position and update speed are continuous functions, corresponding to which, Discrete Particle Swarm Optimization Algorithm (DPSO) is an Algorithm whose position and velocity update are both Discrete values. In general, after following the position of the new particle, the particle is treated with discrete points; For example, the discrete points of your particles are integers from 0 to 9. Then update the position of each particle, such as a random number in the range of (0,1). So the range (0, 0.1) is 0; The range (0.1,0.2) sets the value to 1; … (0.9.1) the range makes it 9. Of course, the initial position value also needs to be handled in this way. reference
2 What is discrete binary particle swarm optimization? Discrete Binary Particle Swarm Optimization Algorithm (BPSO) was first designed by J.Kennedy and R.C.Eberhart in 1997. PSO mainly optimizes continuous real value problems and BPSO mainly optimizes discrete space constraint problems. BPSO is based on the discrete particle swarm optimization algorithm, and the convention position vector and velocity vector are composed of 0 and 1 values. BPSO has a strong global search ability, but it cannot converge to the global optimal value. With the increasing randomness of iterative search algorithm, BPSO lacks the local search ability in the later stage.
3 steps of discrete binary particle swarm optimization
4 Experimental Steps
Reference: Analysis of discrete binary particle swarm optimization
Step 1: determine the benchmark function of the test;
Step 2: Test the iterative change of the average velocity of a particle, and the iterative change of the average probability of a particle taking 1; The probability of a particle changing iteratively; The iterative change of the distance from a particle to the optimal particle;
The third step is to propose the improved particle swarm optimization algorithm, the improved point is the probability function; Follow the second step of the experiment;
Step 4: propose an improved binary PSO algorithm based on genetic algorithm; Significance analysis was conducted to test the minimum mean fitness value and standard variance.
Ii. Source code
clear all; % -- -- -- -- -- - a given initial conditions -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - c1 =2; % learning factor1
c2=2; % learning factor2
w=0.7298; % inertia weight MaxDT=1000; % Maximum number of iterations D=10; % Dimension of search space (number of unknowns) N=50; % Number of initializing population c=[55.10.47.5.4.50.8.61.85.87]; A = [% price95.4.60.32.23.72.80.62.65.46]; B = % volume269; % Total volume % %100
% c=[297.295.293.292.291.289.284.284.283.283.281.280.279.277.276.275.273.264.260.257.250.236.236.235.235.233.232.232.228.218.217.214.211.208.205.204.203.201.196.194.193.193.192.191.190.187.187.184.184.184.181.179.176.173.172.171.160.128.123.114.113.107.105.101.100.100.99.98.97.94.94.93.91.80.74.73.72.63.63.62.61.60.56.53.52.50.48.46.40.40.35.28.22.22.18.15.12.11.6.5];
% a=[54.95.36.18.4.71.83.16.27.84.88.45.94.64.14.80.4.23.75.36.90.20.77.32.58.6.14.86.84.59.71.21.30.22.96.49.81.48.37.28.6.84.19.55.88.38.51.52.79.55.70.53.64.99.61.86.1.64.32.60.42.45.34.22.49.37.33.1.78.43.85.24.96.32.99.57.23.8.10.74.59.89.95.40.46.65.6.89.84.83.6.19.45.59.26.13.8.26.5.9];
% b=3820;
% % 80
% c=[199.194.193.191.189.178.174.169.164.164.161.158.157.154.152.152.149.142.131.125.124.124.124.122.119.116.114.113.111.110.109.100.97.94.91.82.82.81.80.80.80.79.77.76.74.72.71.70.69.68.65.65.61.56.55.54.53.47.47.46.41.36.34.32.32.30.29.29.26.25.23.22.20.11.10.9.5.4.3.1];
% a=[40.27.5.21.51.16.42.18.52.28.57.34.44.43.52.55.53.42.47.56.57.44.16.2.12.9.40.23.56.3.39.16.54.36.52.5.53.48.23.47.41.49.22.42.10.16.53.58.40.1.43.56.40.32.44.35.37.45.52.56.40.2.23.49.50.26.11.35.32.34.58.6.52.26.31.23.4.52.53.19];
% b=1173;
% 50
% c=[293.291.290.280.278.274.269.265.248.247.245.245.241.234.229.228.222.216.214.191.191.187.171.170.164.152.142.132.131.126.122.116.112.111.110.106.77.76.74.73.69.67.42.41.35.33.30.29.28.26]; % price % a=[95.39.69.63.49.104.56.58.47.23.17.129.91.28.77.125.73.5.103.63.76.23.47.79.119.125.26.119.79.56.50.75.12.26.31.43.41.38.29.21.14.9.3.17.8.8.9.7.4.5]; % volume % b=959; % Total volume % %20
% c=[44.46.90.72.91.40.75.35.8.54.78.40.77.15.61.17.75.29.75.63]; % price % a=[92.4.43.83.84.68.92.82.6.44.32.18.56.83.25.96.70.48.14.58]; % volume % b=878; % total volume %------ initializing population of individuals ------------ x= Zeros (N,D);for i=1:N,
for j=1:D % For dimension
if rand<=0.5
x(i,j)=0;
else
x(i,j)=1;
end
end
end
p=x;
v(1, :) =0.1*x(1, :);for i=1:N
if a*x(i,:)'>b x(i,:)=GTA( x(i,:),c,a,b ); end end pg=x(1,:); % -- -- -- -- -- -- the main loop -- -- -- -- -- -- -- -- -- -- -- -- for t = 1: MaxDT for I = 2: N for j = 1: D v (I, j) = w * v (I - 1, j )+c1*round(rand(1))*(p(i-1,j)-x(i-1,j))+c2*round(rand(1))*(pg(1,j)-x(i-1,j)); q=rand(1); if [1/(1+exp(-x(i,j)))]>q x(i,j)=1; else x(i,j)=0; end end if a*x(i,:)'>b
x(i,:)=GTA( x(i,:),c,a,b );
end
if c*(x(i,:))'>c*(p(i-1,:))'
p(i,:)=x(i,:);
else p(i,:)=p(i- 1, :); end %if c*(p(i,:))'>c*(pg)'pg=p(i,:); End end %------ initializes the population of individuals ------------ x=eye(N,D); p=x; v(1, :) =0.1*x(1, :); pg=x(1, :); %------ main loop ------------for t=1:MaxDT
for i=2:N
for j=1:D
v(i,j)=w*v(i- 1,j )+c1*round(rand(1))*(p(i- 1,j)-x(i- 1,j))+c2*round(rand(1))*(pg(1,j)-x(i- 1,j));
q=rand(1);
if [1/ (1+exp(-v(i,j)))]>q
x(i,j)=1;
else x(i,j)=0;
end
end
if a*x(i,:)'<b
if c*(x(i,:))'>c*(p(i- 1, :))'
p(i,:)=x(i,:);
else p(i,:)=p(i- 1, :);end
else p(i,:)=p(i- 1, :); end %if c*(p(i,:))'>c*(pg)'
pg=p(i,:);
end
end
Copy the code
3. Operation results
Fourth, note
Version: 2014 a