www.gusucode.com > 基于matlab编程斯坦纳树的配电网规划研究程序 > 基于matlab编程斯坦纳树的配电网规划研究程序/code/fitness.m

    function y=fitness(x)
load PSOfit.mat
    dai=fix(x*endl); 
    sums=zeros(1000,1);
    dd=1;
    while dai>0
            yu=mod(dai,2);
            dai=fix(dai/2);
            sums(dd)=yu;
            dd=dd+1;
    end
    points=[];
    for j=1:rownet
        if sums(j)==1
            points=[points;net(j)];
        end
    end
    points=[points;p];
    points=sort(points);
    Gs=G(points,points);
    MSTs=Prim_algo(Gs);
    y=sum(MSTs(:,3));