首页 > 编程语言 > 详细

【优化求解】基于混沌引力搜索算法求解机械工程设计问题matlab源码

时间:2021-09-05 15:56:11      阅读:33      评论:0      收藏:0      [点我收藏+]

?

 一、 引力搜索算法

 引力搜索算法(Gravitational Search Algorithm,GSA)是Esmat Rashedi等人在2009年提出的一种随机性启发式搜索算法,这种算法的灵感来自于牛顿的万有引力定律与运动定律:1.任意两个质点有通过连心线方向上的力相互吸引,该引力大小与它们质量的乘积成正比与它们距离的平方成反比。2.力使物体获得加速度。

在GSA中,质点被抽象成解空间的一个解,解之间存在一个相互吸引力,这个吸引力由解的质量与两个解之间的距离确定,质点的质量被抽象成解的评估函数值。在解空间中,每个解由其他解对其的吸引力获得加速度,质量更大(评估函数值更优)所提供的加速度更大,从而使解向更优解的方向移动。

看到这里,有些小伙伴会以为GSA是个与PSO差不多的算法,是的,GSA与PSO的外层框架是一致的,但是,它们最关键的粒子移动策略却是不同的:

1.在PSO中,粒子的移动只使用两个最佳位置pbest和gbest。但是在GSA中,智能体的方向是根据所有其他智能体或部分较优的智能体获得的总力来计算的。
2.PSO使用一种内存来更新速度(由于pbest和gbest)。然而,GSA是无内存的,只有智能体的当前位置在更新过程中起作用。
3.在PSO中,更新不考虑解之间的距离,而在GSA中,力与解之间的距离成反比。
4.PSO模拟了鸟类的社会行为,而GSA的灵感来自于物理现象。

GSA的主要过程如下:

1. 确定搜索空间。
2. 随机初始化个体种群。
3. 对种群进行适应度评价。
4. 更新引力常量G,更新种群中最好的个体 best与最差的个体worst,更新个体的质量。
5. 计算每个个体在不同方向上的总引力。
6. 计算个体的加速度,基于此更新个体的速度。
7. 根据速度更新个体在解空间中的位置。
8. 重复步骤3-7直到达到停止标准。

算法流程:
技术分享图片技术分享图片?

 

二、混沌引力搜索算法


    Purpose The purpose of this paper is to investigate the performance of chaotic gravitational search algorithm (CGSA) in solving mechanical engineering design frameworks including welded beam design (WBD), compression spring design (CSD) and pressure vessel design (PVD). Design/methodology/approach In this study, ten chaotic maps were combined with gravitational constant to increase the exploitation power of gravitational search algorithm (GSA). Also, CGSA has been used for maintaining the adaptive capability of gravitational constant. Furthermore, chaotic maps were used for overcoming premature convergence and stagnation in local minima problems of standard GSA. Findings The chaotic maps have shown efficient performance for WBD and PVD problems. Further, they have depicted competitive results for CSD framework.

 

三、部分代码


                            
%              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

 技术分享图片技术分享图片?

 

?

【优化求解】基于混沌引力搜索算法求解机械工程设计问题matlab源码

原文:https://www.cnblogs.com/matlabxiao/p/15225519.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!