0001 function [gencost, genfuel, gentype] = sg_gen_cost(PgMax, cost_model, Tab_2D_gcost)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 Ng=length(PgMax);
0027
0028 PgMax_norm = PgMax;
0029 MAX_PgMax = max(PgMax(:,2));
0030 PgMax_norm (:,2) = PgMax_norm (:,2)./MAX_PgMax;
0031
0032 [Corr_type,Type_setting]=Assignment(PgMax_norm,Tab_2D_gcost);
0033
0034 Type_setting(:,2)= Type_setting(:,2).*MAX_PgMax;
0035 gentype = cell(Ng,1);
0036 genfuel = cell(Ng,1);
0037 gencost = zeros(Ng,4);
0038 if cost_model == 2
0039 gencost(:,1) = 2;
0040 gencost(:,4) = 3;
0041 for it = 1:Ng
0042 if Type_setting(it,3) == 1
0043 gentype{it} = 'HY';
0044 genfuel{it} = 'hydro';
0045 gencost (it,5:7) = 0;
0046 elseif Type_setting(it,3) == 2
0047 gentype{it} = 'W2';
0048 genfuel{it} = 'wind';
0049 gencost (it,5:7) = 0;
0050 elseif Type_setting(it,3) == 3
0051 gentype{it} = 'GT';
0052 genfuel{it} = 'ng';
0053 if Type_setting(it,2) <=400
0054 gencost (it,7) = 0 + 600*rand;
0055 else
0056 gencost (it,7) = 600 + 3259*rand;
0057 end
0058 gencost (it,6) = 23.13 + 33.9*rand;
0059 gencost (it,5) = 0.002 + 0.006*rand;
0060 elseif Type_setting(it,3) == 4
0061 gentype{it} = 'ST';
0062 genfuel{it} = 'coal';
0063 if Type_setting(it,2) <=75
0064 gencost (it,7) = 0 + 238*rand;
0065 elseif Type_setting(it,2) > 75 && Type_setting(it,2) <=150
0066 gencost (it,7) = 238 + 507*rand;
0067 elseif Type_setting(it,2) > 150 && Type_setting(it,2) <=350
0068 gencost (it,7) = 745 + 468*rand;
0069 else
0070 gencost (it,7) = 1213 + 1830*rand;
0071 end
0072 gencost (it,6) = 19;
0073 gencost (it,5) = 0.001;
0074 elseif Type_setting(it,3) == 5
0075 gentype{it} = 'NB';
0076 genfuel{it} = 'nuclear';
0077 gencost (it,7) = 1000 + 500*rand;
0078 gencost (it,6) = 5 + 6*rand;
0079 gencost (it,5) = 0.00015 + 0.00008*rand;
0080
0081 end
0082 end
0083 elseif cost_model == 1
0084 gencost(:,1) = 2;
0085 gencost(:,4) = 2;
0086 for it = 1:Ng
0087 if Type_setting(it,3) == 1
0088 gentype{it} = 'HY';
0089 genfuel{it} = 'hydro';
0090 gencost (it,5:6) = 0;
0091 elseif Type_setting(it,3) == 2
0092 gentype{it} = 'W2';
0093 genfuel{it} = 'wind';
0094 gencost (it,5:6) = 0;
0095 elseif Type_setting(it,3) == 3
0096 gentype{it} = 'GT';
0097 genfuel{it} = 'ng';
0098 if Type_setting(it,2) <=400
0099 gencost (it,6) = 0 + 600*rand;
0100 else
0101 gencost (it,6) = 600 + 3259*rand;
0102 end
0103 gencost (it,5) = 2.59.*(6.5 + rand*11);
0104 elseif Type_setting(it,3) == 4
0105 gentype{it} = 'ST';
0106 genfuel{it} = 'coal';
0107 if Type_setting(it,2) <=75
0108 gencost (it,6) = 0 + 238*rand;
0109 elseif Type_setting(it,2) > 75 && Type_setting(it,2) <=150
0110 gencost (it,6) = 238 + 507*rand;
0111 elseif Type_setting(it,2) > 150 && Type_setting(it,2) <=350
0112 gencost (it,6) = 745 + 468*rand;
0113 else
0114 gencost (it,6) = 1213 + 1830*rand;
0115 end
0116 gencost (it,5) = 2.16.*(9.43 + rand*9.1);
0117 elseif Type_setting(it,3) == 5
0118 gentype{it} = 'NB';
0119 genfuel{it} = 'nuclear';
0120 gencost (it,6) = 1000 + 500*rand;
0121 gencost (it,5) = 0.85.*10.46;
0122 end
0123 end
0124 end
0125
0126
0127 function [Corr_co,Type_setting]=Assignment(PgMax_norm,Tab_2D)
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138 Ng=length(PgMax_norm);
0139
0140
0141 Tab_2D_Ng=round(Tab_2D.*Ng);
0142
0143
0144 if sum(sum(Tab_2D_Ng))<Ng
0145 [Max_tab,ind_max_tab]=max(Tab_2D_Ng(:));
0146 [I_row, I_col] = ind2sub(size(Tab_2D_Ng),ind_max_tab);
0147 Tab_2D_Ng(I_row,I_col)=Tab_2D_Ng(I_row,I_col)+(Ng-sum(sum(Tab_2D_Ng)));
0148 elseif sum(sum(Tab_2D_Ng))>Ng
0149 [Max_tab,ind_max_tab]=max(Tab_2D_Ng(:));
0150 [I_row, I_col] = ind2sub(size(Tab_2D_Ng),ind_max_tab);
0151 Tab_2D_Ng(I_row,I_col)=Tab_2D_Ng(I_row,I_col)-(sum(sum(Tab_2D_Ng))-Ng);
0152 end
0153
0154 N_PgM= zeros(1,14);
0155 N_PgM = sum(Tab_2D_Ng,1);
0156
0157
0158 Sort_PgMax=sortrows(PgMax_norm,2);
0159
0160 PgM1=Sort_PgMax(1:N_PgM(1,1),:);
0161 Sort_PgMax(1:N_PgM(1,1),:)=[];
0162
0163 PgM2=Sort_PgMax(1:N_PgM(1,2),:);
0164 Sort_PgMax(1:N_PgM(1,2),:)=[];
0165
0166 PgM3=Sort_PgMax(1:N_PgM(1,3),:);
0167 Sort_PgMax(1:N_PgM(1,3),:)=[];
0168
0169 PgM4=Sort_PgMax(1:N_PgM(1,4),:);
0170 Sort_PgMax(1:N_PgM(1,4),:)=[];
0171
0172 PgM5=Sort_PgMax(1:N_PgM(1,5),:);
0173 Sort_PgMax(1:N_PgM(1,5),:)=[];
0174
0175 PgM6=Sort_PgMax(1:N_PgM(1,6),:);
0176 Sort_PgMax(1:N_PgM(1,6),:)=[];
0177
0178 PgM7=Sort_PgMax(1:N_PgM(1,7),:);
0179 Sort_PgMax(1:N_PgM(1,7),:)=[];
0180
0181 PgM8=Sort_PgMax(1:N_PgM(1,8),:);
0182 Sort_PgMax(1:N_PgM(1,8),:)=[];
0183
0184 PgM9=Sort_PgMax(1:N_PgM(1,9),:);
0185 Sort_PgMax(1:N_PgM(1,9),:)=[];
0186
0187 PgM10=Sort_PgMax(1:N_PgM(1,10),:);
0188 Sort_PgMax(1:N_PgM(1,10),:)=[];
0189
0190 PgM11=Sort_PgMax(1:N_PgM(1,11),:);
0191 Sort_PgMax(1:N_PgM(1,11),:)=[];
0192
0193 PgM12=Sort_PgMax(1:N_PgM(1,12),:);
0194 Sort_PgMax(1:N_PgM(1,12),:)=[];
0195
0196 PgM13=Sort_PgMax(1:N_PgM(1,13),:);
0197 Sort_PgMax(1:N_PgM(1,13),:)=[];
0198
0199 PgM14=Sort_PgMax(1:N_PgM(1,14),:);
0200 Sort_PgMax(1:N_PgM(1,14),:)=[];
0201
0202
0203 N_T=zeros(1,5);
0204 N_T = sum(Tab_2D_Ng,2)';
0205
0206
0207
0208
0209
0210
0211
0212
0213 K_cell=cell(1,14);
0214 K_cell{1}=PgM1; K_cell{2}=PgM2; K_cell{3}=PgM3; K_cell{4}=PgM4; K_cell{5}=PgM5; K_cell{6}=PgM6; K_cell{7}=PgM7;
0215 K_cell{8}=PgM8; K_cell{9}=PgM9; K_cell{10}=PgM10; K_cell{11}=PgM11; K_cell{12}=PgM12; K_cell{13}=PgM13; K_cell{14}=PgM14;
0216
0217 Type_gen =[];
0218 for pgm=1:14
0219 for tt=1:1:5
0220 if Tab_2D_Ng(tt,pgm)>0
0221 [samp_G,ind_G]=sg_datasample(K_cell{pgm},Tab_2D_Ng(tt,pgm),'replace',false);
0222 K_cell{pgm}(ind_G,3)=tt;
0223 Type_gen = [Type_gen;K_cell{pgm}(ind_G,:)];
0224 K_cell{pgm}(ind_G,:)=[];
0225 end
0226 end
0227 end
0228 Type_setting=sortrows(Type_gen,1);
0229 Corr_co=corr(Type_setting(:,2),Type_setting(:,3));
0230 end
0231 end