• 大小: 1KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: Matlab
  • 标签: matlab  pso  wugong  

资源简介

基于pso算法的无功优化程序,针对14节点系统,采用MATLAB编程。

资源截图

代码片段和文件信息

clc
clear
popsize=40;
MAXITER=100;
dimension=12;
w_max = 0.9;                        
w_min = 0.4;
v_max = 6;                                                                                                 
c1 = 2;                  
c2 = 2;
vmin=0.9;
vmax=1.1;
q10min=0;
q10max=0.04;
q24min=0;
q24max=0.04;
tmin=0.9;
tmax=1.1;
xmax=100;
sum1=0;
sum2=0;
mean=0;
st=0;
runno=1;
data1=zeros(runnoMAXITER);
v=3/2*(rand(popsize12));             %   初始化当前速度
V=vmin+(vmax-vmin)*rand(popsize61);
Q10=round(5*rand(popsize11));
Q24=round(5*rand(popsize11));
TA=round(10*rand(popsize41))-5;
x=[V Q10 Q24 TA];
%for run=1:runno
mean=0;
T=cputime;
pbest=x;
%disp(‘pbest=‘);
%disp(pbest);
gbest=zeros(1dimension);
  for i=1:popsize;
     %[PLOSS] = runpf(casenamex(i:))
      f_x(i)=yue(x(i:));
    f_pbest(i)=f_x(i);
  end
%disp(‘f_pbest=‘);
%disp(f_pbest);  
    g=find(f_pbest==min(f_pbest(1:popsize)));%找出f_pbest中等于min(f_pbest(1:popsize))元素的下标
    gbest=pbest(g:);
    f_gbest=f_pbest(g);
    MINIUM=f_gbest;
  for t=1:MAXITER;
       disp(‘MINIUM=‘);
       disp(MINIUM);
       disp(‘迭代次数t=‘);
       disp(t);
    w = w_max-(w_max-w_min)*t/MAXITER;
   for i=1:popsize;
       u(i)=v(i);
     v(i:) = w.*v(i:)+c1.*rand.*(pbest(i1:dimension)-x(i1:dimension))+c2.*rand.*(gbest(1:dimension)-x(i1:dimension));
     if abs(v(i)-u(i))<0.00001;
         v(i)=3/2*(rand(112));
     end
     x(i1:dimension) = x(i1:dimension)+v(i1:dimension);
        %disp(‘导纳矩阵  x(i:)=‘);
        %disp( x(i:)); 
%       x(i:)=sign(y).*min(abs(y)xmax); 
         for j=1:6;
            if x(ij)>1.1;
                x(ij)=1.1;
            end;
            if x(ij)<0.95;
                x(ij)=0.95;
            end;
         end;
         for j=7:8;
            if x(ij)>5;
                x(ij)=5;
            end;
            x(ij)=round(x(ij));
         end;
         for j=9:dimension;
            if x(ij)>5;
                x(ij)=5;
            end;
            if x(ij)<-5;
                x(ij)=-5;
            end;
            x(ij)=round(x(ij));
         end
         %disp(‘矩阵 x=‘);
         %disp(x); 
         for i=1:40;
             for j=1:40;
                 if abs(x(i)-x(j))<0.00001;
                     f_x(i)=yue(x(i:));
                     f_x(j)=yue(x(j:));
                     if f_x(i)                         x(i)=3*rand(112);
                     else 
                         x(j)=3*rand(112);
                     end
                 end
             end
         end             
         f_x(i)=yue(x(i:));
         if f_x(i)              pbest(i:)=x(i:);
              f_pbest(i)=f_x(i);
         end
         if f_pbest(i)              gbest=pbest(i:);
              f_gbest=f_pbest(i);
         end  
        
            MINIUM=f_gbest;                    
      end
   % disp(‘矩阵 x=‘);
    %disp(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3422  2012-02-25 14:25  pso.m

     文件        151  2017-12-14 20:23  www.downma.com.txt

----------- ---------  ---------- -----  ----

                 3573                    2


评论

共有 条评论