✅作者簡介:熱愛科研的Matlab仿真開發者,修心和技術同步精進,matlab項目合作可私信。
🍎個人首頁:Matlab科研工作室
🍊個人信條:格物緻知。
⛄ 内容介紹
微電網集中了分布式發電、負荷和儲能,其并網接入必然對配電網的無功優化産生影響。提出了考慮微電網的配電網動态無功優化模型,在模型中考慮微電網運作特性對于動态無功優化的影響。利用基于粒子群算法進行無功優化求解,通過 IEEE33節點配電網系統的仿真算例驗證了本文計算的合理性和有效性。
⛄ 部分代碼
%% 清空環境
clc;
clear;
%% 參數初始化
%粒子群算法中的兩個參數
c1 = 1.5;
c2 = 1.5;
maxgen=50; %進化次數
sizepop=60; %種群規模
Vmax=[4 4 4 4 4 4 4 0 0 4];
Vmin=[-4 -4 -4 -4 -4 -4 -4 0 0 -4];
popmax=[60 60 0 34 400 15 15 0 10 60];
popmin=[0 0 0 0 0 0 0 0 10 0];
%% 産生初始粒子和速度
for z=1:sizepop
%随機産生一個種群
pop(z,:)=60*rand(); %初始種群
pop(z,2)=60*rand();
pop(z,3)=0;
pop(z,4)=34*rand();
pop(z,5)=400*rand();
pop(z,6)=15*rand();
pop(z,7)=15*rand();
pop(z,8)=0;
pop(z,9)=10;
pop(z,10)=60*rand();
V(z,1)=4*rand(); %初始化速度
V(z,2)=4*rand();
V(z,3)=4*rand();
V(z,4)=4*rand();
V(z,5)=4*rand();
V(z,6)=4*rand();
V(z,7)=4*rand();
V(z,8)=0;
V(z,9)=0;
V(z,10)=4*rand();
%計算适應度
fitness(z)=fun1(pop(z,:)); %染色體的适應度
end
end
%[bf bt]=max(fitness);
%gb=pop(bt,:); %最佳geti
%disp(gb);
for j=1:sizepop
%個體最優更新
if fitness(j) < fitnessgbest(j)
gbest(j,:) = pop(j,:);
fitnessgbest(j) = fitness(j);
end
%群體最優更新
if fitness(j) < fitnesszbest
zbest = pop(j,:);
fitnesszbest = fitness(j);
end
end
result(z)=fitnesszbest;
yy(:,z)=zbest;
end
disp (zbest);
disp (fitnesszbest);
g=[zbest(1)+zbest(6)*1i zbest(2)+zbest(7)*1i zbest(3)+zbest(8)*1i zbest(4)+zbest(9)*1i];
u=sum(g);
disp(g);
disp(u);
l=zbest(5)+zbest(10)*1i;
disp(l);
t=u-l;
disp(t);
%% 結果分析
plot(result)
title('最優個體适應度','fontsize',12);
xlabel('進化代數','fontsize',12);ylabel('适應度','fontsize',12);