diff --git a/@Opti/equ.m b/@Opti/equ.m index 2e82476..ad1ae8c 100644 --- a/@Opti/equ.m +++ b/@Opti/equ.m @@ -24,7 +24,7 @@ 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)]; -output_args=full(output_args); +output_args=sparse(output_args); this.gle=zeros(length(output_args),1); this.eb=this.gle; end diff --git a/Run_YALMIP.m b/Run_YALMIP.m index 7e6f210..bc392eb 100644 --- a/Run_YALMIP.m +++ b/Run_YALMIP.m @@ -54,46 +54,7 @@ load('QD0'); % QD0=(1+normrnd(0,0.05,length(QD0),1)).*QD0; % save('QD0','QD0'); %% 目标函数 -% Objective=ObjectiveFun(PG,PG0,PGi,QG,QG0,PVi,PD,PD0,QD,QD0,Volt,Volt0,wPG,wQG,wPD,wQD,wVolt,Loadi); -%AngleIJ=sparse(r,c,UAngel(r)-UAngel(c)-Angle,Busnum,Busnum); -%% 赋初值,可以加快求解速度。 -% assign(Volt(:),1); -% assign(UAngel(:),0); -% assign(PD(:),PD0(:)); -% assign(QD(:),QD0(:)); -% %% YALMIP部分 -% dP=PG0-PD-diag(Volt)*Y.*cos( sparse(r,c,UAngel(r)-UAngel(c)-Angle,Busnum,Busnum) )*Volt; -% dQ=QG0-QD-diag(Volt)*Y.*sin( sparse(r,c,UAngel(r)-UAngel(c)-Angle,Busnum,Busnum) )*Volt; -% Loadi=PD0~=0 | QD0~=0 |PG0~=0|QG0~=0; -% Constraints = [%AngleIJ-sparse(r,c,UAngel(r)-UAngel(c)-Angle,Busnum,Busnum)==0, ... -% dP(setdiff(1:Busnum,Loadi))==0, ... -% dQ(setdiff(1:Busnum,Loadi))==0, ... -% % dP==0, ... -% % dQ==0, ... -% PD(PD0==0)==0, ... -% QD(QD0==0)==0, ... -% 0.9*ones(Busnum,1)<=Volt<=1.1*ones(Busnum,1), ... -% Volt(Balance)==BalVolt, ... -% UAngel(Balance)==0, ... -% 0.8*PD0<=PD<=1.2*PD0; -% 0.8*QD0<=QD<=1.2*QD0; -% ]; -% options = sdpsettings('verbose',2,'showprogress',1,'debug',0,'solver','ipopt','usex0','1'); -% sol = solvesdp(Constraints,Objective,options); -% if sol.problem == 0 -% fprintf('Volt\n'); -% dvolt=double(Volt) -% fprintf('VoltAngle\n'); -% dVangle=double(UAngel) -% fprintf('ojb\n'); -% optimalObj=double(Objective) -% sol -% else -% display('Hmm, something went wrong!'); -% sol.info -% sol.solveroutput -% yalmiperror(sol.problem) -% end + %% Opti Toolbox Busnum=length(Volt); PDi=find(PD~=0); @@ -102,7 +63,7 @@ QDi=find(QD~=0); % QD0=QD0(QDi); seOpti=Opti(); seOpti=seOpti.init(Volt0,PDi,QDi,wPD,wQD,PD0,QD0,Y,Angle,r,c,PG,QG,Balance); -opts = optiset('solver','ipopt'); +opts = optiset('solver','filtersd'); opts.maxiter=85500; opts.maxtime=3000; opts.maxfeval=85000;