本程序代码参考EI期刊论文《考虑电动汽车可调度潜力的充电站两阶段市场投标策略》,程序中基于历史数据评估可调度潜力,由联合报价模型确定节点边际电价,作为报价的参考,包含个体竞价模式,纳什博弈竞价,算例丰富,注释清晰,干货满满!下面对程序代码和文章进行简要介绍!
运行平台:MATLAB+Cplex+Yalmip;或者:MATLAB+Gurobi+Yalmip;
有很多公证号介绍了该程序代码,差别从运行平台开始,懂得都懂!
使用两种求解器对模型进行求解,均可以得到良好效果!
在电力市场环境下,充电站优化投标策略能降低电力成本,甚至通过售电获取收益。文中考虑了电动汽车成为柔性储荷资源的潜力,提出了日前电力市场和实时电力市场下充电站的投标策略。首先,基于闵可夫斯基加法提出了充电站内电动汽车集群模型的压缩方法,并建立了日前可调度潜力预测模型和实时可调度潜力评估模型。同时,考虑充电站间的非合作博弈,建立了电力零售市场下充电站的策略投标模型,并基于驻点法将其转化为一个广义Nash均衡问题。然后,提出了基于日前报价和实时报量的两阶段市场交易模式,并与合作投标模式、价格接受模式和集中调度模式进行对比。最后,基于一个38节点配电系统进行了仿真。仿真结果表明所提出的可调度潜力计算方法能够将电动汽车集群封装为广义储能设备,从而降低了模型的维度。基于可调度潜力的策略投标模型能够挖掘电动汽车的储荷潜力,实现电动汽车与电网的有序互动。
算例共分为7节,限于篇幅,介绍前3节内容。
第一节算例结果:
第二节算例结果:
第三节算例结果:
介绍到这里,您看出和其他相关介绍的区别了吗?
部分代码:
% %% 第七节,日前可调度潜力预测算法对比
% %算法1:个体
% clear
% clc
% close all
% load data_EV
% X_CS1=data_CS1.X;X_CS2=data_CS2.X;X_CS3=data_CS3.X;X_CS4=data_CS4.X;
% S0_CS1=data_CS1.S0;S0_CS2=data_CS2.S0;S0_CS3=data_CS3.S0;S0_CS4=data_CS4.S0;
% m1=length(S0_CS1);m2=length(S0_CS2);m3=length(S0_CS3);m4=length(S0_CS4);
% %充电站投标问题
% pch_CS1=sdpvar(m1,24);pdis_CS1=sdpvar(m1,24);%电动汽车个体的充放电功率
% pch_CS2=sdpvar(m2,24);pdis_CS2=sdpvar(m2,24);
% pch_CS3=sdpvar(m3,24);pdis_CS3=sdpvar(m3,24);
% pch_CS4=sdpvar(m4,24);pdis_CS4=sdpvar(m4,24);
% s_CS1=sdpvar(m1,24);s_CS2=sdpvar(m2,24);s_CS3=sdpvar(m3,24);s_CS4=sdpvar(m4,24);%电动汽车个体的SOC
% Pch=sdpvar(4,24);%充电站充电功率
% Pdis=sdpvar(4,24);%充电站放电功率
% Ccs=[Pch(1,:)==sum(pch_CS1),Pch(2,:)==sum(pch_CS2),Pch(3,:)==sum(pch_CS3),Pch(4,:)==sum(pch_CS4),
% Pdis(1,:)==sum(pdis_CS1),Pdis(2,:)==sum(pdis_CS2),Pdis(3,:)==sum(pdis_CS3),Pdis(4,:)==sum(pdis_CS4),
% 0<=pch_CS1<=6.6*X_CS1,0<=pch_CS2<=6.6*X_CS2,0<=pch_CS3<=6.6*X_CS3,0<=pch_CS4<=6.6*X_CS4,
% 0<=pdis_CS1<=6.6*X_CS1,0<=pdis_CS2<=6.6*X_CS2,0<=pdis_CS3<=6.6*X_CS3,0<=pdis_CS4<=6.6*X_CS4,
% s_CS1(:,1)==S0_CS1'+0.95*pch_CS1(:,1)-pdis_CS1(:,1)/0.95,
% s_CS2(:,1)==S0_CS2'+0.95*pch_CS2(:,1)-pdis_CS2(:,1)/0.95,
% s_CS3(:,1)==S0_CS3'+0.95*pch_CS3(:,1)-pdis_CS3(:,1)/0.95,
% s_CS4(:,1)==S0_CS4'+0.95*pch_CS4(:,1)-pdis_CS4(:,1)/0.95,
% s_CS1(:,2:24)==s_CS1(:,1:23)+0.95*pch_CS1(:,2:24)-pdis_CS1(:,2:24)/0.95,
% s_CS2(:,2:24)==s_CS2(:,1:23)+0.95*pch_CS2(:,2:24)-pdis_CS2(:,2:24)/0.95,
% s_CS3(:,2:24)==s_CS3(:,1:23)+0.95*pch_CS3(:,2:24)-pdis_CS3(:,2:24)/0.95,
% s_CS4(:,2:24)==s_CS4(:,1:23)+0.95*pch_CS4(:,2:24)-pdis_CS4(:,2:24)/0.95,
% 32*0.15<=s_CS1<=32*0.9,32*0.15<=s_CS2<=32*0.9,32*0.15<=s_CS3<=32*0.9,32*0.15<=s_CS4<=32*0.9
% sum(0.95*pch_CS1-pdis_CS1/0.95,2)==32*0.9-S0_CS1',
% sum(0.95*pch_CS2-pdis_CS2/0.95,2)==32*0.9-S0_CS2',
% sum(0.95*pch_CS3-pdis_CS3/0.95,2)==32*0.9-S0_CS3',
% sum(0.95*pch_CS4-pdis_CS4/0.95,2)==32*0.9-S0_CS4'
% ];%约束条件
% % %市场出清问题
% Loadcurve=[0.955391944564747,0.978345604157644,1,0.995019488956258,0.972932005197055,0.970333477695972,0.930489389346037,0.890428757037679,0.902771762667822,0.941966219142486,0.911000433087917,0.862061498484192,0.840190558683413,0.831095712429623,0.756604590731919,0.671719359029883,0.611520138588133,0.582936336076224,0.572542226071893,0.574707665656128,0.587267215244695,0.644218276310091,0.755521870939801,0.884798614118666];
% PL_base=[5.704;5.705;5.631;6.518;4.890;5.705;5.847]*1000;%负荷分布
% PL=PL_base*Loadcurve;%基础负荷
% Pf=sdpvar(7,24);%馈线功率
% Pf(1,:)=PL(1,:)+Pch(1,:)-Pdis(1,:);Pf(2,:)=PL(2,:);Pf(3,:)=PL(3,:);Pf(4,:)=PL(4,:)+Pch(2,:)-Pdis(2,:);Pf(5,:)=PL(5,:)+Pch(3,:)-Pdis(3,:);Pf(6,:)=PL(6,:);Pf(7,:)=PL(7,:)+Pch(4,:)-Pdis(4,:);%馈线功率组成
% Pf_limit=1000*[40,40,40,40,40,40,40]';%馈线功率限制
% Pg=sdpvar(10,24);%发电商分段电量
% Pg_step=1000*[20,5,3,2,2,2,2,2,2,100]';%报价区间
% Price_DSO=[3:12]'*0.1;%分段电价
% Lagrant_G_left=sdpvar(10,24);%发电商电量下界
% Lagrant_G_right=sdpvar(10,24);%发电商电量上界
% b_Lagrant_G_left=binvar(10,24);%发电商电量下界布尔变量
% b_Lagrant_G_right=binvar(10,24);%发电商电量上界布尔变量
% Lagrant_L_left=sdpvar(7,24);%线路功率下界
% Lagrant_L_right=sdpvar(7,24);%线路功率上界
% b_Lagrant_L_left=binvar(7,24);%线路功率上界布尔变量
% b_Lagrant_L_right=binvar(7,24);%线路功率下界布尔变量
% Lagrant_G=sdpvar(1,24);%平衡节点电价
% DLMP=sdpvar(7,24);%DLMP
% Ckkt=[sum(Pg)==sum(Pf),
% 0<=Pg<=Pg_step*ones(1,24),
% Price_DSO*ones(1,24)-Lagrant_G_left+Lagrant_G_right-ones(10,1)*Lagrant_G==0,
% DLMP==ones(7,1)*Lagrant_G+Lagrant_L_right-Lagrant_L_left,
% Pg<=1E6*b_Lagrant_G_left,0<=Lagrant_G_left<=(1-b_Lagrant_G_left),
% Pg_step*ones(1,24)-Pg<=1E6*b_Lagrant_G_right,0<=Lagrant_G_right<=(1-b_Lagrant_G_right),
% -Pf_limit*ones(1,24)<=Pf<=Pf_limit*ones(1,24),
% Pf+Pf_limit*ones(1,24)<=1E6*b_Lagrant_L_left,0<=Lagrant_L_left<=(1-b_Lagrant_L_left),
% -Pf+Pf_limit*ones(1,24)<=1E6*b_Lagrant_L_right,0<=Lagrant_L_right<=(1-b_Lagrant_L_right)];%市场出清问题的KKT条件
% Obj=sum(sum((Price_DSO*ones(1,24)).*Pg))-sum(sum(DLMP.*PL))+sum(sum((Pg_step*ones(1,24)).*Lagrant_G_right))+sum(sum((Lagrant_L_left+Lagrant_L_right).*(Pf_limit*ones(1,24))));
% %求解问题
% C=[Ccs,Ckkt];%约束条件
% ops=sdpsettings('solver','cplex');
% result=solvesdp(C,Obj,ops);
% DLMP=double(DLMP);
% Lagrant_G=double(Lagrant_G);
% Pf=double(Pf);
% Pch=double(Pch);
% Pdis=double(Pdis);
% Pg=double(Pg);
% %实时调度
% load data_RT_potential
% load result_order
% Pch1=RT_CS1(96).Pch;Pdis1=RT_CS1(96).Pdis;Smin1=RT_CS1(96).Smin;Smax1=RT_CS1(96).Smax;dS1=RT_CS1(96).dS;%取最后一个时刻的可调度潜力
% Pch2=RT_CS2(96).Pch;Pdis2=RT_CS2(96).Pdis;Smin2=RT_CS2(96).Smin;Smax2=RT_CS2(96).Smax;dS2=RT_CS2(96).dS;
% Pch3=RT_CS3(96).Pch;Pdis3=RT_CS3(96).Pdis;Smin3=RT_CS3(96).Smin;Smax3=RT_CS3(96).Smax;dS3=RT_CS3(96).dS;
% Pch4=RT_CS4(96).Pch;Pdis4=RT_CS4(96).Pdis;Smin4=RT_CS4(96).Smin;Smax4=RT_CS4(96).Smax;dS4=RT_CS4(96).dS;
% Pchmax=[Pch1;Pch2;Pch3;Pch4];
% Pdismax=[Pdis1;Pdis2;Pdis3;Pdis4];
% Smin=[Smin1;Smin2;Smin3;Smin4];
% Smax=[Smax1;Smax2;Smax3;Smax4];
% dS=[dS1;dS2;dS3;dS4];
% Link=zeros(24,96);%时段换算矩阵(日前1h换算为实时15min)
% for i=1:24
% Link(i,4*i-3:4*i)=1;
% end
% DA_Ps=Pch-Pdis;%日前调度数据
% DA_Ps=DA_Ps*Link;%时段换算
% DA_Pf=Pf*Link;%日前总功率
% %充电站投标问题
% Pch=sdpvar(4,96);%充电站充电功率
% Pdis=sdpvar(4,96);%充电站放电功率
% S=sdpvar(4,96);%充电站广义储能SOC
% Ccs=[0<=Pch<=Pchmax,0<=Pdis<=Pdismax,Smin<=S<=Smax,S(:,1)==0.95*0.25*Pch(:,1)-0.25*Pdis(:,1)/0.95+dS(:,1),S(:,2:96)==S(:,1:95)+0.25*0.95*Pch(:,2:96)-0.25*Pdis(:,2:96)/0.95+dS(:,2:96)];%约束条件
% % %市场出清问题
% Loadcurve=[0.955391944564747,0.978345604157644,1,0.995019488956258,0.972932005197055,0.970333477695972,0.930489389346037,0.890428757037679,0.902771762667822,0.941966219142486,0.911000433087917,0.862061498484192,0.840190558683413,0.831095712429623,0.756604590731919,0.671719359029883,0.611520138588133,0.582936336076224,0.572542226071893,0.574707665656128,0.587267215244695,0.644218276310091,0.755521870939801,0.884798614118666];
% Loadcurve=Loadcurve*Link;%换成96个时段
% PL_base=[5.704;5.705;5.631;6.518;4.890;5.705;5.847]*1000;%负荷分布
% PL=PL_base*Loadcurve;%基础负荷
% Pf=sdpvar(7,96);%馈线功率
% Pf(1,:)=PL(1,:)+Pch(1,:)-Pdis(1,:);Pf(2,:)=PL(2,:);Pf(3,:)=PL(3,:);Pf(4,:)=PL(4,:)+Pch(2,:)-Pdis(2,:);Pf(5,:)=PL(5,:)+Pch(3,:)-Pdis(3,:);Pf(6,:)=PL(6,:);Pf(7,:)=PL(7,:)+Pch(4,:)-Pdis(4,:);%馈线功率组成
% Pf_limit=1000*[40,40,40,40,40,40,40]';%馈线功率限制
% Pg=sdpvar(10,96);%发电商分段电量
% Pg_step=1000*[20,5,3,2,2,2,2,2,2,100]';%报价区间
% Price_DSO=[3:12]'*0.1;%分段电价
% Lagrant_G_left=sdpvar(10,96);%发电商电量下界
% Lagrant_G_right=sdpvar(10,96);%发电商电量上界
% b_Lagrant_G_left=binvar(10,96);%发电商电量下界布尔变量
% b_Lagrant_G_right=binvar(10,96);%发电商电量上界布尔变量
% Lagrant_L_left=sdpvar(7,96);%线路功率下界
% Lagrant_L_right=sdpvar(7,96);%线路功率上界
% b_Lagrant_L_left=binvar(7,96);%线路功率上界布尔变量
% b_Lagrant_L_right=binvar(7,96);%线路功率下界布尔变量
% Lagrant_G=sdpvar(1,96);%平衡节点电价
% DLMP=sdpvar(7,96);%DLMP
% Ckkt=[sum(Pg)==sum(Pf),
% 0<=Pg<=Pg_step*ones(1,96),
% 0.25*Price_DSO*ones(1,96)-Lagrant_G_left+Lagrant_G_right-ones(10,1)*Lagrant_G==0,
% DLMP==ones(7,1)*Lagrant_G+Lagrant_L_right-Lagrant_L_left,
% Pg<=1E6*b_Lagrant_G_left,0<=Lagrant_G_left<=(1-b_Lagrant_G_left),
% Pg_step*ones(1,96)-Pg<=1E6*b_Lagrant_G_right,0<=Lagrant_G_right<=(1-b_Lagrant_G_right),
% -Pf_limit*ones(1,96)<=Pf<=Pf_limit*ones(1,96),
% Pf+Pf_limit*ones(1,96)<=1E6*b_Lagrant_L_left,0<=Lagrant_L_left<=(1-b_Lagrant_L_left),
% -Pf+Pf_limit*ones(1,96)<=1E6*b_Lagrant_L_right,0<=Lagrant_L_right<=(1-b_Lagrant_L_right)];%市场出清问题的KKT条件
% Obj=0.25*sum(sum((Price_DSO*ones(1,96)).*Pg))-sum(sum(DLMP.*PL))+sum(sum((Pg_step*ones(1,96)).*Lagrant_G_right))+sum(sum((Lagrant_L_left+Lagrant_L_right).*(Pf_limit*ones(1,96))))+0.1*0.25*sum(sum(abs(Pch-Pdis-DA_Ps)));
% %求解问题
% C=[Ccs,Ckkt];%约束条件
% result=solvesdp(C,Obj);
% DLMP=double(DLMP);
% Lagrant_G=double(Lagrant_G);
% Pf=double(Pf);
% Pch=double(Pch);
% Pdis=double(Pdis);
% Pg=double(Pg);
% S=double(S);
% double(Obj)
% figure(1)%实时日前结果对比
% hold on
% plot(sum(Pf),'r.-')
% plot(sum(DA_Pf),'b--');
% Cost=sum(sum((Pf-PL).*DLMP));%总用电费用
% Cost_b=sum(sum(((Pf-PL)>0).*(Pf-PL).*DLMP))%总购电费用
% Cost_s=-sum(sum(((Pf-PL)<0).*(Pf-PL).*DLMP))%总售电收入
% Cost_r=0.1*0.25*sum(sum(abs(Pch-Pdis-DA_Ps)))%平衡费用
% MAPE=100*sum(abs((sum(DA_Pf)-sum(Pf))./sum(DA_Pf))/96);%平均百分误差
% %% 第七节,日前可调度潜力预测算法对比
% %算法2:群体
% clear
% clc
% close all
% load data_EV
% X_CS1=data_CS1.X;X_CS2=data_CS2.X;X_CS3=data_CS3.X;X_CS4=data_CS4.X;
% S0_CS1=data_CS1.S0;S0_CS2=data_CS2.S0;S0_CS3=data_CS3.S0;S0_CS4=data_CS4.S0;
% m1=length(S0_CS1);m2=length(S0_CS2);m3=length(S0_CS3);m4=length(S0_CS4);
% X=[sum(X_CS1);sum(X_CS2);sum(X_CS3);sum(X_CS4)];
% Energy=[32*0.9*m1-sum(S0_CS1);32*0.9*m2-sum(S0_CS2);32*0.9*m3-sum(S0_CS3);32*0.9*m4-sum(S0_CS4)];
% %充电站投标问题
% Pch=sdpvar(4,24);%充电站充电功率
% Pdis=sdpvar(4,24);%充电站放电功率
% Ccs=[0<=Pch<=6.6*X,
% 0<=Pdis<=6.6*X,
% sum(Pch-Pdis,2)==Energy
% ];%约束条件
% % %市场出清问题
% Loadcurve=[0.955391944564747,0.978345604157644,1,0.995019488956258,0.972932005197055,0.970333477695972,0.930489389346037,0.890428757037679,0.902771762667822,0.941966219142486,0.911000433087917,0.862061498484192,0.840190558683413,0.831095712429623,0.756604590731919,0.671719359029883,0.611520138588133,0.582936336076224,0.572542226071893,0.574707665656128,0.587267215244695,0.644218276310091,0.755521870939801,0.884798614118666];
% PL_base=[5.704;5.705;5.631;6.518;4.890;5.705;5.847]*1000;%负荷分布
% PL=PL_base*Loadcurve;%基础负荷
% Pf=sdpvar(7,24);%馈线功率
% Pf(1,:)=PL(1,:)+Pch(1,:)-Pdis(1,:);Pf(2,:)=PL(2,:);Pf(3,:)=PL(3,:);Pf(4,:)=PL(4,:)+Pch(2,:)-Pdis(2,:);Pf(5,:)=PL(5,:)+Pch(3,:)-Pdis(3,:);Pf(6,:)=PL(6,:);Pf(7,:)=PL(7,:)+Pch(4,:)-Pdis(4,:);%馈线功率组成
% Pf_limit=1000*[40,40,40,40,40,40,40]';%馈线功率限制
% Pg=sdpvar(10,24);%发电商分段电量
% Pg_step=1000*[20,5,3,2,2,2,2,2,2,100]';%报价区间
% Price_DSO=[3:12]'*0.1;%分段电价
% Lagrant_G_left=sdpvar(10,24);%发电商电量下界
% Lagrant_G_right=sdpvar(10,24);%发电商电量上界
% b_Lagrant_G_left=binvar(10,24);%发电商电量下界布尔变量
% b_Lagrant_G_right=binvar(10,24);%发电商电量上界布尔变量
% Lagrant_L_left=sdpvar(7,24);%线路功率下界
% Lagrant_L_right=sdpvar(7,24);%线路功率上界
% b_Lagrant_L_left=binvar(7,24);%线路功率上界布尔变量
% b_Lagrant_L_right=binvar(7,24);%线路功率下界布尔变量
% Lagrant_G=sdpvar(1,24);%平衡节点电价
% DLMP=sdpvar(7,24);%DLMP
% Ckkt=[sum(Pg)==sum(Pf),
% 0<=Pg<=Pg_step*ones(1,24),
% Price_DSO*ones(1,24)-Lagrant_G_left+Lagrant_G_right-ones(10,1)*Lagrant_G==0,
% DLMP==ones(7,1)*Lagrant_G+Lagrant_L_right-Lagrant_L_left,
% Pg<=1E6*b_Lagrant_G_left,0<=Lagrant_G_left<=(1-b_Lagrant_G_left),
% Pg_step*ones(1,24)-Pg<=1E6*b_Lagrant_G_right,0<=Lagrant_G_right<=(1-b_Lagrant_G_right),
% -Pf_limit*ones(1,24)<=Pf<=Pf_limit*ones(1,24),
% Pf+Pf_limit*ones(1,24)<=1E6*b_Lagrant_L_left,0<=Lagrant_L_left<=(1-b_Lagrant_L_left),
% -Pf+Pf_limit*ones(1,24)<=1E6*b_Lagrant_L_right,0<=Lagrant_L_right<=(1-b_Lagrant_L_right)];%市场出清问题的KKT条件
% Obj=sum(sum((Price_DSO*ones(1,24)).*Pg))-sum(sum(DLMP.*PL))+sum(sum((Pg_step*ones(1,24)).*Lagrant_G_right))+sum(sum((Lagrant_L_left+Lagrant_L_right).*(Pf_limit*ones(1,24))));
% %求解问题
% C=[Ccs,Ckkt];%约束条件
% ops=sdpsettings('solver','cplex');
% result=solvesdp(C,Obj,ops);
% DLMP=double(DLMP);
% Lagrant_G=double(Lagrant_G);
% Pf=double(Pf);
% Pch=double(Pch);
% Pdis=double(Pdis);
% Pg=double(Pg);
% %实时调度
% load data_RT_potential
% load result_order
% Pch1=RT_CS1(96).Pch;Pdis1=RT_CS1(96).Pdis;Smin1=RT_CS1(96).Smin;Smax1=RT_CS1(96).Smax;dS1=RT_CS1(96).dS;%取最后一个时刻的可调度潜力
% Pch2=RT_CS2(96).Pch;Pdis2=RT_CS2(96).Pdis;Smin2=RT_CS2(96).Smin;Smax2=RT_CS2(96).Smax;dS2=RT_CS2(96).dS;
% Pch3=RT_CS3(96).Pch;Pdis3=RT_CS3(96).Pdis;Smin3=RT_CS3(96).Smin;Smax3=RT_CS3(96).Smax;dS3=RT_CS3(96).dS;
% Pch4=RT_CS4(96).Pch;Pdis4=RT_CS4(96).Pdis;Smin4=RT_CS4(96).Smin;Smax4=RT_CS4(96).Smax;dS4=RT_CS4(96).dS;
% Pchmax=[Pch1;Pch2;Pch3;Pch4];
% Pdismax=[Pdis1;Pdis2;Pdis3;Pdis4];
% Smin=[Smin1;Smin2;Smin3;Smin4];
% Smax=[Smax1;Smax2;Smax3;Smax4];
% dS=[dS1;dS2;dS3;dS4];
% Link=zeros(24,96);%时段换算矩阵(日前1h换算为实时15min)
% for i=1:24
% Link(i,4*i-3:4*i)=1;
% end
% DA_Ps=Pch-Pdis;%日前调度数据
% DA_Ps=DA_Ps*Link;%时段换算
% DA_Pf=Pf*Link;%日前总功率
% %充电站投标问题
% Pch=sdpvar(4,96);%充电站充电功率
% Pdis=sdpvar(4,96);%充电站放电功率
% S=sdpvar(4,96);%充电站广义储能SOC
% Ccs=[0<=Pch<=Pchmax,0<=Pdis<=Pdismax,Smin<=S<=Smax,S(:,1)==0.95*0.25*Pch(:,1)-0.25*Pdis(:,1)/0.95+dS(:,1),S(:,2:96)==S(:,1:95)+0.25*0.95*Pch(:,2:96)-0.25*Pdis(:,2:96)/0.95+dS(:,2:96)];%约束条件
% % %市场出清问题
% Loadcurve=[0.955391944564747,0.978345604157644,1,0.995019488956258,0.972932005197055,0.970333477695972,0.930489389346037,0.890428757037679,0.902771762667822,0.941966219142486,0.911000433087917,0.862061498484192,0.840190558683413,0.831095712429623,0.756604590731919,0.671719359029883,0.611520138588133,0.582936336076224,0.572542226071893,0.574707665656128,0.587267215244695,0.644218276310091,0.755521870939801,0.884798614118666];
% Loadcurve=Loadcurve*Link;%换成96个时段
% PL_base=[5.704;5.705;5.631;6.518;4.890;5.705;5.847]*1000;%负荷分布
% PL=PL_base*Loadcurve;%基础负荷
% Pf=sdpvar(7,96);%馈线功率
% Pf(1,:)=PL(1,:)+Pch(1,:)-Pdis(1,:);Pf(2,:)=PL(2,:);Pf(3,:)=PL(3,:);Pf(4,:)=PL(4,:)+Pch(2,:)-Pdis(2,:);Pf(5,:)=PL(5,:)+Pch(3,:)-Pdis(3,:);Pf(6,:)=PL(6,:);Pf(7,:)=PL(7,:)+Pch(4,:)-Pdis(4,:);%馈线功率组成
% Pf_limit=1000*[40,40,40,40,40,40,40]';%馈线功率限制
% Pg=sdpvar(10,96);%发电商分段电量
% Pg_step=1000*[20,5,3,2,2,2,2,2,2,100]';%报价区间
% Price_DSO=[3:12]'*0.1;%分段电价
% Lagrant_G_left=sdpvar(10,96);%发电商电量下界
% Lagrant_G_right=sdpvar(10,96);%发电商电量上界
% b_Lagrant_G_left=binvar(10,96);%发电商电量下界布尔变量
% b_Lagrant_G_right=binvar(10,96);%发电商电量上界布尔变量
% Lagrant_L_left=sdpvar(7,96);%线路功率下界
% Lagrant_L_right=sdpvar(7,96);%线路功率上界
% b_Lagrant_L_left=binvar(7,96);%线路功率上界布尔变量
% b_Lagrant_L_right=binvar(7,96);%线路功率下界布尔变量
% Lagrant_G=sdpvar(1,96);%平衡节点电价
% DLMP=sdpvar(7,96);%DLMP
% Ckkt=[sum(Pg)==sum(Pf),
% 0<=Pg<=Pg_step*ones(1,96),
% 0.25*Price_DSO*ones(1,96)-Lagrant_G_left+Lagrant_G_right-ones(10,1)*Lagrant_G==0,
% DLMP==ones(7,1)*Lagrant_G+Lagrant_L_right-Lagrant_L_left,
% Pg<=1E6*b_Lagrant_G_left,0<=Lagrant_G_left<=(1-b_Lagrant_G_left),
% Pg_step*ones(1,96)-Pg<=1E6*b_Lagrant_G_right,0<=Lagrant_G_right<=(1-b_Lagrant_G_right),
% -Pf_limit*ones(1,96)<=Pf<=Pf_limit*ones(1,96),
% Pf+Pf_limit*ones(1,96)<=1E6*b_Lagrant_L_left,0<=Lagrant_L_left<=(1-b_Lagrant_L_left),
% -Pf+Pf_limit*ones(1,96)<=1E6*b_Lagrant_L_right,0<=Lagrant_L_right<=(1-b_Lagrant_L_right)];%市场出清问题的KKT条件
% Obj=0.25*sum(sum((Price_DSO*ones(1,96)).*Pg))-sum(sum(DLMP.*PL))+sum(sum((Pg_step*ones(1,96)).*Lagrant_G_right))+sum(sum((Lagrant_L_left+Lagrant_L_right).*(Pf_limit*ones(1,96))))+0.1*0.25*sum(sum(abs(Pch-Pdis-DA_Ps)));
% %求解问题
% C=[Ccs,Ckkt];%约束条件
% result=solvesdp(C,Obj);
% DLMP=double(DLMP);
% Lagrant_G=double(Lagrant_G);
% Pf=double(Pf);
% Pch=double(Pch);
% Pdis=double(Pdis);
% Pg=double(Pg);
% S=double(S);
% double(Obj)
% figure(1)%实时日前结果对比
% hold on
% plot(sum(Pf),'r.-')
% plot(sum(DA_Pf),'b--');
% Cost=sum(sum((Pf-PL).*DLMP));%总用电费用
% Cost_b=sum(sum(((Pf-PL)>0).*(Pf-PL).*DLMP))%总购电费用
% Cost_s=-sum(sum(((Pf-PL)<0).*(Pf-PL).*DLMP))%总售电收入
% Cost_r=0.1*0.25*sum(sum(abs(Pch-Pdis-DA_Ps)))%平衡费用
% MAPE=100*sum(abs((sum(DA_Pf)-sum(Pf))./sum(DA_Pf))/96);%平均百分误差
以上就是本次介绍的主要内容,欢迎关注下方公众号获取完整版代码,小编会继续推送更有质量的学习资料、文章和程序代码,为您的科研加油助力!