不是用电流作为量测量,因为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
properties
mVolt=0;
mVAngel=0;
mBranchI=0;
mBranchP=0;
mBranchQ=0;
onlyPG=0;
onlyQG=0;
PG=0;
QG=0;
sigma=0;
Busnum=0;
lineI=0;
lineJ=0;
lineR=0;
lineX=0;
lineB2=0;
zerosInjectionIndex=0;
cmpY=0;
Balance=0;
mVolt=NaN;
mBranchI=NaN;
mBranchP=NaN;
mBranchQ=NaN;
onlyPG=NaN;
onlyQG=NaN;
PG=NaN;
QG=NaN;
sigma=NaN;
Busnum=NaN;
lineI=NaN;
lineJ=NaN;
lineR=NaN;
lineX=NaN;
lineB2=NaN;
zerosInjectionIndex=NaN;
cmpY=NaN;
Balance=NaN;
end
methods

View File

@ -5,7 +5,6 @@ SEVolt=x(1:this.Busnum);
SEVAngel=x(this.Busnum+1:2*this.Busnum);
cmpSEV=SEVolt.*exp(1j*SEVAngel); %
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=[out_arg;x(this.Busnum+this.Balance)];

View File

@ -1,25 +1,24 @@
function [ Objective ] = fun(this, x )
%FUN Summary of this function goes here
% Detailed explanation goes here
SEVolt=x(1:this.Busnum);
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);%
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));
Objective=Objective+(SEBranchP-this.mBranchP)'*(1./this.sigma^2*eye(length(this.mBranchP)))*(SEBranchP-this.mBranchP);
Objective=Objective+(SEBranchQ-this.mBranchQ)'*(1./this.sigma^2*eye(length(this.mBranchQ)))*(SEBranchQ-this.mBranchQ);
% %% 0
PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV);
% zeroInjP=real(PQ(this.zerosInjectionIndex));%% 0
% 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.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=0;
SEVolt=x(1:this.Busnum);
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);%
% 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(cmpSEBranchI));
SEBranchQ=imag((cmpSEV(this.lineI)-cmpSEV(this.lineJ)).*conj(cmpSEBranchI));
Objective=Objective+(SEBranchP-this.mBranchP)'*(1./this.sigma^2*eye(length(this.mBranchP)))*(SEBranchP-this.mBranchP);
Objective=Objective+(SEBranchQ-this.mBranchQ)'*(1./this.sigma^2*eye(length(this.mBranchQ)))*(SEBranchQ-this.mBranchQ);
%% 0
PQ=diag(cmpSEV)*conj(this.cmpY*cmpSEV);
%%
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)));
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
% Detailed explanation goes here
this.mVolt=mVolt;
@ -16,6 +16,9 @@ function [ this ] = init(this,Busnum, mVolt,sigma,newwordParameter,zerosInjectio
this.PG=PG;
this.QG=QG;
this.Balance=Balance;
this.mBranchI=mBranchI;
this.mBranchP=mBranchP;
this.mBranchQ=mBranchQ;
end

15
run.m
View File

@ -10,7 +10,7 @@ addpath('.\Powerflow')
%
%%
%%
sigma=0.05;% ±ê×¼²î
sigma=0.0005;% ±ê×¼²î
%%
%
rVolt=Volt; %
@ -53,7 +53,7 @@ mPG=rPG.*(normrnd(0,sigma,length(rPG),1)+1);
mQG=rQG.*(normrnd(0,sigma,length(rQG),1)+1);
%%
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);
%%
% SEVolt=sdpvar(length(Volt),1,'full');
@ -95,12 +95,17 @@ onlyQG=setdiff(QGi,PDQDi);
%% Opti ToolBox
Busnum=length(Volt);
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();
nle=seOpti.nle();
Opt = opti('fun',@seOpti.fun,'ndec',length(Volt)*2,'nlmix',@seOpti.equ,nlrhs,nle)
x0=ones(Busnum*2,1);
opts = optiset('solver','ipopt');
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);
info
%%
SEVolt=x(1:length(Volt));
SEVAngel=x(length(Volt)+Balance:2*length(Volt));