2008暑假A第二次競賽題(劉圓,范興容,張偉) - 圖文 - 下載本文

-0.0008 -0.003 0 -0.0001 -0.0001 -0.0002 -0.0002 -0.0002 -0.0002 -0.0003 -0.0003 -0.0003 -0.0003 -0.0003 -0.0004 -0.0003 -0.0003 -0.0005 -0.0006 -0.0005 -0.0004 -0.0004 -0.0003 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 0.1249 0.1029 0.1028 -0.0042 0.1253 0.0065

0.11 0.1119 0.1092 0.1052 0.1045 0.1088 0.1104 0.096 0.096 0.096 0.1116 0.1131 0.1207 0.1231 0.1509 0.1175 0.1271 0.1719 0.2158 0.1857 0.1638 0.1389 0.098 0.083 0.0945 0.09 0.1065 0.1094 0.1126 0.0799 0.1137 0.1085 0.0469 -0.0944 -0.0848 -0.0875 -0.0718 -0.0093 -0.0633 -0.0584 -0.0545 -0.0436 -0.073 -0.0417 -0.0302 -0.022 -0.0166 -0.0186 -0.0177 -0.0168 -0.0158 -0.0155 -0.0148 -0.0143 -0.0141 -0.0142 -0.0153 -0.0151 -0.0114 -0.0104 -0.0102 -0.0105 -0.0101 -0.0095 -0.0077 -0.0119 -0.0113 -0.0046 0 0.0202 0.0256 0.0531 0.0256 0.0115 0.0089 0.0055 0.0007 0.0005 0.0002 -0.0008 -0.0033 0 0 -0.0001 -0.0001 -0.0001 -0.0001 -0.0002 -0.0003 -0.0003 -0.0003 -0.0003 -0.0003 -0.0004 -0.0003 -0.0003 -0.0005 -0.0007 -0.0005 -0.0004 -0.0004 -0.0003 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 -0.0004 0.1247 0.1077 0.1075 -0.0046 0.1131 0.0073

0.514 0.5093 0.516 0.5256 0.5275 0.517 0.513 0.5486 0.5486 0.5486 0.5097 0.5064 0.4863 0.4802 0.4081 0.4979 0.4796 0.4305 0.3826 0.3865 0.3893 0.3925 0.3978 0.3367 0.4675 0.5047 0.4507 0.453 0.4555 0.5885 0.4563 0.4443 0.1992 -0.0253 -0.0313 -0.0296 -0.0393 -0.1646 -0.0382 -0.0376 -0.0371 -0.0357 -0.0269 -0.0292 -0.03 -0.0295 -0.0273 -0.0318 -0.0325 -0.0334 -0.0345 -0.0348 -0.0355 -0.0361 -0.0363 -0.0362 -0.035 -0.0352 -0.0392 -0.0403 -0.0405 -0.0401 -0.0406 -0.0413 -0.0433 -0.0387 -0.0394 -0.0266 0 0.0813 0.1033 0.2151 0.1033 0.0456 0.0346 0.0201 -0.0007 -0.0016 -0.0032 -0.008 -0.02 -0.004 -0.0042 -0.0046 -0.0048 -0.0048 -0.0048 -0.0052 -0.0054 -0.0055 -0.0055 -0.0056 -0.0057 -0.0058 -0.0057 -0.0056 -0.0068 -0.0073 -0.0068 -0.0063 -0.006 -0.0058 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 -0.0063 0.475 0.447 0.4475 -0.0266 0.5064 0.0278

0.2547 0.255 0.2546 0.2539 0.2538 0.2545 0.2548 0.2525 0.2525 0.2525 0.2548 0.2552 0.2552 0.2556 0.2567 0.2584 0.2653 0.2627 0.2601 0.3001 0.3291 0.3622 0.4165 -0.494 0.3489 0.3185 0.3409 0.3323 0.3227 0.25 0.3194 0.3435 0.2227 0.1848 0.1844 0.1845 0.1839 0.1829 0.1653 0.1546 0.1461 0.1225 0.1511 0.1018 0.0837 0.0696 0.0583 0.0666 0.0658 0.0651 0.0643 0.0641 0.0636 0.0632 0.063 0.0631 0.0639 0.0638 0.0608 0.06 0.0599 0.0602 0.0598 0.0593 0.0579 0.0612 0.0607 0.0353 0 -0.1196 -0.1519 -0.3156 -0.1519 -0.0674 -0.0514 -0.0306 -0.0006 0.0006 0.0029 0.0095 0.0262 0.0039 0.0043 0.0048 0.0051 0.0051 0.0051 0.0056 0.0059 0.006 0.0061 0.0063 0.0064 0.0065 0.0064 0.0062 0.0078 0.0086 0.0078 0.0072 0.0068 0.0064 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.0072 0.2754 0.3424 0.3422 0.0353 0.2552 -0.0416]; %系統備用要求

bei_power = [50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 發電機組的分段成本和 for i = 1:54

35

result(i, 1) = load0(i) + cp(i, 1) * rp(i, 1);

result(i, 2) = cp(i, 2) * (rp(i, 2) - rp(i, 1)) + result(i, 1); result(i, 3) = cp(i, 3) * (rp(i, 3) - rp(i, 2)) + result(i, 2); result(i, 4) = cp(i, 4) * (rp(i, 4) - rp(i, 3)) + result(i, 3); result(i, 5) = cp(i, 5) * (rp(i, 5) - rp(i, 4)) + result(i, 4); end

% 橫坐標 發電機組的發電量 xdata=[zeros(54,1),rp]; % 總坐標 發電機組的成本 ydata=[load0,result]; for i = 1:54 % 二次擬合系數

factor(i, 1:3) = polyfit(xdata(i,1:6),ydata(i,1:6),2); end

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

% n為機組總數,T為第幾時段 n = 54; T = 24;

%生成隨機數矩陣 n*T for i = 1:n for t = 1:T

r(i, t) = unifrnd(0, P_MAX(i)); end end

%計算百分比系數數組 for t = 1:T

R(t) = sum(r(1:n,t)); end for i = 1:n for t = 1:T

PER(i, t) = r(i, t)/R(t); end end

%初始化各臺發電機組的發電量 %l 負載數 l = 90;

% 列求和 各時段負載總和 for t = 1:T

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

36

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 for k = 1:T

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

% 記錄最小花費的成本值 Tc0 = Tc;

%mark = round(c2);%對結果四舍五入取整 mark = c2; %為最優發電機組啟停計劃 %break;

37

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); end end if Tc < Tc0

% 記錄最小花費的成本值 Tc0 = Tc;

%mark = round(c2);%對結果四舍五入取整 mark = c2; %為最優發電機組啟停計劃 %break; end

% 記錄所有發電機組發電成本值

38

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; end end end

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

%調整列中的元素取值,使其滿足發電機組的增出力和降出力約束 % 第一列特殊處理 for i = 1:n

if c1(i, 1) > ini_power(i) + PCMAX(i) c2(i, 1) = ini_power(i) + PCMAX(i);

39





陕西11选5五位走势图 2011年上证指数走势图 甘肃快3一定牛 百度 历史广西快乐十分开奖 北京快三查询 重庆快乐十分开奖走势图 百度 十一运夺金预测彩经网 云计算概念 福建快3三不同遗漏 河南快三走势图一定牛排五 分分彩是不是官方开奖