华企号 企业信息化 含电热联合系统的微电网运行优化附Matlab代码

含电热联合系统的微电网运行优化附Matlab代码

⛄ 内容介绍
在当前能源互联网迅速发展及电热联系日渐紧密的环境下,提出基于电热联合调度的区域并网型微电网运行优化模型.综合网内储能特性,分时电价,电热负荷与分布式电源的时序特征,以包含风机,光伏电池,热电联产系统,电锅炉,燃料电池和储能系统的并网型微电网为例,采用Cplex优化软件求得调度周期内各微电源最佳出力及总运行成本,并与两种常见电热调度方式进行比较.仿真算例表明:联合调度模型能实现电热统一协调调度并降低微电网运行成本.该模型可为电热之间能源互联及规划运营提供参考.

⛄ 部分代码
function f = initialize_variables(N, M, V, min_range, max_range, time, Zall, ComC0)

 

min = min_range;

max = max_range;

 

% K is the total number of array elements. For ease of computation decision

% variables and objective functions are concatenated to form a single

% array. For crossover and mutation only the decision variables are used

% while for selection, only the objective variable are utilized.

number_of_decision_variables.c =  V(1,1);

number_of_decision_variables.t =  V(2,1);

K = M + 2 * V(1,1) + 2 * V(2,1);

StepComC = 1; %变量的离散化

StepT1 = 0.025;

StepT2 = 0.025;

%% Initialize each chromosome

% For each chromosome perform the following (N is the population size)

for i = 1 : N

for j= 1 : number_of_decision_variables.c

f(i,j) = min.c(j,1) + (max.c(j,1) – min.c(j,1))*rand(1);

f(i,j + number_of_decision_variables.c) = min.c(j,2) + (max.c(j,2) – min.c(j,2))*rand(1);

%f(i,j)离散化

ComCC(j)= f(i,j);

ComCC1(j) = abs(ComCC(j)) / StepComC;

%Tap1 = Tap ./ StepTap;

ComCC2(j) = fix(ComCC1(j)); %商

ComCC3(j) = abs(ComCC(j)) – ComCC2(j) * StepComC;%余

ComCC2(j) =  ComCC2(j) *  StepComC;

%Tap = Tap1 – fix(Tap1);

if ComCC3(j) > (StepComC / 2)

ComCC3(j) = StepComC – ComCC3(j);

ComCC2(j) = ComCC2(j) + StepComC;

end

if f(i,j)>0

f(i,j) = ComCC2(j);

else

f(i,j) = – ComCC2(j);

end

%检验f(i,j)中无重复

pf(1,:) = f(i,1:number_of_decision_variables.c);

for w = 1 : number_of_decision_variables.c

for ww =  (w + 1) : number_of_decision_variables.c

while f(i,w) == pf(1,ww)

f(i,w) = min.c(j,1) + (max.c(j,1) – min.c(j,1))*rand(1);

ComCC(j)= f(i,w);

ComCC1(j) = abs(ComCC(j)) / StepComC;

%Tap1 = Tap ./ StepTap;

ComCC2(j) = fix(ComCC1(j)); %商

ComCC3(j) = abs(ComCC(j)) – ComCC2(j) * StepComC;%余

ComCC2(j) =  ComCC2(j) *  StepComC;

%Tap = Tap1 – fix(Tap1);

if ComCC3(j) > (StepComC / 2)

ComCC3(j) = StepComC – ComCC3(j);

ComCC2(j) = ComCC2(j) + StepComC;

end

if f(i,w)>0

f(i,w) = ComCC2(j);

else

f(i,w) = – ComCC2(j);

end

end

end

end

%f(i,j + number_of_decision_variables)离散化

ComCC(j)= f(i,j + number_of_decision_variables.c);

ComCC1(j) = abs(ComCC(j)) / StepComC;

%Tap1 = Tap ./ StepTap;

ComCC2(j) = fix(ComCC1(j)); %商

ComCC3(j) = abs(ComCC(j)) – ComCC2(j) * StepComC;%余

ComCC2(j) =  ComCC2(j) *  StepComC;

%Tap = Tap1 – fix(Tap1);

if ComCC3(j) > (StepComC / 2)

ComCC3(j) = StepComC – ComCC3(j);

ComCC2(j) = ComCC2(j) + StepComC;

end

if f(i,j + number_of_decision_variables.c)>0

f(i,j + number_of_decision_variables.c) = ComCC2(j);

else

f(i,j + number_of_decision_variables.c) = – ComCC2(j);

end

end

 

for j= 1 : number_of_decision_variables.t

f(i,j + 2 * V(1,1)) = min.t(j,1) + (max.t(j,1) – min.t(j,1))*rand(1);

f(i,j + 2 * V(1,1) + number_of_decision_variables.t) = min.t(j,2) + (max.t(j,2) – min.t(j,2))*rand(1);

%f(i,j)离散化

ComCC(j)= f(i,j + 2 * V(1,1));

ComCC1(j) = abs(ComCC(j)) / StepT1;

%Tap1 = Tap ./ StepTap;

ComCC2(j) = fix(ComCC1(j)); %商

ComCC3(j) = abs(ComCC(j)) – ComCC2(j) * StepT1;%余

ComCC2(j) =  ComCC2(j) *  StepT1;

%Tap = Tap1 – fix(Tap1);

if ComCC3(j) > (StepT1 / 2)

ComCC3(j) = StepT1 – ComCC3(j);

ComCC2(j) = ComCC2(j) + StepT1;

end

if f(i,j)>0

f(i,j + 2 * V(1,1)) = ComCC2(j);

else

f(i,j + 2 * V(1,1)) = – ComCC2(j);

end

%f(i,j + 2 * V(1,1) + number_of_decision_variables)离散化

ComCC(j)= f(i,j + 2 * V(1,1) + number_of_decision_variables.t);

ComCC1(j) = abs(ComCC(j)) / StepT2;

%Tap1 = Tap ./ StepTap;

ComCC2(j) = fix(ComCC1(j)); %商

ComCC3(j) = abs(ComCC(j)) – ComCC2(j) * StepT2;%余

ComCC2(j) =  ComCC2(j) *  StepT2;

%Tap = Tap1 – fix(Tap1);

if ComCC3(j) > (StepT2 / 2)

ComCC3(j) = StepT2 – ComCC3(j);

ComCC2(j) = ComCC2(j) + StepT2;

end

if f(i,j + 2 * V(1,1) + number_of_decision_variables.t)>0

f(i,j + 2 * V(1,1) + number_of_decision_variables.t) = ComCC2(j);

else

f(i,j + 2 * V(1,1) + number_of_decision_variables.t) = – ComCC2(j);

end

end

f(i, 2 * V(1,1) + 2 * V(2,1) + 1 : K) = evaluate_objective(f(i,:),M ,V ,time, Zall, ComC0);

end

 

⛄ 运行结果

 

 

作者: 华企网通李铁牛程序员

我是程序员李铁牛,热爱互联网软件开发和设计,专注于大数据、数据分析、数据库、php、java、python、scala、k8s、docker等知识总结。15889726201 我的座右铭:"业精于勤荒于嬉,行成于思毁于随"
上一篇
下一篇

发表回复

联系我们

联系我们

028-84868647

在线咨询: QQ交谈

邮箱: tech@68v8.com

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部