引力搜索算法(Gravitational Search Algorithm,GSA)是Esmat Rashedi等人在2009年提出的一种随机性启发式搜索算法,这种算法的灵感来自于牛顿的万有引力定律与运动定律:1.任意两个质点有通过连心线方向上的力相互吸引,该引力大小与它们质量的乘积成正比与它们距离的平方成反比。2.力使物体获得加速度。
在GSA中,质点被抽象成解空间的一个解,解之间存在一个相互吸引力,这个吸引力由解的质量与两个解之间的距离确定,质点的质量被抽象成解的评估函数值。在解空间中,每个解由其他解对其的吸引力获得加速度,质量更大(评估函数值更优)所提供的加速度更大,从而使解向更优解的方向移动。
% Chaotic GSA for Mechanical Engineering Design Problems
%
% Main paper: Rather, S. and Bala, P. (2020), "Swarm-based chaotic gravitational search algorithm for solving mechanical engineering design problems",
% World Journal of Engineering, Vol. 17 No. 1, pp. 97-114. https://doi.org/10.1108/WJE-09-2019-0254
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);
Rather, S. and Bala, P. (2020), "Swarm-based chaotic gravitational search algorithm for solving mechanical engineering design problems", World Journal of Engineering, Vol. 17 No. 1, pp. 97-114. DOI: https://doi.org/10.1108/WJE-09-2019-0254