资源简介

一个关于物流配置(车辆调度)的基于遗传算法实现的matlab程序,注释详细,功能完善。

资源截图

代码片段和文件信息

function bestdistance(distTxnkmcsv)
f=0;
M=100;
for m=1:nk
        temp1=x((m-1)*mc+1:m*mc);
        index=find(temp1==1);
        kk=size(index2);
        [ffxx]=zuhe(indexkk);
        for t=1:kk
            sprintf(‘%d  ‘index(xx(t)));
        end
        f=f+ff;
        sprintf(‘%d‘f);
end

 sprintf(‘%d‘f);

    function [mindisxx]=zuhe(indexn)
        mindis=1000000;
        x=1:n;
        xx=zeros(1n);
        temp=zeros(1n);
        function track(kn)
            if k>=n
                f=0;
                p=0;
                for i=1:n
                   if i==1
                    temp(i)=dist(1index(x(i))+1)/v;
                     f=f+dist(1index(x(i))+1);
                   else
                    temp(i)=temp(i-1)+dist(index(x(i-1))+1index(x(i))+1)/v+s(index(x(i-1)));
                    f=f+dist(index(x(i-1))+1index(x(i))+1);
                   end
                    p=p+p_f(temp(i)index(x(i)));
                end
                f=f+dist(1index(x(n)));
                if f                    mindis=f;
                    xx=x;
                end 
                f=f+p;
                return;

            else
                for j=k:n
                    temp1=x(j);
                    x(j)=x(k);
                    x(k)=temp1;
                    track(k+1n);
                    temp1=x(j);
                    x(j)=x(k);
                    x(k)=temp1;
                end
            end
        end
        
        track(1n);

    end
       
       
       
       
    function p=p_f(tk)
        x0=T(1k);
        x1=T(2k);
        c=0.5*(x1-x0);
        a1=x0-c;
        b1=x1+c;

        if t<=a1||t>=b1
            p=M;
        else if t>=x0&&t<=x1
                p=0;
            else if t>a1&&t                    p=M*(x0-t)/c;
                else
                    p=M*(t-x1)/c;     
                end
            end
            
        end
    end
    end
   

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

     文件        628  2013-08-29 09:50  Code.m

     文件       1817  2013-08-29 09:50  Cross.asv

     文件       1811  2013-08-29 09:50  Cross.m

     文件       2048  2013-08-29 12:35  fun.asv

     文件       2046  2013-08-29 12:54  fun.m

     文件       2855  2013-08-29 09:50  Genetic.asv

     文件       2941  2013-08-29 09:50  Genetic.m

     文件        167  2013-08-29 11:30  main.asv

     文件        172  2013-08-29 11:48  main.m

     文件       1402  2013-08-29 09:50  Mutation.asv

     文件       1425  2013-08-29 09:50  Mutation.m

     文件        911  2013-08-29 09:50  Select.asv

     文件        950  2013-08-29 09:50  Select.m

     文件        510  2013-08-29 09:50  test.m

     文件        795  2013-08-29 09:50  all.mat

     文件       1926  2013-08-29 11:30  bestdistance.asv

     文件       2047  2013-08-29 13:04  bestdistance.m

     文件        604  2013-08-29 09:50  Code.asv

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

                25055                    18


评论

共有 条评论