加入了各种统计值。
This commit is contained in:
parent
7ded138066
commit
0f8edee30b
|
|
@ -0,0 +1,14 @@
|
|||
function this=AddPDQDPGQG( this, PD,QD,PG,QG)
|
||||
%ADDPD Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
if this.currentPos>this.sampleNum
|
||||
error('出入的数太多了');
|
||||
return;
|
||||
end
|
||||
this.currentPos=this.currentPos+1;
|
||||
this.PDArray(:,this.currentPos)=PD;
|
||||
this.QDArray(:,this.currentPos)=QD;
|
||||
this.PGArray(this.currentPos)=PG;
|
||||
this.QGArray(this.currentPos)=QG;
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
classdef ForThesis
|
||||
%UNTITLED Summary of this class goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
properties
|
||||
currentPos=0;
|
||||
sampleNum=0;
|
||||
LoadNum=0;
|
||||
PDArray=0;
|
||||
|
||||
QDArray=0;
|
||||
PGArray=0;
|
||||
QGArray=0;
|
||||
|
||||
end
|
||||
|
||||
methods
|
||||
function this=ForThesis(sampleNum,LoadNum)
|
||||
this.currentPos=0;%记录当前用到的列,不要超过100列
|
||||
this.sampleNum=sampleNum;
|
||||
this.LoadNum=LoadNum;
|
||||
this.PDArray=zeros(LoadNum,sampleNum);
|
||||
this.QDArray=zeros(LoadNum,sampleNum);
|
||||
this.PGArray=zeros(sampleNum,1);
|
||||
this.QGArray=zeros(sampleNum,1);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function MaxDeviation(this,PG0,QG0,PD0,QD0)
|
||||
PD0Array=repmat(PD0,1,this.sampleNum);
|
||||
QD0Array=repmat(QD0,1,this.sampleNum);
|
||||
PDMaxDev=max(abs(this.PDArray-PD0Array),[],2)
|
||||
QDMaxDev=max(abs(this.QDArray-QD0Array),[],2)
|
||||
PG0Array=repmat()
|
||||
end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
function [output_arg]=MaxDeviation(this,PG0,QG0,PD0,QD0)
|
||||
PD0Array=repmat(PD0,1,this.sampleNum);
|
||||
QD0Array=repmat(QD0,1,this.sampleNum);
|
||||
PDMaxDev=max(abs( (this.PDArray-PD0Array)./PD0Array ),[],2);
|
||||
QDMaxDev=max(abs( (this.QDArray-QD0Array)./QD0Array ),[],2);
|
||||
PG0Array=repmat(PG0,this.sampleNum,1);
|
||||
QG0Array=repmat(QG0,this.sampleNum,1);
|
||||
PGMaxDev=max(abs( (PG0Array-this.PGArray)./PG0Array ));
|
||||
QGMaxDev=max( abs( (QG0Array-this.QGArray)./QG0Array ) );
|
||||
output_arg=max([PDMaxDev;QDMaxDev;PGMaxDev;QGMaxDev]);
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function [ output_args ] = MeanPD(this)
|
||||
%MEANPD Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
output_args=sum(this.PDArray,2)/this.sampleNum;
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function [ output_args ] = MeanPG( this )
|
||||
%MEANPG Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
output_args=sum(this.PGArray,1)/this.sampleNum;
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function [ output_args ] = MeanQD(this)
|
||||
%MEANQD Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
output_args=sum(this.QDArray,2)/this.sampleNum;
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
function [ output_args ] = MeanQG( this )
|
||||
%MEAQG Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
output_args=sum(this.QGArray,1)/this.sampleNum;
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
function [ output_args ] = StatDeviation( this,PG0,QG0,PD0,QD0 )%ͳ¼ÆÎó²î
|
||||
%STATDEVIATION Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
PD0Array=repmat(PD0,1,this.sampleNum);
|
||||
QD0Array=repmat(QD0,1,this.sampleNum);
|
||||
PDMaxDev=max(abs(this.PDArray-PD0Array),[],2);
|
||||
QDMaxDev=max(abs(this.QDArray-QD0Array),[],2);
|
||||
PG0Array=repmat(PG0,this.sampleNum,1);
|
||||
QG0Array=repmat(QG0,this.sampleNum,1);
|
||||
PGMaxDev=max(abs(PG0Array));
|
||||
QGMaxDev=max(abs(QG0Array));
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
function [ output_args ] = StatDeviation( this,PG0,QG0,PD0,QD0 )%ͳ¼ÆÎó²î
|
||||
%STATDEVIATION Summary of this function goes here
|
||||
% Detailed explanation goes here
|
||||
|
||||
PD0Array=repmat(PD0,1,this.sampleNum);
|
||||
QD0Array=repmat(QD0,1,this.sampleNum);
|
||||
PDDev=(this.PDArray-PD0Array)/0.05;
|
||||
QDDev=(this.QDArray-QD0Array)/0.05;
|
||||
PG0Array=repmat(PG0,this.sampleNum,1);
|
||||
QG0Array=repmat(QG0,this.sampleNum,1);
|
||||
PGDev=(PG0Array-this.PGArray)/0.01;
|
||||
QGDev=(QG0Array-this.QGArray)/0.01;
|
||||
wholeMat=[PDDev;QDDev;PGDev';QGDev'];
|
||||
t1=wholeMat.^2;
|
||||
t2=sum(t1,1);
|
||||
t3=t2/size(t1,1);
|
||||
t4=t3.^2;
|
||||
output_args=sum(t4)/length(t4);
|
||||
end
|
||||
|
||||
10
FormLw.m
10
FormLw.m
|
|
@ -8,14 +8,14 @@ VoltU=(1.1)*ones(1,Busnum);
|
|||
%VoltU=10*ones(1,Busnum);
|
||||
PDU=PD0(Loadi);
|
||||
% PDU=noDataTransCapacity;
|
||||
PDU(PDU>0)=1.200*PDU(PDU>0);
|
||||
PDU(PDU<0)=0.800*PDU(PDU<0);
|
||||
PDU(PDU>0)=1.300*PDU(PDU>0);
|
||||
PDU(PDU<0)=0.700*PDU(PDU<0);
|
||||
PDU(PDU==0)=0.400;
|
||||
%PDU=10*ones(length(Loadi),1);
|
||||
QDU=QD0(Loadi);
|
||||
QDU(QDU>0)=1.200*QDU(QDU>0);
|
||||
QDU(QDU<0)=0.800*QDU(QDU<0);
|
||||
QDU(QDU==0)=0.200;
|
||||
QDU(QDU>0)=1.300*QDU(QDU>0);
|
||||
QDU(QDU<0)=0.700*QDU(QDU<0);
|
||||
QDU(QDU==0)=0.400;
|
||||
% PF=0.85;
|
||||
% QDU=1.0*PD(Loadi).*sqrt(1 -PF.^2)./PF;
|
||||
t1=([PU',QU',PDU',QDU',VoltU])';
|
||||
|
|
|
|||
10
FormLz.m
10
FormLz.m
|
|
@ -7,14 +7,14 @@ QL=-5*ones(length(PVQL(:,1)),1);
|
|||
VoltL=(0.9)*ones(1,Busnum);
|
||||
%VoltL=-10*ones(1,Busnum);
|
||||
PDL=PD0(Loadi);
|
||||
PDL(PDL>0)=0.800*PDL(PDL>0);
|
||||
PDL(PDL<0)=1.200*PDL(PDL<0);
|
||||
PDL(PDL>0)=0.700*PDL(PDL>0);
|
||||
PDL(PDL<0)=1.300*PDL(PDL<0);
|
||||
PDL(PDL==0)=-0.400;
|
||||
%PDL=-10*ones(length(Loadi),1);
|
||||
QDL=QD0(Loadi);
|
||||
QDL(QDL>0)=0.800*QDL(QDL>0);
|
||||
QDL(QDL<0)=1.200*QDL(QDL<0);
|
||||
QDL(QDL==0)=-0.200;
|
||||
QDL(QDL>0)=0.700*QDL(QDL>0);
|
||||
QDL(QDL<0)=1.300*QDL(QDL<0);
|
||||
QDL(QDL==0)=-0.400;
|
||||
% QDL=0*PD(Loadi).*sqrt((1-PF.^2))./PF;
|
||||
t1=([PL',QL',PDL',QDL',VoltL])';
|
||||
t2=Mat_G-Init_L'-t1;
|
||||
|
|
|
|||
7
OPF.asv
7
OPF.asv
|
|
@ -51,7 +51,8 @@ QD0(Loadi)=QD0(Loadi).*(1+normrnd(0,0.05,length(Loadi),1));
|
|||
PG0(PGi)=PG0(PGi).*(1+normrnd(0,0.01,length(PGi),1));
|
||||
QG0(PVi)=QG0(PVi).*(1+normrnd(0,0.01,length(PVi),1));
|
||||
%% 读变压器容量
|
||||
[noDataTransNum noDataTransCapacity noDataTransPowerFactor]=ReadNoDataTrans(fileName);
|
||||
%[noDataTransNum noDataTransCapacity noDataTransPowerFactor]=ReadNoDataTrans('C:/b/东际911_2751267_2012-09-05/iPso_东际911_2751267_2012-09-05_变压器无负载.txt');
|
||||
noDataTransCapacity=0;
|
||||
while(abs(Gap)>Precision)
|
||||
if KK>kmax
|
||||
break;
|
||||
|
|
@ -83,7 +84,7 @@ while(abs(Gap)>Precision)
|
|||
Mat_H=FormH(Busnum,Volt,PG,PD,QG,QD,Y,UAngel,r,c,Angle,QD_NON_ZERO,QD_NON_ZERO_IND,Loadi);
|
||||
Ly=Mat_H;
|
||||
Lz=FormLz(Mat_G,Init_L,GenL,Busnum,PVQL,PD,PD0,QD0,Loadi,KK,PF);
|
||||
Lw=FormLw(Mat_G,Init_U,GenU,Busnum,PVQU,PD,PD0,QD0,Loadi,KK,PF);
|
||||
Lw=FormLw(Mat_G,Init_U,GenU,Busnum,PVQU,PD,PD0,QD0,Loadi,KK,PF,noDataTransCapacity);
|
||||
Lx=FormLx(deltF,deltH,Init_Y,deltG,Init_Z,Init_W);
|
||||
YY=FormYY(Lul,Lz,Ly,Luu,Lw,Lx);
|
||||
%% 开始解方程
|
||||
|
|
@ -97,7 +98,7 @@ while(abs(Gap)>Precision)
|
|||
end
|
||||
fprintf('迭代次数%d\n',KK);
|
||||
fprintf('目标值%f\n',full(ObjectiveFun(PG,PG0,PGi,QG,QG0,PVi,PD,PD0,QD,QD0,wPG,wQG,wPD,wQD,Loadi)));
|
||||
DrawGap(plotGap);
|
||||
% DrawGap(plotGap);
|
||||
%%
|
||||
%Volt=full(Volt');
|
||||
%PD=full(PD);
|
||||
|
|
|
|||
20
OPF.m
20
OPF.m
|
|
@ -1,6 +1,8 @@
|
|||
tic
|
||||
clc
|
||||
clear
|
||||
thesis=ForThesis(4,8);
|
||||
for II=1:4
|
||||
[kmax,Precision,UAngel,Volt,Busnum,PVi,PVu,Balance,Y,Angle,P0,Q0,r,c,GB,Linei,Linej,Transfori,Transforj,GenU,GenL,GenC,PG,QG,PD,QD,CenterA,PGi,PVQU,PVQL,Liner,Linex,Lineb,Transforr,Transforx,Transfork0]= ...
|
||||
pf('c:/newFIle.txt');
|
||||
%pf('D:\Project\青秀降损项目\最小化潮流\最小潮流算例\原始\津头站津视922(3-1)_0.5_120%.txt');
|
||||
|
|
@ -43,16 +45,17 @@ kmax=60;
|
|||
QD_NON_ZERO=QD(PD==0 & QD~=0);
|
||||
QD_NON_ZERO_IND=find(PD==0 & QD~=0);
|
||||
%%
|
||||
Precision=Precision/1;
|
||||
Precision=Precision/10;
|
||||
|
||||
%% 加误差
|
||||
PD0(Loadi)=PD0(Loadi).*(1+normrnd(0,0.05,length(Loadi),1));
|
||||
QD0(Loadi)=QD0(Loadi).*(1+normrnd(0,0.05,length(Loadi),1));
|
||||
PG0(PGi)=PG0(PGi).*(1+normrnd(0,0.01,length(PGi),1));
|
||||
QG0(PVi)=QG0(PVi).*(1+normrnd(0,0.01,length(PVi),1));
|
||||
% PG0(PGi)=PG0(PGi).*(1+normrnd(0,0.01,length(PGi),1));
|
||||
% QG0(PVi)=QG0(PVi).*(1+normrnd(0,0.01,length(PVi),1));
|
||||
%% 读变压器容量
|
||||
%[noDataTransNum noDataTransCapacity noDataTransPowerFactor]=ReadNoDataTrans('C:/b/东际911_2751267_2012-09-05/iPso_东际911_2751267_2012-09-05_变压器无负载.txt');
|
||||
noDataTransCapacity=0;
|
||||
|
||||
while(abs(Gap)>Precision)
|
||||
if KK>kmax
|
||||
break;
|
||||
|
|
@ -98,7 +101,7 @@ while(abs(Gap)>Precision)
|
|||
end
|
||||
fprintf('迭代次数%d\n',KK);
|
||||
fprintf('目标值%f\n',full(ObjectiveFun(PG,PG0,PGi,QG,QG0,PVi,PD,PD0,QD,QD0,wPG,wQG,wPD,wQD,Loadi)));
|
||||
DrawGap(plotGap);
|
||||
% DrawGap(plotGap);
|
||||
%%
|
||||
%Volt=full(Volt');
|
||||
%PD=full(PD);
|
||||
|
|
@ -116,5 +119,14 @@ fprintf('
|
|||
fprintf('线损率为 %f\n',full(totalLoss/sum(PG)));
|
||||
%% 计算各线损
|
||||
%Lineloss(Linei,Linej,Liner,Linex,Lineb,Transfori,Transforj,Transforr,Transforx,Transfork0,Volt,UAngel);
|
||||
thesis=thesis.AddPDQDPGQG(PD(Loadi),QD(Loadi),PG(Balance),QG(PVi));
|
||||
|
||||
end
|
||||
PD(Loadi)=thesis.MeanPD();
|
||||
QD(Loadi)=thesis.MeanQD();
|
||||
PG(Balance)=thesis.MeanPG();
|
||||
QG(PVi)=thesis.MeanQG();
|
||||
thesis.MaxDeviation(PG0(Balance),QG0(PVi),PD0(Loadi),QD0(Loadi));
|
||||
thesis.StatDeviation(PG0(Balance),QG0(PVi),PD0(Loadi),QD0(Loadi))
|
||||
toc
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ tPL=sparse(GenL(:,2));%
|
|||
tQL=sparse(PVQL(:,1));% 无功下限
|
||||
PG(PGi)=(tPU+tPL)/2;
|
||||
QG(PVi)=(tQU+tQL)/2;
|
||||
wPG=100*ones(size(PGi,1),1);
|
||||
wQG=100*ones(size(PVi,1),1);
|
||||
wPG=0*ones(size(PGi,1),1);
|
||||
wQG=0*ones(size(PVi,1),1);
|
||||
%randInt=randperm(size(Loadi,1));
|
||||
%randPDind=randInt(1:10);
|
||||
randPDind=0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue