Biogeography-based optimization 生物地理学优化算法(一):代码理解-物种数概率计算的实现

近期在研究生物地理学优化算法(Biogeography-based optimization ) 时发现 在计算物种数概率时,原文章给出的公式与作者给出的源码形式不一样,一度以为是代码出了问题,最后发现是因为代码中对种群的排序是按照 从最好到最差 的顺序排序。

原论文下载:https://download.csdn.net/download/sunshinefcx/11111947

源码下载:https://download.csdn.net/download/sunshinefcx/11111950

 

代码中的栖息地排序如下形式【population(i) 表示第 i  个栖息地】:

for j = 1 : length(Population)   % 其中 j 代表的是栖息地
    % Population(1)  是适宜度最高的栖息地,相对应的这个栖息地的物种数量最多
    % 随着 j 的增加,物种数量是减少的,栖息地的 适宜度 HSI 也是降低的
end

下面咱们来看,原论文及源码中分别是怎么实现的

原论文:

首先看原文我们可以知道,原文章中给出的 某栖息地在 (t+△t) 时刻有 S 种物种的概率 Ps 的计算公式如下:

在(t+△t)时刻此 栖息地 中有 S 种物种的情况主要有下面三种:

1、在 △t 时间内,此栖息地没有 迁入 迁出

2、在 t 时刻此栖息地有S-1种物种,在 △t 时间内,迁入一种,以致于在 (t+△t) 时刻有 S 种

3、在 t 时刻此栖息地有S+1种物种,在 △t 时间内,迁出一种,以致于在 (t+△t) 时刻有 S 种

 公式(1)  对  △t 求导之后,得到下面的式(2)

下面来看,源码中是怎么实现的

源代码:

 [lambda, mu] = GetLambdaMu(Population, I, E, P);   %  I表示最大迁入率 E最大迁出率 P最大物种数
    
    if ProbFlag
        % Compute the time derivative of Prob(i) for each habitat i.
       for j = 1 : length(Population)  % 开始遍历栖息地 开始求导
            % j 代表的是 栖息地
            % Compute lambda for one less than the species count of habitat i.
            
            lambdaMinus = I * (1 - (Population(j).SpeciesCount - 1) / P);
            
            % Compute mu for one more than the species count of habitat i.
            muPlus = E * (Population(j).SpeciesCount + 1) / P;
            
            % Compute Prob for one less than and one more than the species count of habitat i.
            % Note that species counts are arranged in an order opposite to that presented in
            % MacArthur and Wilson's book - that is, the most fit
            % habitat has index 1, which has the highest species count.
            
            % 请注意,物种数量的排列顺序与麦克阿瑟和威尔逊的书中的顺序相反——
            % 也就是说,最适合的栖息地的索引是 1,其物种数量最高。
            % 所以说 对 第 j = 1 个种群 ,物种数量是最多的,因此在 t 时刻 不能进行迁出操作
            % 所以说 对 第 j = Smax 个种群 ,物种数量是最少的,因此在 t 时刻 不能进行迁入操作
            % j 从 1 -- Smax  物种数量是从最多到最少  

            if j < length(Population)  % S < Smax
                ProbMinus = Prob(j+1);   % !!!因为是相反的,所以 j + 1表示的是 物种数量 - 1 
            else                       % S == Smax
                ProbMinus = 0; 
            end
            
            if j > 1   % S > 1
                ProbPlus = Prob(j-1);   %  !!! 因为是相反的,所以 j - 1表示的是 物种数量 + 1
            else       % S = 1
                ProbPlus = 0;
            end
            ProbDot(j) = -(lambda(j) + mu(j)) * Prob(j) + lambdaMinus * ProbMinus + muPlus * ProbPlus;
        end

            % Note that species counts are arranged in an order opposite to that presented in
            % MacArthur and Wilson's book - that is, the most fit
            % habitat has index 1, which has the highest species count.
            
            % 请注意,物种数量的排列顺序与麦克阿瑟和威尔逊的书中的顺序相反——
            % 也就是说,最适合的栖息地的索引是 1,其物种数量最高。

注意源码中标注的这句,所以可以发现,正是在源码中对栖息地的排序是从 最好 到 最差,所以相对应的 种群数量也是从最多到最少,与上述(2)的也是相反的,详细的理解可以参考我在代码中的注释

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章