好文档 - 专业文书写作范文服务资料分享网站

2008数学建模论文大全(优秀)好的东西值得下载 - 图文

天下 分享 时间: 加入收藏 我要投稿 点赞

end

%初始化各台发电机组的发电量 %l 负载数 l = 90;

% 列求和 各时段负载总和 for t = 1:T

L(t) = sum(load(1:l, t)); end for i = 1:n for t = 1:T

c(i, t) = PER(i, t) * L(t); end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 种群中个体数量 N个 N = 200;

for i = 1:N % 适度函数

[Fit(i),C] = fitness(c, P_MAX, P_MIN, PCMAX, PDMAX, ini_power, bei_power, start_money, factor, min_s_time, min_r_time, ini_time, L); % 种群样本 for j=1:n for k=1:T

C1(i,j,k) = C(j,k); end end end

[C3] = yichuan(Fit, C1);

% 遗传迭代

G=50; % 遗传迭代次数G % 最小花费总成本,初始设为2500000 Tc0=2500000; % 遗传迭代G代数 for l = 1 :G for i = 1:N

C4(1:n,1:T) = C3(i,1:n,1:T);

[Fitness(i),c2,Tc] = fitness(C4(1:n,1:T), P_MAX, P_MIN, PCMAX, PDMAX, ini_power, bei_power, start_money, factor, min_s_time, min_r_time, ini_time, L); for j = 1:n

30

for k = 1:T

C3(i,j,k) = c2(j,k); end end if Tc < Tc0

% 记录最小花费的成本值 Tc0 = Tc;

%mark = round(c2);%对结果四舍五入取整 mark = c2; %为最优发电机组启停计划 %break; end

% 记录所有发电机组发电成本值 Tc0(l) = Tc; end

[C5] = yichuan(Fitness, C3); C3 = C5; end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %迭代G代后的运行结果图: g=1:50;

plot(g,log10(Tc0+0.01),'o') %发电机组发电总成本F取对数,加上0.01避免初值Tc0=0时取对数无意义 %plot(g,Tc0,'o') %发电机组发电总成本F grid on

xlabel('迭代次数');ylabel('发电机组发电总成本F(取对数)'); title('迭代50次的运行结果');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2.2 遗传算法核心,用于进行样本的遗传操作:选择-复制、交叉、变异 [C3] = yichuan(Fit, C1);

% 遗传迭代

G=50; % 遗传迭代次数G

% 最小花费总成本,初始设为2500000 Tc0=2500000; % 遗传迭代G代数 for l = 1 :G for i = 1:N

C4(1:n,1:T) = C3(i,1:n,1:T);

[Fitness(i),c2,Tc] = fitness(C4(1:n,1:T), P_MAX, P_MIN, PCMAX, PDMAX, ini_power, bei_power, start_money, factor, min_s_time, min_r_time, ini_time, L); for j = 1:n for k = 1:T

C3(i,j,k) = c2(j,k);

31

end end if Tc < Tc0

% 记录最小花费的成本值 Tc0 = Tc;

%mark = round(c2);%对结果四舍五入取整 mark = c2; %为最优发电机组启停计划 %break; end

% 记录所有发电机组发电成本值 Tc0(l) = Tc; end

[C5] = yichuan(Fitness, C3); C3 = C5; end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %迭代G代后的运行结果图: g=1:50;plot(g,log10(Tc0+eps),'o') grid on

xlabel('迭代次数');ylabel('发电机组发电总成本F(取对数)'); title('迭代50次的运行结果');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2.3 计算适度值,并且使生成的样本满足各种约束 % 遗传种群初始化,并返回适应度等大小

function [Fitness,c2,Tc] = fitness(c, P_MAX, P_MIN, PCMAX, PDMAX, ini_power, bei_power, start_money, factor, min_s_time, min_r_time, ini_time, L)

% n为机组总数,T为第几时段 n = 54; T = 24;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %调整列中的元素取值,使其满足发电机组出力范围约束 for i = 1:n for t = 1:T

if c(i, t) > P_MAX(i) c1(i, t) = P_MAX(i); elseif c(i, t) >= P_MIN(i) c1(i, t) = c(i,t); elseif c(i, t) >= 0.6*P_MIN(i) c1(i, t) = P_MIN(i); else

c1(i, t) = 0;

32

end end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%调整列中的元素取值,使其满足发电机组的增出力和降出力约束 % 第一列特殊处理 for i = 1:n

if c1(i, 1) > ini_power(i) + PCMAX(i) c2(i, 1) = ini_power(i) + PCMAX(i); elseif c1(i, 1) < ini_power(i) - PDMAX(i) c2(i, 1) = ini_power(i) - PDMAX(i); else

c2(i, 1) = c1(i, 1); end end % 第二至T列 for i = 1:n for t = 2:T

if c1(i, t) > c1(i, t-1) + PCMAX(i) c2(i, t) = c1(i, t-1) + PCMAX(i); elseif c1(i, t) < c1(i, t-1) - PDMAX(i) c2(i, t) = c1(i, t-1) - PDMAX(i); else

c2(i, t) = c1(i, t-1); end end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 创建机组0-1状态矩阵 for i = 1:n for t = 1:T if c2(i, t) > 0 u(i, t) = 1; else

u(i, t) = 0; end end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 调整列中的元素取值,使其满足系统备用约束 for t = 1:T

33

for i = 1:n

temp(i) = u(i,t)*(P_MAX(i) - c2(i, t)); end

if sum(temp) < bei_power(t) for i=1:n if u(i,t) == 0

c2(i, t) = c2(i, t) + 4*(bei_power(t) - sum(temp))/(n); % c2(i,t) = P_MIN(i); % sort 优化 % if sum(temp) >= bei_power(t) % break; % end end end end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 调整列中的元素取值,使其满足机组启动时和停运时的出力约束 for i = 1:n

if ini_power(i) > 0 temp1(i) = 1; else

temp1(i) = 0; end end

for i = 1:n

if u(i, 1) == 1 && temp1(i) == 0 || u(i, 1) == 1 && u(i, 2) == 0 c2(i, 1) = P_MIN(i); end

if u(i, T) == 0 && u(i, T- 1) == 1 c2(i, T) = P_MIN(i); end end

for i = 1:n for t = 2:T-1

if u(i, t-1) == 0 && u(i, t) == 1 || u(i, t) == 1 && u(i, t+1) == 0 c2(i, t) = P_MIN(i); end end end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

34

2008数学建模论文大全(优秀)好的东西值得下载 - 图文

end%初始化各台发电机组的发电量%l负载数l=90;%列求和各时段负载总和fort=1:TL(t)=sum(load(1:l,t));endfori=1:nfort=1:Tc(i,t)=PER(i,t)
推荐度:
点击下载文档文档为doc格式
3295l1fvgm9d31q9oedn
领取福利

微信扫码领取福利

微信扫码分享