www.pudn.com > IEEE33DG.rar > main.m, change:2015-04-17,size:2410b


%function main() 
clear; 
clc; 
tic; 
numberofRuns = 1;          %number of trials per experiment 
 
psoOptions = get_psoOptions; 
  
psoOptions.Vars.ErrGoal = 1e-4;     %最小误差 
LL=5;   %联络开关数 
% Parameters common across all functions 
psoOptions.SParams.c1 = 0.02; %边界参数 
psoOptions.SParams.w_beta = 0.5; %初始化beta值 
 
% Run experiments for the three complex functions 
psoOptions.Obj.f2eval = 'fitness_cgfcPQV'; 
 
psoOptions.Obj.lb = ones(1,LL); %初始化下限 
%psoOptions.Obj.lb = ones(1,32); 
psoOptions.Obj.ub = [10 7 15 21 11]; %初始化上限            %通过运行程序maxswarmmin得到的结果 
%psoOptions.Obj.ub = 20*ones(1,32); 
%psoOptions.Obj.ub(1,1:5)=4; 
psoOptions.SParams.Xmax =psoOptions.Obj.ub; %最大限制位置 
 
 
  
%-----------------------------------------------------------% 
%--Run Experiments for different dimensions and SwarmSizes--% 
%-----------------------------------------------------------% 
    DimIters = [5; ...   %Dimensions维数 
              300];    %Corresponding iterations迭代次数 
    x = DimIters; 
        psoOptions.Vars.Dim = x(1,:); 
        psoOptions.Vars.Iterations = x(2,:); 
        swarmsize = [50]   %种群规模 
            psoOptions.Vars.SwarmSize = swarmsize; 
            disp(sprintf('This experiment will optimize %s function for %d times.', psoOptions.Obj.f2eval, numberofRuns)); 
            disp(sprintf('Population Size: %d\t\tDimensions: %d.', psoOptions.Vars.SwarmSize, psoOptions.Vars.Dim)); 
              temp = 5e6; 
              fVal = 0; 
     
     
 
 
for i = 1:numberofRuns     %程序运行numberofRuns次 
    [tfxmin, xmin,PBest,fPBest, tHistory] = QPSO(psoOptions); 
    fVal(:,i)=tfxmin; 
      if temp>tfxmin 
        temp=tfxmin; 
        record=tHistory; 
   end 
     
end 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
toc; 
disp(sprintf('\nminxfmin= \t\t%2.10g',temp));  %最优函数适应值 
xmin           %优化的开关组合     
fPBest         %备选开关组合函数适应值 
PBest          %备选开关组合(用于在哪个开关失灵情况下,采用备选方案,更加符合实际情况) 
a=fbm(xmin) 
sumall=0; 
for i = 1:numberofRuns 
    if fVal(i)<100 
        sumall=sumall+1; 
    end 
end  
pre=sumall/numberofRuns 
Avg = sum(fVal)/numberofRuns; 
disp(sprintf('\nAvg. \t\t%2.10g\n\n', Avg)) %平均值 
[fploss,fustab]=powflow(a)   %根据运行结果调用潮流函数,求得运行处的网损与节点电压稳定性值