shareevaniche.sci

来自「基于SCILAB的The Genetic Algorithm Toolbox f」· SCI 代码 · 共 30 行

SCI
30
字号
function endPop=ShareEvaNiche(oldPop,bounds,NicheOpt,options)
// options(1) parameter for caculate distance
// options(2) parameter for share distance
e = size(oldPop,2) ; //number of Variables +fit
n = size(oldPop,1);   //number of Pop;
endPop=oldPop;
dis= zeros(n);
sharew=zeros(n);
sumw=zeros(n,1);
for i=1:n 
    Pop1=oldPop(i,:);
    for j=i+1:n
        Pop2=oldPop(j,:);
        dis(i,j)= normDistance(Pop1,Pop2,bounds,options);
        sharew(i,j) = ShareFunction(dis(i,j),NicheOpt(1) );
    end
end
sumw= (sum(sharew)' + sum(sharew')' - diag(sharew))'+1;
endPop(:,e)=endPop(:,e)./sumw';
end


function shareweight=ShareFunction(distance,sharedistance )
if ( distance <= sharedistance )
    shareweight = 1- distance/sharedistance;
else
    shareweight = 0;
end
end

⌨️ 快捷键说明

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