⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 routsolbytribalga.m

📁 一个用于自然数编码遗传算法的工具包indexGA
💻 M
字号:
%solve the rout problem by tribleGA
clc

%matrix of cost (distance)
load thedist.txt;
global c
c=thedist;

popSize=10;
solSize=16;
MaxGen=50;
tribalSize=10;
tribalHistory=1;

s=[1:solSize];

best=[s 0];

tribal=zeros(tribalSize,solSize+1);

for lup=1:tribalHistory    
    for y=1:tribalSize 
        %make the initialize
        startpop=initialIndexPop(s,popSize);
        %call ga
        [x,endPop,bPop,traceInfo] = indexTribalGA([1 solSize],'routFitness',0,startpop,...
        'termFN',MaxGen,'normGeomSelect',[0.08],'pmxIndexXover',[0,0],'indexMutate',[popSize,0.8]);
        tribal(y,:)=x;
        printPop(y,x);       
    end

    [x,endPop,bPop,traceInfo] = indexTribalGA([1 solSize],'routFitness',0,tribal,...
    'termFN',MaxGen,'normGeomSelect',[0.08],'pmxIndexXover',[0,0],'indexMutate',[0,0]);

    if x(solSize+1) > best(solSize+1)
        best=x;
    end    
    
end


%display the Result

%the Best solution
printPop(MaxGen,best);

[b,r]=solToRouts(best);
%the Best Rount
r

%the Sum of distance
sumDist=1/best(solSize+1);
fprintf(1,'\n\n sumDist = %f',sumDist);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -