First, the way to obtain the code
Get the code 1: by subscribing to the paid column of purple Pole Shenguang blog, you can get this code with payment voucher, private letter bloggers.
Access code 2: Open CSDN membership through the homepage of CSDN blog, and the code can be obtained by payment voucher and private letter bloggers.
Differential swarm optimization algorithm (DEABC) differential swarm optimization algorithm (DEABC)
Note: For CSDN membership, only one code can be obtained free of charge (valid within three days from the date of opening); Subscribe to the paid column of purple Pole Shenguang blog, you can get 2 copies of the code for free (valid for three days from the subscription date);
Two, some source code
Clear CLC close all %% objfun=@f1; ub=100; lb=- 100.; %sphere global minimum value is0objfun=@f2; lb=- 600.; ub=600; %griewank global minimum value is0objfun=@f3; lb=- 100.; ub=100; %rastrigin The global minimum value is0objfun=@f4; lb=- 10; ub=10; %rosenbrock The global minimum value is0
%%
d=2;
max_iter=2500;
sizepop=20; % % %1Particle swarm [pso_position, pso_fitness pso_trace] = pso (objfun, d, max_iter sizepop, ub, lb). %2Genetic algorithm [GA_position, GA_FITNESS, GA_trace]= GA (objFun, D,max_iter, sizePOP,ub,lb); %2Differential evolution algorithm [DE_position, DE_FITNESS, DE_trace]= DE1 (objFun, D,max_iter, sizePOP, UB,lb); %3Swarm algorithm [ABc_position, ABC_FITNESS, ABC_trace]= ABC (ObjFun, D,max_iter, sizePOP, UB,lb); % differential bee colony [DEABc_position, DEABC_FITNESS, DEABC_trace]=DEABC(ObjFun, D,max_iter, sizePOP, UB,lb); % %figure
plot(pso_trace(:,1))
hold on
plot(ga_trace(:,1))
plot(de_trace(:,1))
plot(abc_trace(:,1))
plot(deabc_trace(:,1))
legend('PSO'.'GA'.'DE'.'ABC'.'DEABC')
xlabel('Number of iterations')
ylabel('Fitness value/function value')
%%
figure
plot(log10(pso_trace(:,1)),'b-')
hold on
plot(log10(ga_trace(:,1)),'r-')
plot(log10(de_trace(:,1)),'g-')
plot(log10(abc_trace(:,1)),'k-')
plot(log10(deabc_trace(:,1)),'m-')
legend('PSO'.'GA'.'DE'.'ABC'.'DEABC')
xlabel('Number of iterations')
ylabel('Fitness value /log10(function value)')
img =gcf; Print (img,'-dpng'.'-r600'.'./img.png') % to get the corresponding format and expected DPI imageCopy the code
3. Operation results
Matlab version and references
1 matlab version 2014A
[1] Yang Baoyang, YU Jizhou, Yang Shan. Intelligent Optimization Algorithm and Its MATLAB Example (2nd Edition) [M]. Publishing House of Electronics Industry, 2016. [2] ZHANG Yan, WU Shuigen. MATLAB Optimization Algorithm source code [M]. Tsinghua University Press, 2017.