不是用电流作为量测量,因为abs可导不好处理。

Signed-off-by: facat <dugg@21cn.com>
This commit is contained in:
facat 2013-04-14 20:33:17 +08:00
parent 32f96a94f0
commit ae2981658e
6 changed files with 75 additions and 46 deletions

View File

@ -1,24 +1,23 @@
classdef SEOpti classdef SEOpti
properties properties
mVolt=0; mVolt=NaN;
mVAngel=0; mBranchI=NaN;
mBranchI=0; mBranchP=NaN;
mBranchP=0; mBranchQ=NaN;
mBranchQ=0; onlyPG=NaN;
onlyPG=0; onlyQG=NaN;
onlyQG=0; PG=NaN;
PG=0; QG=NaN;
QG=0; sigma=NaN;
sigma=0; Busnum=NaN;
Busnum=0; lineI=NaN;
lineI=0; lineJ=NaN;
lineJ=0; lineR=NaN;
lineR=0; lineX=NaN;
lineX=0; lineB2=NaN;
lineB2=0; zerosInjectionIndex=NaN;
zerosInjectionIndex=0; cmpY=NaN;
cmpY=0; Balance=NaN;
Balance=0;
end end
methods methods

View File

@ -5,7 +5,6 @@ SEVolt=x(1:this.Busnum);
SEVAngel=x(this.Busnum+1:2*this.Busnum); SEVAngel=x(this.Busnum+1:2*this.Busnum);
cmpSEV=SEVolt.*exp(1j*SEVAngel); % cmpSEV=SEVolt.*exp(1j*SEVAngel); %
PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV); PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV);
% Constraints=[SEVAngel(Balance)==0,PQ(zerosInjectionIndex)==0];
out_arg=[real(PQ(this.zerosInjectionIndex));imag(PQ(this.zerosInjectionIndex));]; out_arg=[real(PQ(this.zerosInjectionIndex));imag(PQ(this.zerosInjectionIndex));];
out_arg=[out_arg;x(this.Busnum+this.Balance)]; out_arg=[out_arg;x(this.Busnum+this.Balance)];

View File

@ -1,25 +1,24 @@
function [ Objective ] = fun(this, x ) function [ Objective ] = fun(this, x )
%FUN Summary of this function goes here %FUN Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
SEVolt=x(1:this.Busnum); Objective=0;
SEVAngel=x(this.Busnum+1:2*this.Busnum); SEVolt=x(1:this.Busnum);
Objective=(SEVolt-this.mVolt)'*(1./this.sigma^2*eye(length(this.mVolt)))*(SEVolt-this.mVolt);% SEVAngel=x(this.Busnum+1:2*this.Busnum);
%% Objective=(SEVolt-this.mVolt)'*(1./this.sigma^2*eye(length(this.mVolt)))*(SEVolt-this.mVolt);%
cmpSEV=SEVolt.*exp(1j*SEVAngel); % % %%
cmpSEBranchI=(cmpSEV(this.lineI)-cmpSEV(this.lineJ))./(this.lineR+1j*this.lineX);% cmpSEV=SEVolt.*exp(1j*SEVAngel); %
SEBranchI=abs(cmpSEBranchI);% cmpSEBranchI=(cmpSEV(this.lineI)-cmpSEV(this.lineJ))./(this.lineR+1j*this.lineX);%
Objective=Objective+(SEBranchI-this.mBranchI)'*(1./this.sigma^2*eye(length(this.mBranchI)))*(SEBranchI-this.mBranchI);%% % SEBranchI=abs(cmpSEBranchI);%
%% % Objective=Objective+(SEBranchI-this.mBranchI)'*(1./this.sigma^2*eye(length(this.mBranchI)))*(SEBranchI-this.mBranchI);%%
SEBranchP=real((cmpSEV(this.lineI)-cmpSEV(this.lineJ)).*conj(SEBranchI)); %%
SEBranchQ=imag((cmpSEV(this.lineI)-cmpSEV(this.lineJ)).*conj(SEBranchI)); SEBranchP=real((cmpSEV(this.lineI)-cmpSEV(this.lineJ)).*conj(cmpSEBranchI));
Objective=Objective+(SEBranchP-this.mBranchP)'*(1./this.sigma^2*eye(length(this.mBranchP)))*(SEBranchP-this.mBranchP); SEBranchQ=imag((cmpSEV(this.lineI)-cmpSEV(this.lineJ)).*conj(cmpSEBranchI));
Objective=Objective+(SEBranchQ-this.mBranchQ)'*(1./this.sigma^2*eye(length(this.mBranchQ)))*(SEBranchQ-this.mBranchQ); Objective=Objective+(SEBranchP-this.mBranchP)'*(1./this.sigma^2*eye(length(this.mBranchP)))*(SEBranchP-this.mBranchP);
% %% 0 Objective=Objective+(SEBranchQ-this.mBranchQ)'*(1./this.sigma^2*eye(length(this.mBranchQ)))*(SEBranchQ-this.mBranchQ);
PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV); %% 0
% zeroInjP=real(PQ(this.zerosInjectionIndex));%% 0 PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV);
% zeroInjQ=imag(PQ(this.zerosInjectionIndex));%% 0 %%
%% Objective=Objective+(this.PG(this.onlyPG)-real(PQ(this.onlyPG)))'*(1./this.sigma^2*eye(length(this.PG(this.onlyPG))))*(this.PG(this.onlyPG)-real(PQ(this.onlyPG)));
Objective=Objective+(this.PG(this.onlyPG)-real(PQ(this.onlyPG)))'*(1./this.sigma^2*eye(length(this.PG(this.onlyPG))))*(this.PG(this.onlyPG)-real(PQ(this.onlyPG))); Objective=Objective+(this.QG(this.onlyQG)-imag(PQ(this.onlyQG)))'*(1./this.sigma^2*eye(length (this.QG(this.onlyQG))))*(this.QG(this.onlyQG)-imag(PQ(this.onlyQG)));
Objective=Objective+(this.QG(this.onlyQG)-imag(PQ(this.onlyQG)))'*(1./this.sigma^2*eye(length (this.QG(this.onlyQG))))*(this.QG(this.onlyQG)-imag(PQ(this.onlyQG)));
end end

24
@SEOpti/init.asv Normal file
View File

@ -0,0 +1,24 @@
function [ this ] = init(this,Busnum, mVolt,sigma,newwordParameter,zerosInjectionIndex,cmpY,onlyPG,onlyQG,PG,QG,Balance,mBranchI,mBranchP )
%INIT Summary of this function goes here
% Detailed explanation goes here
this.mVolt=mVolt;
this.sigma=sigma;
this.Busnum=Busnum;
this.lineI=newwordParameter.line.lineI;
this.lineJ=newwordParameter.line.lineJ;
this.lineR=newwordParameter.line.lineR;
this.lineX=newwordParameter.line.lineX;
this.lineB2=newwordParameter.line;
this.zerosInjectionIndex=zerosInjectionIndex;
this.cmpY=cmpY;
this.onlyPG=onlyPG;
this.onlyQG=onlyQG;
this.PG=PG;
this.QG=QG;
this.Balance=Balance;
this.mBranchI=mBranchI;
this.mBranchP=mBranchP;
this.mBranchQ=mBranchQ;
end

View File

@ -1,4 +1,4 @@
function [ this ] = init(this,Busnum, mVolt,sigma,newwordParameter,zerosInjectionIndex,cmpY,onlyPG,onlyQG,PG,QG,Balance ) function [ this ] = init(this,Busnum, mVolt,sigma,newwordParameter,zerosInjectionIndex,cmpY,onlyPG,onlyQG,PG,QG,Balance,mBranchI,mBranchP,mBranchQ )
%INIT Summary of this function goes here %INIT Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
this.mVolt=mVolt; this.mVolt=mVolt;
@ -16,6 +16,9 @@ function [ this ] = init(this,Busnum, mVolt,sigma,newwordParameter,zerosInjectio
this.PG=PG; this.PG=PG;
this.QG=QG; this.QG=QG;
this.Balance=Balance; this.Balance=Balance;
this.mBranchI=mBranchI;
this.mBranchP=mBranchP;
this.mBranchQ=mBranchQ;
end end

15
run.m
View File

@ -10,7 +10,7 @@ addpath('.\Powerflow')
% %
%% %%
%% %%
sigma=0.05;% ±ê×¼²î sigma=0.0005;% ±ê×¼²î
%% %%
% %
rVolt=Volt; % rVolt=Volt; %
@ -53,7 +53,7 @@ mPG=rPG.*(normrnd(0,sigma,length(rPG),1)+1);
mQG=rQG.*(normrnd(0,sigma,length(rQG),1)+1); mQG=rQG.*(normrnd(0,sigma,length(rQG),1)+1);
%% %%
stateVarCount=2*length(Volt); stateVarCount=2*length(Volt);
measurements=length(mVolt)+length(mI)+length(mBranchI)+length(mBranchP)+length(mBranchQ)+length(mPG)+length(mQG); measurements=length(mVolt)+length(mBranchP)+length(mBranchQ)+length(mPG)+length(mQG);
fprintf(' %f\n',measurements/stateVarCount); fprintf(' %f\n',measurements/stateVarCount);
%% %%
% SEVolt=sdpvar(length(Volt),1,'full'); % SEVolt=sdpvar(length(Volt),1,'full');
@ -95,12 +95,17 @@ onlyQG=setdiff(QGi,PDQDi);
%% Opti ToolBox %% Opti ToolBox
Busnum=length(Volt); Busnum=length(Volt);
seOpti=SEOpti(); seOpti=SEOpti();
seOpti=seOpti.init(Busnum, mVolt,sigma,newwordParameter,zerosInjectionIndex,cmpY ,onlyPG,onlyQG,PG,QG,Balance); seOpti=seOpti.init(Busnum, mVolt,sigma,newwordParameter,zerosInjectionIndex,cmpY,onlyPG,onlyQG,PG,QG,Balance,rBranchI,mBranchP,mBranchQ );
nlrhs=seOpti.nlrhs(); nlrhs=seOpti.nlrhs();
nle=seOpti.nle(); nle=seOpti.nle();
Opt = opti('fun',@seOpti.fun,'ndec',length(Volt)*2,'nlmix',@seOpti.equ,nlrhs,nle) opts = optiset('solver','ipopt');
x0=ones(Busnum*2,1); opts.maxiter=2500;
opts.display='iter';
% Opt = opti('fun',@seOpti.fun,'ndec',length(Volt)*2,'nlmix',@seOpti.equ,nlrhs,nle,'options',opts)
Opt = opti('fun',@seOpti.fun,'ndec',length(Volt)*2,'options',opts)
x0=[ones(Busnum,1);zeros(Busnum,1)];
[x,fval,exitflag,info] = solve(Opt,x0); [x,fval,exitflag,info] = solve(Opt,x0);
info
%% %%
SEVolt=x(1:length(Volt)); SEVolt=x(1:length(Volt));
SEVAngel=x(length(Volt)+Balance:2*length(Volt)); SEVAngel=x(length(Volt)+Balance:2*length(Volt));