diff --git a/@Opti/Geteb.m b/@Opti/Getcl.m similarity index 56% rename from @Opti/Geteb.m rename to @Opti/Getcl.m index 244762a..74c80ab 100644 --- a/@Opti/Geteb.m +++ b/@Opti/Getcl.m @@ -1,7 +1,7 @@ -function [ output_args ] = Geteb( this ) +function [ output_args ] = Getcl( this ) %BE Summary of this function goes here % Detailed explanation goes here -output_args=this.eb; +output_args=this.cl; end diff --git a/@Opti/Getgle.m b/@Opti/Getcu.m similarity index 55% rename from @Opti/Getgle.m rename to @Opti/Getcu.m index f12771c..12210da 100644 --- a/@Opti/Getgle.m +++ b/@Opti/Getcu.m @@ -1,7 +1,7 @@ -function [ output_args ] = Getgle( this ) +function [ output_args ] = Getcu( this ) %GLE Summary of this function goes here % Detailed explanation goes here -output_args=this.gle; +output_args=this.cu; end diff --git a/@Opti/Opti.m b/@Opti/Opti.m index ed0fa1a..eeed69b 100644 --- a/@Opti/Opti.m +++ b/@Opti/Opti.m @@ -17,8 +17,8 @@ classdef Opti c=NaN; PG=NaN; QG=NaN; - gle=NaN;%opti toolbox大于小于等于 - eb=NaN;%等式、不等式约束右边的值 + cl=NaN;%opti toolbox大于小于等于 + cu=NaN;%等式、不等式约束右边的值 Balance=NaN; end diff --git a/@Opti/equ.m b/@Opti/equ.m index 2e82476..b0a7ad5 100644 --- a/@Opti/equ.m +++ b/@Opti/equ.m @@ -24,8 +24,11 @@ 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;VAngel(Balance)]; +%% 开始增加不等式约束-电压\PD\QD +%电压不等式约束 + output_args=full(output_args); -this.gle=zeros(length(output_args),1); -this.eb=this.gle; +this.cu=zeros(length(output_args),1); +this.cl=this.cu; end diff --git a/Run_YALMIP.m b/Run_YALMIP.m index 7519747..3d87926 100644 --- a/Run_YALMIP.m +++ b/Run_YALMIP.m @@ -79,9 +79,9 @@ opts.display='iter'; % zeros(length(Volt),1)]; x0=[PD(PDi);QD(QDi);xVolt';xUAngel']; [~,seOpti]=seOpti.equ(x0); -nlrhs=seOpti.Geteb(); -nle=seOpti.Getgle(); -Opt = opti('fun',@seOpti.obj,'ndec',length(Volt)*2+length(PDi)+length(QDi),'nlmix',@seOpti.equ,nlrhs,nle,'options',opts) +cl=seOpti.Getcl(); +cu=seOpti.Getcu(); +Opt = opti('fun',@seOpti.obj,'ndec',length(Volt)*2+length(PDi)+length(QDi),'nl',@seOpti.equ,cl,cu,'options',opts) % Opt = opti('fun',@seOpti.obj,'ndec',length(PDi)+length(QDi),'options',opts) [x,fval,exitflag,info] = solve(Opt,x0); info @@ -96,3 +96,5 @@ fprintf(' PD=x(1:length(PDi)); QD=x(length(PDi)+1:length(PDi)+length(QDi)); MaxDeviation(rVolt,SEVolt,rVAngel,SEVAngel,rPD(PDi),rQD(QDi),PD,QD) +fprintf('统计偏差\n') +StatDeviation(rVolt,SEVolt,rVAngel,SEVAngel,rPD(PDi),rQD(QDi),PD,QD) \ No newline at end of file diff --git a/StatDeviation.asv b/StatDeviation.asv new file mode 100644 index 0000000..c918720 --- /dev/null +++ b/StatDeviation.asv @@ -0,0 +1,16 @@ +function [ output_args ] = StatDeviation( this,PG0,QG0,PD0,QD0 )%统计误差 +%STATDEVIATION Summary of this function goes here +% Detailed explanation goes here +PDArray=PD; +PD0Array=repmat(PD0,1,1); +QD0Array=repmat(QD0,1,1); +PDDev=(PDArray-PD0Array)/0.05; +QDDev=(QDArray-QD0Array)/0.05; +wholeMat=[PDDev;QDDev;]; +t1=wholeMat.^2; +t2=sum(t1,1); +t3=t2/size(t1,1); +t4=t3.^.5; +output_args=sum(t4)/length(t4); +end + diff --git a/StatDeviation.m b/StatDeviation.m index 5e5c442..3f24359 100644 --- a/StatDeviation.m +++ b/StatDeviation.m @@ -1,15 +1,14 @@ -function [ output_args ] = StatDeviation( this,PG0,QG0,PD0,QD0 )%统计误差 +function [ output_args ] = StatDeviation(rVolt,SEVolt,rVAngel,SEVAngel,rPD,rQD,PD,QD)%统计误差 %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; +PDArray=PD; +QDArray=QD; +PD0Array=repmat(rPD,1,1); +QD0Array=repmat(rQD,1,1); +PDDev=(PDArray-PD0Array)/0.05; +QDDev=(QDArray-QD0Array)/0.05; +% VoltDev=(SEVolt-rVolt)/0.05; +% VAngelDev=(SEVAngel-QD0Array)/0.05; wholeMat=[PDDev;QDDev;]; t1=wholeMat.^2; t2=sum(t1,1);