改成了含0注入约束(不是潮流约束)的最小二乘法。

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab
2015-03-19 13:19:57 +08:00
parent 4c521bd022
commit b7498c2b15
6 changed files with 83 additions and 135 deletions

View File

@@ -14,16 +14,13 @@ Balance=this.Balance;
Y=this.Y;
PD=x(1:length(PDi));
QD=x(length(PDi)+1:length(PDi)+length(QDi));
Volt=x(length(PDi)+length(QDi)+1:length(PDi)+length(QDi)+length(Volt0));
VAngel=x(length(PDi)+length(QDi)+length(Volt0)+1:end);
Volt=x(1:length(Volt0));
VAngel=x(length(Volt0)+1:end);
PD_=zeros(length(Volt0),1);
QD_=zeros(length(Volt0),1);
PD_(PDi)=PD;
QD_(QDi)=QD;
busNum=length(Volt0);
VMatrix=sparse(r,c,VAngel(r)-VAngel(c)-Angel,busNum,busNum);
dP=PG-PD_-diag(Volt)*(Y.*cos(VMatrix))*Volt;
dQ=QG-QD_-diag(Volt)*(Y.*spfun(@sin,VMatrix))*Volt;
output_args=[dP;dQ];%潮流约束
%% 使用零注入begin
% zeroInj=setdiff(1:busNum,union(Balance,union(PDi,QDi)));
@@ -35,38 +32,6 @@ output_args=[output_args;Volt(Balance)-1];
output_args=[output_args;VAngel(Balance)];
this.cu=zeros(length(output_args),1);
this.cl=zeros(length(output_args),1);
%% 开始增加不等式约束-电压\PD\QD
%电压不等式约束
output_args=[output_args;Volt];
% this.cu=[this.cu;1.07*ones(length(Volt),1)];%9节点
% this.cl=[this.cl;0.93*ones(length(Volt),1)];%9节点
this.cu=[this.cu;1.00*ones(length(Volt),1)];
this.cl=[this.cl;0.90*ones(length(Volt),1)];
%% PD
rPD=this.rPD;
output_args=[output_args;PD];
% PDU=[0.124;0.315;0.5;1;1;0.5;0.63;0.4];%原始数据
% PDU=[0.63;0.4;0.5;1;0.8;1;0.63;0.4];%偏差比较大
%Generate values from the uniform distribution on the interval [a, b].
global loadFlag;
if loadFlag==0
r =-0.201 + (-0.01-(-0.2)).*rand(length(rPD),1);
else
end
this.cu=[this.cu;(r+1.4).*rPD];
this.cl=[this.cl;(r+1).*rPD];
% this.cu=[this.cu;PDU];
% this.cl=[this.cl;0*PDU];
%% QD
rQD=this.rQD;
output_args=[output_args;QD];
% QDU=PDU;
this.cu=[this.cu;(r+1.4).*rQD];
this.cl=[this.cl;(r+1).*rQD];
% this.cu=[this.cu;QDU];
% this.cl=[this.cl;0*QDU];
%% 稠密化
output_args=full(output_args);
this.cu=full(this.cu);

View File

@@ -2,74 +2,36 @@ function [ output_args,this ] = equ( this,x )
%EQU Summary of this function goes here
% Detailed explanation goes here
output_args=[];
PDi=this.PDi;
QDi=this.QDi;
Volt0=this.Volt0;
Balance=this.Balance;
% Volt=x(1:length(Volt0));
% VAngel=x(length(Volt0)+1:end);
%% 使begin
SEVolt=x(1:length(Volt0));
SEVAngel=x(length(SEVolt)+1:end);
Angel=this.Angel;
r=this.r;
c=this.c;
PG=this.PG;
QG=this.QG;
Balance=this.Balance;
Y=this.Y;
PD=x(1:length(PDi));
QD=x(length(PDi)+1:length(PDi)+length(QDi));
Volt=x(length(PDi)+length(QDi)+1:length(PDi)+length(QDi)+length(Volt0));
VAngel=x(length(PDi)+length(QDi)+length(Volt0)+1:end);
PD_=zeros(length(Volt0),1);
QD_=zeros(length(Volt0),1);
PD_(PDi)=PD;
QD_(QDi)=QD;
busNum=length(Volt0);
VMatrix=sparse(r,c,VAngel(r)-VAngel(c)-Angel,busNum,busNum);
dP=PG-PD_-diag(Volt)*(Y.*cos(VMatrix))*Volt;
dQ=QG-QD_-diag(Volt)*(Y.*spfun(@sin,VMatrix))*Volt;
output_args=[dP;dQ];%
%% 使begin
% zeroInj=setdiff(1:busNum,union(Balance,union(PDi,QDi)));
% output_args=[output_args(zeroInj);output_args(length(Volt0)+zeroInj)];
%% 使end
%
output_args=[output_args;Volt(Balance)-1];
%
output_args=[output_args;VAngel(Balance)];
VMatrix=sparse(r,c,SEVAngel(r)-SEVAngel(c)-Angel,busNum,busNum);
zerosP=diag(SEVolt)*(Y.*cos(VMatrix))*SEVolt;
zerosQ=diag(SEVolt)*(Y.*spfun(@sin,VMatrix))*SEVolt;
PDi=this.PDi;
QDi=this.QDi;
zeroInj=setdiff(1:busNum,union(Balance,union(PDi,QDi)));
output_args=[zerosP(zeroInj);zerosQ(zeroInj)];
this.cu=zeros(length(output_args),1);
this.cl=zeros(length(output_args),1);
%% 使end
%
output_args=[output_args;SEVolt(Balance)-1];
%
output_args=[output_args;SEVAngel(Balance)];
this.cu=zeros(length(output_args),1);
this.cl=zeros(length(output_args),1);
%% -\PD\QD
%
output_args=[output_args;Volt];
% this.cu=[this.cu;1.07*ones(length(Volt),1)];%9
% this.cl=[this.cl;0.93*ones(length(Volt),1)];%9
this.cu=[this.cu;1.00*ones(length(Volt),1)];
this.cl=[this.cl;0.90*ones(length(Volt),1)];
%% PD
rPD=this.rPD;
output_args=[output_args;PD];
% PDU=[0.124;0.315;0.5;1;1;0.5;0.63;0.4];%
% PDU=[0.63;0.4;0.5;1;0.8;1;0.63;0.4];%
%Generate values from the uniform distribution on the interval [a, b].
global loadFlag;
if loadFlag==1
r=load('rLD');
r=r.r;
else
%r=-0.2;
r =-0.201 + (-0.001-(-0.2)).*rand(length(rPD),1);
end
this.cu=[this.cu;(r+1.4).*rPD];
this.cl=[this.cl;(r+1).*rPD];
% this.cu=[this.cu;PDU];
% this.cl=[this.cl;0*PDU];
%% QD
rQD=this.rQD;
output_args=[output_args;QD];
% QDU=PDU;
this.cu=[this.cu;(r+1.4).*rQD];
this.cl=[this.cl;(r+1).*rQD];
% this.cu=[this.cu;QDU];
% this.cl=[this.cl;0*QDU];
%%
output_args=full(output_args);
this.cu=full(this.cu);

View File

@@ -3,32 +3,39 @@ function [ output_args ] = obj( this,x )
% Detailed explanation goes here
PDi=this.PDi;
QDi=this.QDi;
PD=x(1:length(PDi));
QD=x(length(PDi)+1:length(PDi)+length(QDi));
wPD=this.wPD;
wQD=this.wQD;
PD0=this.PD0;
QD0=this.QD0;
t4=(wPD(PDi).*(PD-PD0(PDi))).^2;
% t4=wPD(PDi).*((PD-PD0(PDi))./PD0(PDi)).^2;
t5=(wQD(QDi).*(QD-QD0(QDi))).^2;
% t5=wQD(QDi).*((QD-QD0(QDi))./QD0(QDi)).^2;
Volt0=this.Volt0;
SEVolt=x(length(PDi)+length(QDi)+1:length(PDi)+length(QDi)+length(Volt0));
SEVolt=x(1:length(Volt0));
wVolt=this.wVolt;
t6=(wVolt.*(SEVolt-Volt0)).^2;
% t6=wVolt.*((SEVolt-Volt0)./Volt0).^2;
t6=(wVolt.*((SEVolt-Volt0))).^2;
Balance=this.Balance;
t6(Balance)=0;%²»¼ÆËãÆ½ºâ½ÚµãµÄ
t6(2:0)
% µçÁ÷
SEVAngel=x(length(PDi)+length(QDi)+length(SEVolt)+1:end);
loadCurrent=LoadCurrent( SEVolt,SEVAngel,PD0(PDi),QD0(QDi),PDi,QDi );
wLoadCurrent=this.wLoadCurrent;
mLoadCurrent=this.mLoadCurrent;
t7=(wLoadCurrent.*(loadCurrent-mLoadCurrent)).^2;
t7=wLoadCurrent.*((loadCurrent-mLoadCurrent)./mLoadCurrent).^2;
output_args=sum(t4)+sum(t5)+sum(t6)+sum(0);
SEVAngel=x(length(SEVolt)+1:end);
busNum=length(Volt0);
Angel=this.Angel;
r=this.r;
c=this.c;
PG=this.PG;
QG=this.QG;
VMatrix=sparse(r,c,SEVAngel(r)-SEVAngel(c)-Angel,busNum,busNum);
PD_=PG-diag(SEVolt)*(Y.*cos(VMatrix))*Volt;
QD_=QG-diag(SEVolt)*(Y.*spfun(@sin,VMatrix))*Volt;
t4=(wPD(PDi).*(PD_-PD0(PDi))).^2;
t5=(wQD(QDi).*(QD_-QD0(QDi))).^2;
% loadCurrent=LoadCurrent( SEVolt,SEVAngel,PD0(PDi),QD0(QDi),PDi,QDi );
% wLoadCurrent=this.wLoadCurrent;
% mLoadCurrent=this.mLoadCurrent;
% t7=(wLoadCurrent.*(loadCurrent-mLoadCurrent)).^2;
% t7=wLoadCurrent.*((loadCurrent-mLoadCurrent)./mLoadCurrent).^2;
output_args=sum(t4)+sum(t5)+sum(t6);
output_args=full(output_args);
end

View File

@@ -3,28 +3,41 @@ function [ output_args ] = obj( this,x )
% Detailed explanation goes here
PDi=this.PDi;
QDi=this.QDi;
PD=x(1:length(PDi));
QD=x(length(PDi)+1:length(PDi)+length(QDi));
wPD=this.wPD;
wQD=this.wQD;
PD0=this.PD0;
QD0=this.QD0;
t4=(wPD(PDi).*(PD-PD0(PDi))).^2;
t5=(wQD(QDi).*(QD-QD0(QDi))).^2;
Volt0=this.Volt0;
SEVolt=x(length(PDi)+length(QDi)+1:length(PDi)+length(QDi)+length(Volt0));
SEVolt=x(1:length(Volt0));
wVolt=this.wVolt;
% wVolt=ones(length(wVolt),1);
t6=(wVolt.*((SEVolt-Volt0))).^2;
Balance=this.Balance;
t6(Balance)=0;%²»¼ÆËãÆ½ºâ½ÚµãµÄ
% µçÁ÷
SEVAngel=x(length(PDi)+length(QDi)+length(SEVolt)+1:end);
loadCurrent=LoadCurrent( SEVolt,SEVAngel,PD0(PDi),QD0(QDi),PDi,QDi );
wLoadCurrent=this.wLoadCurrent;
mLoadCurrent=this.mLoadCurrent;
SEVAngel=x(length(SEVolt)+1:end);
busNum=length(Volt0);
Angel=this.Angel;
r=this.r;
c=this.c;
PG=this.PG;
QG=this.QG;
Y=this.Y;
VMatrix=sparse(r,c,SEVAngel(r)-SEVAngel(c)-Angel,busNum,busNum);
PD_=PG-diag(SEVolt)*(Y.*cos(VMatrix))*SEVolt;
QD_=QG-diag(SEVolt)*(Y.*spfun(@sin,VMatrix))*SEVolt;
t4=(wPD(PDi).*(PD_(PDi)-PD0(PDi))).^2;
t5=(wQD(QDi).*(QD_(QDi)-QD0(QDi))).^2;
% loadCurrent=LoadCurrent( SEVolt,SEVAngel,PD0(PDi),QD0(QDi),PDi,QDi );
% wLoadCurrent=this.wLoadCurrent;
% mLoadCurrent=this.mLoadCurrent;
% t7=(wLoadCurrent.*(loadCurrent-mLoadCurrent)).^2;
t7=wLoadCurrent.*((loadCurrent-mLoadCurrent)./mLoadCurrent).^2;
output_args=sum(t4)+sum(t5)+sum(t6);
% t7=wLoadCurrent.*((loadCurrent-mLoadCurrent)./mLoadCurrent).^2;
% output_args=sum(t4)+sum(t5)+sum(t6);
output_args=sum(t6)+sum(t4)+sum(t5);
output_args=full(output_args);
end