function [bestY,bestX,recording]=AFO2(x,y,option,data)
% Update log.
% 1. 2021.1.1
% Version 1.0
% All experiments of the paper are run based on this version, except for the experiments of running time.
% 2. 2021.1.7
% Version 1.1
% Disadvantages of version 1.0
% (1) Too slow
% (2) The total number of evaluations is T*(N+m) after the catastrophe strategy is triggered, and m is the number of times the catastrophe strategy is triggered.
% However, this problem will not affect the results of this experiment because the maximum number of iterations of the experiment is 50, and the catastrophe strategy will basically not be triggered.
% The runtime experiments of the paper are based on this version
% Updated content.
% (1) Optimization based on the advantages of MATLAB. The problem of too slow speed is solved.
% The core reason for the excessive slowness was that strategy 2 did not use matrix operations in version 1.0.
% Note: In order to use matrix operations, this version updates all individuals of the population when using the third strategy, but calculates the fitness value only for those individuals that are eligible. The total number of evaluations is still T*N.
% (2) After using the catastrophe strategy, the current iteration number +1,the total evaluation number reverts to T*N
%% Authority
% x----positions of initialized populaiton
% y----fitnesses of initialized populaiton
% option-----parameters set of the algorithm
% data------Pre-defined parameters
% This parameter is used for solving complex problems is passing case data
%% outPut
% bestY ----fitness of best individual
% bestX ----position of best individual
% recording ---- somme data was recorded in this variable
%% initialization
pe=option.pe;
L=option.L;
gap0=option.gap0;
gap=gap0;
dim=option.dim;
maxIteration=option.maxIteration;
recording.bestFit=zeros(maxIteration+1,1);
recording.meanFit=zeros(maxIteration+1,1);
numAgent=option.numAgent;
At=randn(numAgent,dim);
w2=option.w2; %weight of Moving strategy III
w4=option.w4;%weight of Moving strategy III
w5=option.w5;%weight of Moving strategy III
pe=option.pe; % rate to judge Premature convergence
gapMin=option.gapMin;
dec=option.dec;
ub=option.ub;
lb=option.lb;
v_lb=option.v_lb;
v_ub=option.v_ub;
fobj=option.fobj;
count=1;
%% center of population
[y_c,position]=min(y);
x_c=x(position(1),:);
At_c=At(position(1),:);
%% memory of population
y_m=y;
x_m=x;
%% update recording
recording.bestFit(1)=y_c;
recording.meanFit(1)=mean(y_m);
%% main loop
iter=1;
while iter<=maxIteration
%Dmp(['AFO,iter:',num2str(iter),',minFit:',num2str(y_c)])
%% Moving Strategy I for center of population
if rem(iter, gap)==0 && dim<option.numAgent
c0=exp(-30*(iter-gap0)/maxIteration); % EQ.2-11
Dx=ones(1,dim);
Dx=c0*Dx/norm(Dx)*norm(v_ub-v_lb)/2; %EQ.2-12 %+¡÷x
Dx1=-Dx; %-¡÷x
% +¡÷x
for j=1:dim
tempX(j,:)=x_c;
tempX(j,j)=x_c(1,j)+Dx(j);
if tempX(j,j)>ub(j)
tempX(j,j)=ub(j);
Dx(1,j)=tempX(j,j)-x_c(1,j);
end
if tempX(j,j)<lb(j)
tempX(j,j)=lb(j);
Dx(1,j)=tempX(j,j)-x_c(1,j);
end
tempY(j,:)=fobj(tempX(j,:),option,data);
if tempY(j)*y_c<0
g0(1,j)=(log(tempY(j))-log(y_c))./Dx(j); %EQ.2-18
else
temp=[tempY(j),y_c];
temp=temp+min(temp)+eps;
g0(1,j)=(log(temp(1))-log(temp(2)))./Dx(j);
end
g0(isnan(g0))=0;
end
G0=-g0(1,:)*norm(v_ub-v_lb)/2/norm(g0(1,:)); % part of Eq 2-18
G0(1,G0(1,:)>v_ub)=G0(1,G0(1,:)>v_ub)/max(G0(1,G0(1,:)>v_ub))*max(v_ub(G0(1,:)>v_ub));
G0(1,G0(1,:)<v_lb)=G0(1,G0(1,:)<v_lb)/min(G0(1,G0(1,:)<v_lb))*min(v_lb(G0(1,:)<v_lb));
G01=G0;
% -¡÷x
Dx=Dx1;
for j=1:dim
tempX(j+dim,:)=x_c;
tempX(j+dim,j)=x_c(1,j)+Dx(j);
if tempX(j+dim,j)>ub(j)
tempX(j+dim,j)=ub(j);
Dx(1,j)=tempX(j,j)-x_c(1,j);
end
if tempX(j+dim,j)<lb(j)
tempX(j+dim,j)=lb(j);
Dx(1,j)=tempX(j,j)-x_c(1,j);
end
tempY(j+dim,:)=fobj(tempX(j,:),option,data);
if tempY(j)*y_c<0
g0(1,j)=(log(tempY(j))-log(y_c))./Dx(j); %EQ.2-18
else
temp=[tempY(j),y_c];
temp=temp+min(temp)+eps;
g0(1,j)=(log(temp(1))-log(temp(2)))./Dx(j);
end
g0(isnan(g0))=0;
end
G0=-g0(1,:)*norm(v_ub-v_lb)/2/norm(g0(1,:)); % part of Eq 2-18
G0(1,G0(1,:)>v_ub)=G0(1,G0(1,:)>v_ub)/max(G0(1,G0(1,:)>v_ub))*max(v_ub(G0(1,:)>v_ub));
G0(1,G0(1,:)<v_lb)=G0(1,G0(1,:)<v_lb)/min(G0(1,G0(1,:)<v_lb))*min(v_lb(G0(1,:)<v_lb));
G02=G0;
G0=G01+G02; % part of Eq 2-18
G0(isnan(G0))=0;
if sum(G0)==0
N=numAgent-2*dim;
Dm=mean(x-repmat(x_c,numAgent,1));
Dm=norm(Dm); %EQ.2-22
if Dm<norm(v_ub-v_lb)/20*iter/maxIteration
Dm=norm(v_ub-v_lb);
end
for j=2*dim+(1:N)
G0=randn(1,dim);
tempX(j,:)=x(i,:)+5*rand*G0./norm(G0)*Dm; %EQ.2-21
tempX(j,tempX(j,:)<lb)=lb(tempX(j,:)<lb);
tempX(j,tempX(j,:)>ub)=ub(tempX(j,:)>ub);
tempY(j,:)=fobj(tempX(j,:),option,data);
end
else
N=numAgent-2*dim;
r1=exp(-10*(0:N-1)/(N-1));
unitG=norm(Dx)/norm(G0); %EQ.2-19
if unitG~=1
r2=1:-(1-unitG)/(N-1):unitG;
a=r1.*r2; %EQ.2-17
else
a=r1;
end
for j=2*dim+(1:N)
tempX(j,:)=x_c+G0*a(j-2*dim); %EQ,2-20
tempX(j,tempX(j,:)<lb)=lb(tempX(j,:)<lb);
tempX(j,tempX(j,:)>ub)=ub(tempX(j,:)>ub);
tempY(j,:)=fobj(tempX(j,:),option,data);
end
end
[minY,no]=min(tempY);
if minY<y_c
y_c=tempY(no);
x_c=tempX(no,:);
end
if rand>(no-dim*2)/(numAgent-dim*2)*(maxIteration-iter)/maxIteration
gap=max(gapMin,gap-dec); %EQ.2-15
end
else
R1=rand(numAgent,dim);
R2=rand(numAgent,dim);
R3=rand(numAgent,dim);
Rn=rand(numAgent,dim);
indexR1=ceil(rand(numAgent,dim)*numAgent);
indexR2=ceil(rand(numAgent,dim)*numAgent);
std0=exp(-20*iter/maxIteration)*(v_ub-v_lb)/2;
std1=std(x_m);
% In order to use matrix operations, all individuals of the population are updated.
% Although more individuals were updated, the running time of the algorithm dropped tremendously.
% This is because MATLAB is extremely good at matrix operations.
% If you want to rewrite this code in another language, we suggest you refer to AFO1.
% AFO2 is optimized for MATLAB and may not be suitable for your language.
for j=1:dim
x_m1(:,j)=x_m(indexR1(:,j),j);
x_m2(:,j)=x_m(indexR2(:,j),j);
y_m1(:,j)=y_m(indexR1(:,j));
y_m2(:,j)=y_m(indexR2(:,j));
AI(:,j)=R1(:,j).*sign(y_m1(:,j)-y_m2(:,j)).*(x_m1(:,j)-x_m2(:,j));
if std1(j)<=std0(j)
position=find(AI(:,j)==0);
AI(position,j)=Rn(position,j)*(v_ub(j)-v_lb(j))/2;
position=find(AI(:,j)~=0);
AI(position,j)=R2(:,j).*sign(y_m1(:,j)-y_m2(:,j)).*sign(x_m1(:,j)-x_m2(:,j))*(v_ub(j)-v_lb(j))/2;
end
end
for i=1:numAgent
p =tanh(abs(y(i)-y_c)); %EQ.2-30
if rand<p*(maxIteration-iter)/max
没有合适的资源?快使用搜索试试~ 我知道了~
帝国企鹅优化算法求解冷链配送物流车辆调度优化研究附matlab代码
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共20个文件
png:8个
m:8个
asv:2个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
温馨提示
1.版本:matlab2019a,不会运行可私信 2.领域:【VRP问题】 3.内容:基于帝国企鹅优化算法求解冷链配送物流车辆调度优化研究附matlab代码 4.适合人群:本科,硕士等教研学习使用
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/XLSX.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
共 20 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- zzmak2024-04-23这个资源值得下载,资源内容详细全面,与描述一致,受益匪浅。
- cgloviking9062024-04-15感谢大佬分享的资源给了我灵感,果断支持!感谢分享~
![avatar](https://profile-avatar.csdnimg.cn/0952dabfe4084a058a29f6b3884c6064_qq_59747472.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
天天Matlab科研工作室
- 粉丝: 3w+
- 资源: 7248
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)