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


%function main() 
clear; 
clc; 
tic; 
psoOptions = get_psoOptions;  
psoOptions.Vars.ErrGoal = 1e-6;     %最小误差 
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_4geDG'; 
 
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; %最大限制位置 
 
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', psoOptions.Obj.f2eval)); 
disp(sprintf('Population Size: %d\t\tDimensions: %d.', psoOptions.Vars.SwarmSize, psoOptions.Vars.Dim)); 
temp = 5e6; 
fVal = 0; 
%运行QPSO算法 
 [tfxmin, xmin,PBest,fPBest, tHistory] = QPSO(psoOptions); 
    fVal=tfxmin; 
      if temp>tfxmin 
        temp=tfxmin; 
        record=tHistory; 
      end 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
toc; 
disp(sprintf('\nminxfmin= \t\t%2.10g',temp));  %最优函数适应值 
xmin           %优化的开关组合     
fPBest         %备选开关组合函数适应值 
PBest          %备选开关组合(用于在哪个开关失灵情况下,采用备选方案,更加符合实际情况) 
a=fbm(xmin)