资源简介

作业车间调度 调度 恶化时间的调度 matlab源码 甘特图 演示 matlab 入门

资源截图

代码片段和文件信息

function [FitY1pY2pY3p]=DeteFitness(XHTDeteriorationXstr)
[mn]=size(X)
Y1p=zeros(mn);
Y2p=zeros(mn);
Y3p=zeros(mn);
Q1=zeros(mn);
Q2=zeros(mn);
Kt=zeros(mn);
J=zeros(1m*n);
K=zeros(1n);
%测试用,遗传算法注释掉以下
%for k=1:N %初始化
%a=repmat(1:m1n)
%pos=a(randperm(length(a)))        %记录行(job)
%farm{k}=pos;
%Xstr=farm{k};
%end

%遗传算法注释掉以上
Nu=zeros(1m)
Q1(Xstr(1)1)=0;
Q2(Xstr(1)1)=H(Xstr(1)1)*T(Xstr(1)1);       %第一个工序
Nu(Xstr(1))=1;
for i=2:m*n                       %记录基因查找顺序数
    Nu(Xstr(i))= Nu(Xstr(i))+1;      %记录列(工序)
    if Nu(Xstr(i))==1 %对于第i个job的第1个工序
        Kt=Nu;
        j=i-1;
      while j~=0&X(Xstr(j)Kt(Xstr(j)))~=X(Xstr(i)1)%判断第i位基因前有没有前序工序
        Kt(Xstr(j))=Kt(Xstr(j))-1;
        j=j-1;
       end
     if j~=0 %如果有,则第i位基因的开始时间是此工序的结束时间,结束时间为开始时间+操作时间
     Q1(Xstr(i)1)=Q2(Xstr(j)Kt(Xstr(j)));
     Q2(Xstr(i)1)=Q1(Xstr(i)1)+H(Xstr(i)1)*(Deterioration(Xstr(i)Nu(Xstr(i)))*Q1(Xstr(i)1)+T(Xstr(i)1));
     else %如果没有,那么第i位基因的开始时间为0结束时间为开始时间+操作时间
     Q1(Xstr(i)1)=0;
     Q2(Xstr(i)1)=Q1(Xstr(i)1)+H(Xstr(i)1)*T(Xstr(i)1);
    end
    else %如果不是第i个job的第一个工序
      if Nu(Xstr(i))>=2
          
           T1=Q2(Xstr(i)Nu(Xstr(i))-1);%记录工件i的上一个工序的结束时间
          
          Kt=Nu;
          Kt(Xstr(i))=Kt(Xstr(i))-1;
         j=i-1;
        while j~=0&X(Xstr(j)Kt(Xstr(j)))~=X(Xstr(i)Nu(Xstr(i)))%寻找第i位基因前的所有工序,查找到和它同一台机器上的前一个工序
           Kt(Xstr(j))=Kt(Xstr(j))-1;
            j=j-1;
        end
        if j~=0 %如果有,记录此工序的结束时间
           T2=Q2(Xstr(j)Kt(Xstr(j)));
           Tmax=[T1T2];
           Q1(Xstr(i)Nu(Xstr(i)))=max(Tmax);
           Q2(Xstr(i)Nu(Xstr(i)))=Q1(Xstr(i)Nu(Xstr(i)))+H(Xstr(i)Nu(Xstr(i)))*(Deterioration(Xstr(i)Nu(Xstr(i)))*Q1(Xstr(i)Nu(Xstr(i)))+T(Xstr(i)Nu(Xstr(i))));
       else
     Q1(Xstr(i)Nu(Xstr(i)))=T1;
     Q2(Xstr(i)Nu(Xstr(i)))=Q1(Xstr(i)Nu(Xstr(i)))+H(Xstr(i)Nu(Xstr(i)))*(Deterioration(Xstr(i)Nu(Xstr(i)))*Q1(Xstr(i)Nu(Xstr(i)))+T(Xstr(i)Nu(Xstr(i))));
    end
    end
    end
  
Y1p=Q1;
Y2p=Q2;
Y3p=X;
end
Fit=max(Y2p(:n));

%for i=1:m
%    for j=1:n
%                   mPoint1=Y1p(ij);
%                   mPoint2=Y2p(ij);
%                   mText=m+1-i;
%                   PlotRec(mPoint1mPoint2mText);
%                   Word=num2str(Y3p(ij));
%                   hold on
%                   x1=mPoint1;
%                   y1=mText-1;
%                   x2=mPoint2;
%                   y2=mText-1;
%                   x3=mPoint2;
%                   y3=mText;
%                   x4=mPoint1;
%                   y4=mText;
%                   fill([x1x2x3x4][y1y2y3y4][10.51]);
%                   text(0.5*mPoint1+0.5*mPoint2mText-0.5Word);
%               end
%           end
%       end
%         function PlotRec(mPoint1mPoint2mText)
%            vPoint=zeros(42);
%            vPoint(1:)=[mPoint1mText-1];
%            vPoint(2:)=[mPoint2mText-1];
%           

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1404  2012-05-22 21:33  工序数不等于机器数的遗传算法.txt

     文件       3611  2012-05-15 08:43  DeteFitness.m

     文件       3566  2012-05-21 19:21  DeteGAM.m

     文件       3583  2012-05-15 08:46  Detemakespan.m

     文件       3027  2012-04-28 17:21  Fitness.m

     文件       2934  2012-04-28 14:37  GAM.m

     文件        817  2012-05-24 15:55  Detestartga.m

     文件       2409  2012-04-21 09:45  Jspgaa.m

     文件       2839  2012-04-28 15:30  makespan.m

     文件        249  2012-04-28 01:48  MutationSwap.m

     文件       1419  2012-04-24 16:20  Repair.m

     文件        234  2012-04-28 15:42  startga.m

----------- ---------  ---------- -----  ----

                26092                    12


评论

共有 条评论