二、部分源代码


clear all
close all
clc

N = 50; % Number of Searcher Agents "
Max_Iteration = 100; % Maximum number of "iterations"
Q=1; % ACO Parameter
tau0=10; % Initial Phromone (ACO)
alpha=0.3; % Phromone Exponential Weight (ACO)
rho=0.1; % Evaporation Rate (ACO)
beta_min=0.2; % Lower Bound of Scaling Factor (DE)
beta_max=0.8; % Upper Bound of Scaling Factor (DE)
pCR=0.2; % Crossover Probability (DE)
ElitistCheck=1; % GSA Parameter
Rpower=1; % GSA Parameter
min_flag=1; % 1: minimization, 0: maximization (GSA)
Algorithm_num=2; %% These are 10 chaotic maps mentioned in the paper. So, change the value of Algorithm_num from 2 to 11 as 1 is for standard GSA.
chValueInitial=20; % CGSA

Benchmark_Function_ID=1 %Benchmark function ID

RunNo = 20;

for k = [ 1 : 1 : RunNo ]
% % %
[gBestScore,gBest,GlobalBestCost]= CPSOGSA(Benchmark_Function_ID, N, Max_Iteration);
BestSolutions1(k) = gBestScore;
% [Fbest,Lbest,BestChart]=GSA(Benchmark_Function_ID,N,Max_Iteration,ElitistCheck,min_flag,Rpower);
% BestSolutions2(k) = Fbest;
% [PcgCurve,GBEST]=pso(Benchmark_Function_ID,N,Max_Iteration);
% BestSolutions3(k) = GBEST.O;
% [BestCost,BestSol] = bbo( Benchmark_Function_ID, N, Max_Iteration);
% BestSolutions4(k) = BestSol.Cost;
% [BestSolDE,DBestSol,BestCostDE] = DE(Benchmark_Function_ID, N, Max_Iteration,beta_min,beta_max,pCR);
% BestSolutions5(k) = BestSolDE.Cost ;
% [BestSolACO,BestAnt,BestCostACO] = ACO(Benchmark_Function_ID, N, Max_Iteration,Q,tau0,alpha,rho);
% BestSolutions6(k) = BestSolACO.Cost ;
% [Best_score,Best_pos,SSA_cg_curve]=SSA(Benchmark_Function_ID, N, Max_Iteration);
% BestSolutions7(k) = Best_score ;
% [Best_scoreSCA,Best_pos,SCA_cg_curve]=SCA(Benchmark_Function_ID, N, Max_Iteration);
% BestSolutions8(k) = Best_scoreSCA ;
% [Best_scoreGWO,Best_pos,GWO_cg_curve]=GWO(Benchmark_Function_ID, N, Max_Iteration);
% BestSolutions9(k) = Best_scoreGWO ;

% if Algorithm_num==6
% [CFbest,CLbest1,CBestChart]=CGSA(Benchmark_Function_ID,N,Max_Iteration,ElitistCheck,min_flag,Rpower,Algorithm_num,chValueInitial);
% BestSolutions10(k) = CFbest ;
% end

Average= mean(BestSolutions1);
StandDP=std(BestSolutions1);
Med = median(BestSolutions1);
[BestValueP I] = min(BestSolutions1);
[WorstValueP IM]=max(BestSolutions1);

disp(['Run # ' , num2str(k), ' gBestScore: ' , num2str( gBestScore)]);
% disp(['Run # ' , num2str(k), ' Fbest: ' , num2str( Fbest)]);
% disp(['Run # ' , num2str(k), ' GBEST.O: ' , num2str( GBEST.O)]);
% disp(['Run # ' , num2str(k), ' BestSol.Cost: ' , num2str( BestSol.Cost)]);
% disp(['Run # ' , num2str(k), ' BestSolDE.Cost : ' , num2str( BestSolDE.Cost)]);
% disp(['Run # ' , num2str(k), ' BestSolACO.Cost: ' , num2str( BestSolACO.Cost )]);
% disp(['Run # ' , num2str(k), ' Best_score : ' , num2str( Best_score)]);
% disp(['Run # ' , num2str(k), ' Best_scoreSCA : ' , num2str( Best_scoreSCA)]);
% disp(['Run # ' , num2str(k), ' Best_scoreGWO : ' , num2str( Best_scoreGWO)]);
% disp(['Run # ' , num2str(k), ' CFbest : ' , num2str( CFbest ),' Algorithm_num= ' , num2str(Algorithm_num)])
end




disp([ 'Best=',num2str( BestValueP)]);
disp(['Worst=',num2str(WorstValueP)]);
disp(['Average=',num2str( Average)]);
disp([ 'Standard Deviation=',num2str( StandDP)]);
disp(['Median=',num2str(Med)]);



figure

semilogy(1:Max_Iteration,GlobalBestCost,'DisplayName','CPSOGSA', 'Color', 'r','Marker','diamond','LineStyle','-','LineWidth',2,...
'MarkerEdgeColor','r','MarkerFaceColor',[.49 1 .63],'MarkerSize',2);
% hold on
% semilogy(1:Max_Iteration,BestChart,'DisplayName','GSA','Color','g','Marker','o','LineStyle','-','LineWidth',2,...
% 'MarkerEdgeColor','g','MarkerFaceColor',[.49 1 .63],'MarkerSize',2);
% semilogy(1:Max_Iteration,PcgCurve,'DisplayName','PSO','Color','c','Marker','square','LineStyle','-','LineWidth',2,...
% 'MarkerEdgeColor','c','MarkerFaceColor',[.49 1 .63],'MarkerSize',2);
% semilogy(1:Max_Iteration,BestCost,'DisplayName','BBO','Color','b','Marker','*','LineStyle','-','LineWidth',2,...
% 'MarkerEdgeColor','b','MarkerFaceColor',[.49 1 .63],'MarkerSize',2);
% semilogy(1:Max_Iteration,BestCostDE,'DisplayName','DE','Color','y','Marker','+','LineStyle','-','LineWidth',2,...
% 'MarkerEdgeColor','y','MarkerFaceColor',[.49 1 .63],'MarkerSize',2);
% semilogy(1:Max_Iteration,BestCostACO,'DisplayName','ACO','Color','m','LineStyle','-','LineWidth',2);
% semilogy(1:Max_Iteration,SSA_cg_curve,'DisplayName','SSA','Color','c','LineStyle','-','LineWidth',2);
% semilogy(1:Max_Iteration,SCA_cg_curve,'DisplayName','SCA','Color','b','LineStyle','--','LineWidth',2);
% semilogy(1:Max_Iteration,GWO_cg_curve,'DisplayName','GWO','Color','r','LineStyle','--','LineWidth',2);
% semilogy(1:Max_Iteration,CBestChart,'DisplayName','CGSA','Color','m','LineStyle',':','LineWidth',2);



title ('\fontsize{15}\bf Welded Beam Design');
% title ('\fontsize{15}\bf Compression Spring Design');
% title ('\fontsize{15}\bf Pressure Vessel Design');

xlabel('\fontsize{15}\bf Iteration');
ylabel('\fontsize{15}\bf Fitness(Best-so-far)');
legend('\fontsize{12}\bf CPSOGSA');

% legend('\fontsize{12}\bf CPSOGSA','\fontsize{12}\bf GSA','\fontsize{12}\bf PSO','\fontsize{12}\bf BBO',...
% '\fontsize{12}\bf DE','\fontsize{12}\bf ACO','\fontsize{12}\bf GWO','\fontsize{12}\bf SCA','\fontsize{12}\bf SSA','\fontsize{12}\bf CGSA',1);



三、运行结果

【单目标优化求解】基于matlab混沌算法求解单目标问题【含Matlab源码 1410期】_优化算法

四、matlab版本及参考文献

1 matlab版本

2014a

2 参考文献

《智能优化算法及其MATLAB实例(第2版)》包子阳 余继周 杨杉著 电子工业出版社