Gointerface接口声明实现及作用详解
199
2022-09-08
【帝企鹅算法】基于帝企鹅算法求解单目标问题附matlab代码
1 简介
2 部分代码
%% 帝企鹅算法测试函数% AFO on shifted classcial benchmark functionsclc;clear;close all;warning off%%rng('default')%% 测试函数global optionoption.no=1; %选择测试函数option.F=['F',num2str(option.no)];[lb,ub,dim,fobj] = Get_Functions_details(option.F);option.lb=lb;option.ub=ub;option.dim=dim;if length(option.lb)==1 option.lb=ones(1,option.dim)*option.lb; option.ub=ones(1,option.dim)*option.ub;endoption.fobj0=fobj;option.fobj=@fitFCN_BX;option.showIter=0;%% 实验参数option.repeatNum=10; % Number of repetitions of the testoption.numAgent=150; % size of populationoption.maxIteration=200; % maximum number of interationoption.v_lb=-(option.ub-option.lb)/4;option.v_ub=(option.ub-option.lb)/4;option.w2=0.5; %weight of Moving strategy IIIoption.w4=1;%weight of Moving strategy IIIoption.w5=1;%weight of Moving strategy IIIoption.pe=0.01; % rate to judge Premature convergenceoption.gap0=ceil(sqrt(option.maxIteration*2))+1;option.gapMin=5; % min gapoption.dec=2; % dec of gapoption.L=10; % Catastrophedata=[];str_legend=[{'AFO1'},{'AFO2'},{'AFO3'}];for ii=1:option.repeatNum ii rng(ii) %% shift classcial benchmark functions option.RateB1=0.6; %Bound of Shift in x space option.RateB2=0.3; %Bound of Shift in x space temp1=rand(1,option.dim).*(option.RateB1-option.RateB2).*option.ub+option.RateB2.*option.ub; temp2=rand(1,option.dim).*(option.RateB1-option.RateB2).*option.lb+option.RateB2.*option.lb; tempR=rand(1,option.dim); if lb==0 option.XB=temp1; elseif ub==0 option.XB=temp2; else option.XB=zeros(1,option.dim); option.XB(tempR>0.5)=temp1(tempR>0.5); option.XB(tempR<0.5)=temp2(tempR<0.5); end option.XB=-option.XB; %% Initialize population individuals (common to control experiment algorithm) x=ones(option.numAgent,option.dim); y=ones(option.numAgent,1); for i=1:option.numAgent x(i,:)=rand(size(option.lb)).*(option.ub-option.lb)+option.lb; y(i)=option.fobj(x(i,:),option,data); end %% ??????·¨?ó?? % Based on the same population, solve the selected benchmarks functions by using different algorithms bestX=x; rng(ii) tic [bestY(1,:),bestX(1,:),recording(1)]=AFO1(x,y,option,data); tt(ii,1)=toc; rng(ii) tic [bestY(2,:),bestX(2,:),recording(2)]=AFO2(x,y,option,data); tt(ii,2)=toc; rng(ii) tic tt(ii,3)=toc; for i=1:length(recording) recordingCruve{i}(ii,1:option.maxIteration)=recording(i).bestFit(1:option.maxIteration); recordingY(i,ii)=bestY(i,:); endend%% Cruvefigurehold onfor i=1:length(recording) if i>=8 plot(mean(recordingCruve{i}),'LineWidth',2) else plot(mean(recordingCruve{i}),'--','LineWidth',2) endendlegend(str_legend)%% Cruve based logfiguresubplot(122)hold onfor i=1:length(recording) if i >=8 plot(log(mean(recordingCruve{i})),'LineWidth',2) else plot(log(mean(recordingCruve{i})),'-.','LineWidth',2) endendlegend(str_legend)%% ??×??á?? Aggregate resultsmeanY=mean(recordingY');stdY=std(recordingY');minY=min(recordingY');maxY=max(recordingY');maeY=mean(abs(recordingY'-meanY));runningT=mean(tt(2:end,:));%% ???????????? Plotting function imagesoption.F=['F',num2str(option.no)];subplot(121)func_plot(option.F)
3 仿真结果
4 参考文献
[1]唐菁敏等. "一种基于帝企鹅差分算法的WSN覆盖优化." 云南大学学报:自然科学版 43.1(2021):6.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~