下面为matlab程序 %后的数据为运行程序时需要输入的
%eta=1e-10 pev_max=0.003 MW b=0.01 MW pnev_i_t=zeros(24,24)
function [pev_i_t]=qwe_c(eta,pev_max,b,pnev_i_t)
M=24;
T=24;
pev_i_t=zeros(M,T);
pnev_t=zeros(1,T);
for i=1:1:M
for t=1:1:T
pnev_t(1,t)=sum(pnev_i_t(1:M,t));
pev_i_t(i,:)=qwe_d(eta,pev_max,b,pnev_t(1,:));
pnev_t=pnev_t+pev_i_t(t);
end
end
figure;
T=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
pev_1_t(1,t)=pev_i_t(1,t);
pev_2_t(1,t)=pev_i_t(2,t);
plot(T,pev_1_t,'-',T,pev_2_t,':');
title('phev');
xlabel('time');
ylabel('power');
legend('pev_1_t','pev_2_t');
end
function [pev_t]=qwe_d(eta,pev_max,b,pnev_t)
T=24;
pev_t=zeros(1,T);
alpha_min=min(pnev_t);
alpha_max=max(pnev_t)+pev_max;
while alpha_max-alpha_min>eta
alpha=(alpha_max+alpha_min)/2;
for t=1:1:T
pev_t(t)=qwe_a(alpha-pnev_t(t),pev_max);
end
if sum(pev_t)>b
alpha_max=alpha;
else
if sum(pev_t)<b
alpha_min=alpha;
end
end
end
end
function [re]=qwe_a(x_k,pev_max)
if x_k>pev_max
re=pev_max;
else
if 0<=x_k&&x_k<=pev_max
re=x_k;
else if x_k<0
re=0;
end
end
end
end
%eta=1e-10 pev_max=0.003 MW b=0.01 MW pnev_i_t=zeros(24,24)
function [pev_i_t]=qwe_c(eta,pev_max,b,pnev_i_t)
M=24;
T=24;
pev_i_t=zeros(M,T);
pnev_t=zeros(1,T);
for i=1:1:M
for t=1:1:T
pnev_t(1,t)=sum(pnev_i_t(1:M,t));
pev_i_t(i,:)=qwe_d(eta,pev_max,b,pnev_t(1,:));
pnev_t=pnev_t+pev_i_t(t);
end
end
figure;
T=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24];
pev_1_t(1,t)=pev_i_t(1,t);
pev_2_t(1,t)=pev_i_t(2,t);
plot(T,pev_1_t,'-',T,pev_2_t,':');
title('phev');
xlabel('time');
ylabel('power');
legend('pev_1_t','pev_2_t');
end
function [pev_t]=qwe_d(eta,pev_max,b,pnev_t)
T=24;
pev_t=zeros(1,T);
alpha_min=min(pnev_t);
alpha_max=max(pnev_t)+pev_max;
while alpha_max-alpha_min>eta
alpha=(alpha_max+alpha_min)/2;
for t=1:1:T
pev_t(t)=qwe_a(alpha-pnev_t(t),pev_max);
end
if sum(pev_t)>b
alpha_max=alpha;
else
if sum(pev_t)<b
alpha_min=alpha;
end
end
end
end
function [re]=qwe_a(x_k,pev_max)
if x_k>pev_max
re=pev_max;
else
if 0<=x_k&&x_k<=pev_max
re=x_k;
else if x_k<0
re=0;
end
end
end
end













