最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【優(yōu)化選址】基于帝國企鵝算法求解工廠-中心-需求點(diǎn)三級(jí)選址問題附matlab代碼

2022-05-01 00:19 作者:Matlab工程師  | 我要投稿

1 簡介

為了更好的提高物流中心選址的準(zhǔn)確性,體現(xiàn)MATLAB的遺傳算法在帶有時(shí)效性的物流中心選址的問題中的計(jì)算優(yōu)勢(shì)。文中去掉了原有模型中對(duì)區(qū)域連續(xù)性要求的限制條件。利用簡單算例,給出運(yùn)用MATLAB的帝國企鵝算法求解的具體步驟,驗(yàn)證模型和算法的可行性。表明基于MATLAB帝國企鵝算法的優(yōu)化算法是一種較其他算法更為有效的求解帶有時(shí)效性約束的物流中心選址問題的算法。

2 部分代碼

function?[bestY,bestX,recording]=AFO2(x,y,option,data)%% Input% 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%% initializationpe=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 IIIw4=option.w4;%weight of Moving strategy IIIw5=option.w5;%weight of Moving strategy IIIpe=option.pe; % rate to judge Premature convergencegapMin=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 populationy_m=y;x_m=x;%% update recordingrecording.bestFit=y_c;recording.meanFit=mean(y_m);%% main loopiter=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 ? ? ? ?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,:)); ? ? ? ? ? ?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,:)); ? ? ? ? ? ?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,:)); ? ? ? ? ? ?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,:)); ? ? ? ? ? ?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)/maxIteration ? ? ? ? ? ? ? ?% EQ 2-28 ? ? ? ? ? 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fobj(x(i,:)); ? ? ? ? ? ?end ? ? ? ? ? ?if y(i)<y_m(i) ? ? ? ? ? ? ? ?y_m(i)=y(i); ? ? ? ? ? ? ? ?x_m(i,:)=x(i,:); ? ? ? ? ? ? ? ?if y_m(i)<y_c ? ? ? ? ? ? ? ? ? ?y_c=y_m(i); ? ? ? ? ? ? ? ? ? ?x_c=x_m(i,:); ? ? ? ? ? ? ? ? ? ?At_c=At(i,:); ? ? ? ? ? ? ? ?end ? ? ? ? ? ?end ? ? ? ?end ? ?end ? ?% EQ.2-31 ? ?if abs(y_c-recording.bestFit(iter))/abs(recording.bestFit(iter))<=pe ? ? ? ?count=count+1; ? ?else ? ? ? ?count=0; ? ?end ? ?%% ?üD????? ? ?recording.bestFit(1+iter)=y_c; ? ?recording.meanFit(1+iter)=mean(y_m); ? ?% ? ? recording.std(1+iter)=mean(std(x_m)); ? ?% ? ? recording.DC(1+iter)=norm(x_m-repmat(x_c,numAgent,1)); ? ?% ? ? recording.x1(1+iter,:)=x(1,:); ? ?iter=iter+1; ? ?%% ? ?if count>L ? ? ? ?for i=1:numAgent ? ? ? ? ? ?x(i,:)=(ub-lb)*rand+lb; ? ? ? ? ? ?y(i)=fobj(x(i,:)); ? ? ? ? ? ?if y(i)<y_m(i) ? ? ? ? ? ? ? ?y_m(i)=y(i); ? ? ? ? ? ? ? ?x_m(i,:)=x(i,:); ? ? ? ? ? ? ? ?if y_m(i)<y_c ? ? ? ? ? ? ? ? ? ?y_c=y_m(i); ? ? ? ? ? ? ? ? ? ?x_c=x_m(i,:); ? ? ? ? ? ? ? ? ? ?At_c=At(i,:); ? ? ? ? ? ? ? ?end ? ? ? ? ? ?end ? ? ? ?end ? ? ? ?count=0; ? ? ? ?recording.bestFit(1+iter)=y_c; ? ? ? ?recording.meanFit(1+iter)=mean(y_m); ? ? ? ?iter=iter+1; ? ?endendbestY=y_c;bestX=x_c;end%%

3 仿真結(jié)果

4 參考文獻(xiàn)

[1]李衛(wèi)江, 郭曉汾, 張毅,等. 基于Matlab優(yōu)化算法的物流中心選址[J]. 長安大學(xué)學(xué)報(bào)(自然科學(xué)版), 2006, 026(003):76-79.

博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問題可私信交流。

部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。





【優(yōu)化選址】基于帝國企鵝算法求解工廠-中心-需求點(diǎn)三級(jí)選址問題附matlab代碼的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
大悟县| 买车| 格尔木市| 竹北市| 中方县| 新巴尔虎右旗| 祁连县| 清远市| 东安县| 通化县| 正定县| 文昌市| 郁南县| 德安县| 东平县| 垣曲县| 抚松县| 麦盖提县| 勐海县| 屯留县| 静海县| 贵南县| 纳雍县| 黑水县| 罗定市| 鄂托克前旗| 田阳县| 南昌县| 化隆| 遵义市| 乌鲁木齐县| 锦州市| 池州市| 扎兰屯市| 旌德县| 临城县| 彭州市| 宿迁市| 通海县| 中阳县| 永登县|