for i=1:N
[bus,line ] = test6(x(i,:)); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG=[x(i,:),s,L];
p(i)=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
y(i,:)=x(i,:);
end
pg = x(N,:); %Pg为全局最优
[bus,line ] = test6(x(N,:));
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0;
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG1=[x(N,:),s,L];
tg=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG1');
for i=1:(N-1)
if p(i)<tg;
pg = x(i,:);
end
end
for t=1:M
for i=1:N %速度、位移更新
w=wmax-(t-1)*(wmax-wmin)/(M-1); %权重线性递减
v(i,:)=w*v(i,:)+c1*rand*(y(i,:)-x(i,:))+c2*rand*(pg-x(i,:));
x(i,:)=x(i,:)+v(i,:);
[bus,line ] = test6(x(i,:)); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG=[x(i,:),s,L];
if Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG')<p(i)
p(i)=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
y(i,:)=x(i,:);
end
[bus,line ] = test6(pg);
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0;
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG1=[x(N,:),s,L];
tg=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG1');
if p(i)<tg
pg=y(i,:);
end
end
end
[bus,line ] = test6(pg); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
pG=[pg,s,L];
x2 =pG'
fv =Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
if norm(x2-x1)<=eps
x = x2;
break;
else
c1 = M;
x1 = x2;
end
minf = Funval(f,var,x);
format short;
end
[bus,line ] = test6(x(i,:)); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG=[x(i,:),s,L];
p(i)=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
y(i,:)=x(i,:);
end
pg = x(N,:); %Pg为全局最优
[bus,line ] = test6(x(N,:));
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0;
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG1=[x(N,:),s,L];
tg=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG1');
for i=1:(N-1)
if p(i)<tg;
pg = x(i,:);
end
end
for t=1:M
for i=1:N %速度、位移更新
w=wmax-(t-1)*(wmax-wmin)/(M-1); %权重线性递减
v(i,:)=w*v(i,:)+c1*rand*(y(i,:)-x(i,:))+c2*rand*(pg-x(i,:));
x(i,:)=x(i,:)+v(i,:);
[bus,line ] = test6(x(i,:)); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG=[x(i,:),s,L];
if Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG')<p(i)
p(i)=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
y(i,:)=x(i,:);
end
[bus,line ] = test6(pg);
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0;
for j=1:48
L=real(S_res(j,5))+L;
end
s=0;
for j=1:48
s=real(bus_res(j,4))+s;
end
pG1=[x(N,:),s,L];
tg=Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG1');
if p(i)<tg
pg=y(i,:);
end
end
end
[bus,line ] = test6(pg); %进行牛顿潮流计算
[bus_res,S_res] =PowerFlow_NR(bus,line);
L=0; %调用潮流计算得到数据
for j=1:48
L=real(S_res(j,5))+L;
end
pG=[pg,s,L];
x2 =pG'
fv =Funval(SumF,[p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 s l],pG');
if norm(x2-x1)<=eps
x = x2;
break;
else
c1 = M;
x1 = x2;
end
minf = Funval(f,var,x);
format short;
end

星雨久梦

