相关疑难解决方法(0)

GA中的排名选择?

我已经实施Roulette wheel selectionGA.

   TotalFitness=sum(Fitness);
    ProbSelection=zeros(PopLength,1);
    CumProb=zeros(PopLength,1);

    for i=1:PopLength
        ProbSelection(i)=Fitness(i)/TotalFitness;
        if i==1
            CumProb(i)=ProbSelection(i);
        else
            CumProb(i)=CumProb(i-1)+ProbSelection(i);
        end
    end

    SelectInd=rand(PopLength,1);

    for i=1:PopLength
        flag=0;
        for j=1:PopLength
            if(CumProb(j)<SelectInd(i) && CumProb(j+1)>=SelectInd(i))
                SelectedPop(i,1:IndLength)=CurrentPop(j+1,1:IndLength);
                flag=1;
                break;
            end
        end
        if(flag==0)
            SelectedPop(i,1:IndLength)=CurrentPop(1,1:IndLength);
        end
    end
Run Code Online (Sandbox Code Playgroud)

现在我是想实现rank selectionGA.我了解到:

  • 排名选择首先对人群进行排名,然后每个染色体从该排名中获得适应性.

  • 最差的将是健身1,第二差2等等,最好的将具有适应度N(人口中的染色体数量).

我看到了这些link1link2,我理解的是:

  1. 首先,我将对人口的健身价值进行排序.

  2. 然后,如果人口数量是10,那么我将给予人口选择的概率,如0.1,0.2,0.3,...,1.0.

  3. 然后我将计算累积健身像轮盘赌轮.
  4. 接下来的步骤与轮盘赌轮相同.

我的实施:

  NewFitness=sort(Fitness);
    NewPop=round(rand(PopLength,IndLength));

    for i=1:PopLength
        for j=1:PopLength
            if(NewFitness(i)==Fitness(j))
                NewPop(i,1:IndLength)=CurrentPop(j,1:IndLength);
                break;
            end
        end
    end
    CurrentPop=NewPop;

    ProbSelection=zeros(PopLength,1);
    CumProb=zeros(PopLength,1);

    for i=1:PopLength
        ProbSelection(i)=i/PopLength;
        if i==1
            CumProb(i)=ProbSelection(i);
        else
            CumProb(i)=CumProb(i-1)+ProbSelection(i);
        end …
Run Code Online (Sandbox Code Playgroud)

matlab selection genetic-algorithm

3
推荐指数
1
解决办法
1657
查看次数

标签 统计

genetic-algorithm ×1

matlab ×1

selection ×1