【車(chē)間調(diào)度】基于帝國(guó)企鵝算法求解考慮AVG分區(qū)多行車(chē)間調(diào)度問(wèn)題附matlab代碼
1 簡(jiǎn)介
基于帝國(guó)企鵝算法求解結(jié)合AGV分區(qū)車(chē)間多行布局問(wèn)題。?



2 部分代碼
function [fit,result,x0]=aimFcn_1(x,option,data)
x0=x;
%% 解碼獲得廠區(qū)布局
x1=x(1:data.numUnit+data.maxS-1);
x(1:data.numUnit+data.maxS-1)=[];
X=x;
map=zeros(data.mapSize./data.accuracy);
[~,S]=sort(x1);
recording{1}=[];
len2=data.mapSize(2)+data.d(2);
len1=data.mapSize(1);
recording0.noUnit=S;
recording1=[];
jishu=0;
for i=1:length(S)
? ?no=S(i);
? ?if S(i)<=data.numUnit
? ? ? ?sizeUnit=data.Unit(no,1:2);
? ? ? ?type=1;
? ? ? ?jishu=jishu+1;
? ?else
? ? ? ?if jishu<data.minUnit
? ? ? ? ? ?continue;
? ? ? ?end
? ? ? ?sizeUnit=[data.r*2,data.r*2];
? ? ? ?type=2;
? ? ? ?jishu=0;
? ?end
? ?if ismember(no,[8,9]) && len1~=data.mapSize(1)
? ? ? ?len1=data.mapSize(1);
? ? ? ?len2=len2-max(recording{end}(:,5))-data.d(2);
? ? ? ?recording=[recording;{[]}];
? ? ? ?recording{end}=[recording{end};no,len1,len2,sizeUnit,type];
? ? ? ?recording1=[recording1;no,len1,len2,sizeUnit,type];
? ? ? ?len1=len1-(sizeUnit(1)+data.d(1));
? ? ? ?continue;
? ?end
? ?if ~isempty(recording1)
? ? ? ?position=find(recording1(:,1)==1 | recording1(:,1)==2);
? ? ? ?if ~isempty(position) && ismember(no,[1,2])
? ? ? ? ? ?len0=recording1(position,2);
? ? ? ? ? ?if len1<len0
? ? ? ? ? ? ? ?len1=len0;
? ? ? ? ? ? ? ?len2=len2-max(recording{end}(:,5))-data.d(2);
? ? ? ? ? ? ? ?recording=[recording;{[]}];
? ? ? ? ? ? ? ?recording{end}=[recording{end};no,len1,len2,sizeUnit,type];
? ? ? ? ? ? ? ?recording1=[recording1;no,len1,len2,sizeUnit,type];
? ? ? ? ? ? ? ?len1=len1-(sizeUnit(1)+data.d(1));
? ? ? ? ? ?else
? ? ? ? ? ? ? ?len1=len0;
? ? ? ? ? ? ? ?recording{end}=[recording{end};no,len1,len2,sizeUnit,type];
? ? ? ? ? ? ? ?recording1=[recording1;no,len1,len2,sizeUnit,type];
? ? ? ? ? ? ? ?len1=len1-(sizeUnit(1)+data.d(1));
? ? ? ? ? ?end
? ? ? ? ? ?continue;
? ? ? ?end
? ?end
? ?if len1-(sizeUnit(1)+data.d(1))>0
? ? ? ?recording{end}=[recording{end};no,len1,len2,sizeUnit,type];
? ? ? ?recording1=[recording1;no,len1,len2,sizeUnit,type];
? ? ? ?len1=len1-(sizeUnit(1)+data.d(1));
? ?else
? ? ? ?len1=data.mapSize(1);
? ? ? ?len2=len2-max(recording{end}(:,5))-data.d(2);
? ? ? ?recording=[recording;{[]}];
? ? ? ?recording1=[recording1;no,len1,len2,sizeUnit,type];
? ? ? ?recording{end}=[recording{end};no,len1,len2,sizeUnit,type];
? ? ? ?len1=len1-(sizeUnit(1)+data.d(1));
? ?end
end
%% 將各單元中心對(duì)齊
recording0.unit=[];
jishu1=1;
for i=1:length(recording)
? ?if rem(i,2)==0
? ? ? ?index=length(recording{i}(:,1)):-1:1;
? ? ? ?recording{i}=recording{i}(index,:);
? ?end
? ?maxY=max(recording{i}(:,5));
? ?meanY=mean(recording{i}(:,5)); ? ?
? ?for j=1:length(recording{i}(:,1))
% ? ? ? ? if recording{i}(j,1)<=data.numUnit
% ? ? ? ? ? ? no=recording{i}(j,1);
% ? ? ? ? ? ? unitType=recording{i}(j,6);
% ? ? ? ? else
% ? ? ? ? ? ? no=recording{i}(j,1)-data.numUnit;
% ? ? ? ? ? ? unitType=0;
% ? ? ? ? end
? ? ? ?no=recording{i}(j,1);
? ? ? ?unitType=recording{i}(j,6);
? ? ? ?x=data.mapSize(1)-recording{i}(j,2);
? ? ? ?y=recording{i}(j,3)-data.d(2);
? ? ? ?unitX=recording{i}(j,4);
? ? ? ?unitY=recording{i}(j,5);
? ? ? ?recording{i}(j,7)=x;
? ? ? ?recording{i}(j,8)=y-maxY/2+unitY/2;
? ? ? ?y=recording{i}(j,8);
? ? ? ?if no>data.numUnit
? ? ? ? ? ?recording{i}(j,1)=jishu1;
? ? ? ? ? ?recording{i}(j,6)=2;
? ? ? ? ? ?jishu1=jishu1+1;
? ? ? ?end
? ?end
? ?recording0.unit=[recording0.unit;[recording{i},ones(length(recording{i}(:,1)),1)*i]];
end
Zone=[];
index=1;
jishu=1; ?%單元指針
jishu1=1; %區(qū)域編號(hào)
for i=1:length(recording0.unit(:,1))
? ?if recording0.unit(i,6)==2
? ? ? ?temp={recording0.unit((index:i-1),1)};
? ? ? ?if ~isempty(temp{1})
? ? ? ? ? ?Zone=[Zone;jishu,jishu+length(temp{1})-1];
? ? ? ? ? ?index1=temp{1};
? ? ? ? ? ?Zone1(index1)=jishu1;
? ? ? ? ? ?Zone2{jishu1}=index1;
? ? ? ? ? ?jishu1=jishu1+1;
? ? ? ? ? ?jishu=jishu+length(temp{1});
? ? ? ?end
? ? ? ?index=i+1;
? ?end
end
temp={recording0.unit(index:end,1)};
if ~isempty(temp{1})
? ?Zone=[Zone;jishu,jishu+length(temp{1})-1];
? ?index1=temp{1};
? ?Zone1(index1)=jishu1;
? ?Zone2{jishu1}=index1;
end
position1=find(recording0.unit(:,6)==2);
if length(position1)>length(Zone(:,1))-1
? ?recording0.unit(position1(length(Zone(:,1)):end),:)=[];
end
position1=find(recording0.unit(:,6)==2);
position2=find(recording0.unit(:,6)==1);
recording0.unit=[recording0.unit(position2,:);recording0.unit(position1,:)];
recording0.noUnit=recording0.unit(:,1);
recording0.Zone=Zone;
recording0.Zone1=Zone1; %每個(gè)節(jié)點(diǎn)的區(qū)域
recording0.Zone2=Zone2; %每個(gè)區(qū)域的節(jié)點(diǎn)
end
if max(DQ)>data.maxDQ
? ?punishiment=max(DQ)-data.maxDQ;
else
? ?punishiment=0;
end
position=find(recording0.unit(:,8)-recording0.unit(:,5)<0);
punishiment=punishiment+1000*length(position);
if max(recording0.Zone1)==1
? ?punishiment=punishiment+1000000;
end
for i=1:max(recording0.Zone1)
? ?position=find(recording0.Zone1==i);
? ?if length( position)<data.minUnit
? ? ? ?punishiment=punishiment+1000000;
? ?end
end
numAGV=max(recording0.Zone1);
%%
minX=min(recording0.unit(:,7));
maxX=max(recording0.unit(:,7)+recording0.unit(:,4));
maxY=max(recording0.unit(:,8));
minY=min(recording0.unit(:,8)-recording0.unit(:,5));
fit1=sum(sum(DQ))/sum(sum(DQmax));
fit2=(maxX-minX)*(maxY-minY);
fit3=numAGV;
fit=sum(data.w.*[fit1,fit2/data.LWmax,fit3/data.maxAGV])+punishiment*10;
if nargout>1
? ?result.fit=fit;
? ?result.recording0=recording0;
? ?result.DQ=DQ;
end
end
3 仿真結(jié)果

4 參考文獻(xiàn)
[1]馬艷楠. 平均最優(yōu)信息粒子群算法在車(chē)輛調(diào)度問(wèn)題中的應(yīng)用[D]. 桂林電子科技大學(xué), 2013.
博主簡(jiǎn)介:擅長(zhǎng)智能優(yōu)化算法、神經(jīng)網(wǎng)絡(luò)預(yù)測(cè)、信號(hào)處理、元胞自動(dòng)機(jī)、圖像處理、路徑規(guī)劃、無(wú)人機(jī)等多種領(lǐng)域的Matlab仿真,相關(guān)matlab代碼問(wèn)題可私信交流。
部分理論引用網(wǎng)絡(luò)文獻(xiàn),若有侵權(quán)聯(lián)系博主刪除。
