当前位置 : 主页 > 编程语言 > python >

【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码

来源:互联网 收集:自由互联 发布时间:2022-06-15
1 简介 基于帝国企鹅算法求解结合AGV分区车间多行布局问题。 2 部分代码 function [fit,result,x0]=aimFcn_1(x,option,data) x0=x; %% 解码获得厂区布局 x1=x(1:data.numUnit+data.maxS-1); x(1:data.numUnit+data.maxS

1 简介

基于帝国企鹅算法求解结合AGV分区车间多行布局问题。 

【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码_d3

【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码_d3_02

【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码_参考文献_03

2 部分代码

function [fit,result,x0]=aimFcn_1(x,option,data)
x0=x;
%% 解码获得厂区布局
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
%% 将各单元中心对齐
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; %区域编号
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; %每个节点的区域
recording0.Zone2=Zone2; %每个区域的节点
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 仿真结果

【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码_matlab代码_04

4 参考文献

[1]马艳楠. 平均最优信息粒子群算法在车辆调度问题中的应用[D]. 桂林电子科技大学, 2013.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。


【车间调度】基于帝国企鹅算法求解考虑AVG分区多行车间调度问题附matlab代码_参考文献_05

网友评论