遗传算法(Genetic Algorithm, GA)优化后的RBF(Radial Basis Function)神经网络是一种结合进化算法与神经网络的混合模型,用于改进RBF神经网络的性能。以下是该模型的基本原理和相关公式:
clear all
close allG = 15;
Size = 30;
CodeL = 10;for i = 1:3MinX(i) = 0.1*ones(1);MaxX(i) = 3*ones(1);
end
for i = 4:1:9MinX(i) = -3*ones(1);MaxX(i) = 3*ones(1);
end
for i = 10:1:12MinX(i) = -ones(1);MaxX(i) = ones(1);
endE = round(rand(Size,12*CodeL)); %Initial Code!BsJ = 0;for kg = 1:1:Gtime(kg) = kgfor s = 1:1:Sizem = E(s,:);for j = 1:1:12y(j) = 0;mj = m((j-1)*CodeL + 1:1:j*CodeL);for i = 1:1:CodeLy(j) = y(j) + mj(i)*2^(i-1);endf(s,j) = (MaxX(j) - MinX(j))*y(j)/1023 + MinX(j);end% ************Step 1:Evaluate BestJ *******************p = f(s,:);[p,BsJ] = RBF(p,BsJ);BsJi(s) = BsJ;end[OderJi,IndexJi] = sort(BsJi);BestJ(kg) = OderJi(1);BJ = BestJ(kg);Ji = BsJi+1e-10;fi = 1./Ji;[Oderfi,Indexfi] = sort(fi);Bestfi = Oderfi(Size);BestS = E(Indexfi(Size),:);% ***************Step 2:Select and Reproduct Operation*********fi_sum = sum(fi);fi_Size = (Oderfi/fi_sum)*Size;fi_S = floor(fi_Size);kk = 1;for i = 1:1:Sizefor j = 1:1:fi_S(i)TempE(kk,:) = E(Indexfi(i),:);kk = kk + 1;endend% ****************Step 3:Crossover Operation*******************pc = 0.60;n = ceil(20*rand);for i = 1:2:(Size - 1)temp = rand;if pc>tempfor j = n:1:20TempE(i,j) = E(i+1,j);TempE(i+1,j) = E(i,j);endendendTempE(Size,:) = BestS;E = TempE;%*****************Step 4:Mutation Operation*********************pm = 0.001 - [1:1:Size]*(0.001)/Size;for i = 1:1:Sizefor j = 1:1:12*CodeLtemp = rand;if pm>tempif TempE(i,j) == 0TempE(i,j) = 1;elseTempE(i,j) = 0;endendendend%Guarantee TempE(Size,:) belong to the best individualTempE(Size,:) = BestS;E = TempE;%********************************************************************endBestfiBestSfiBest_J = BestJ(G)figure(1);plot(time,BestJ);xlabel('Times');ylabel('BestJ');save pfile p;