www.gusucode.com > matlab编程遗传算法计算匹配电路源码程序 > code1/code/MATLAB源代码/matlab_match/recombin_electric_parameter.m
function NewChrom = recombin_electric_parameter(OldChrom,num_integer,Pc_max,Pc_min,gen,MAXGEN) %recombin_electric_parameter 用于电气参数的中间重组 % Pc_max为重组率的最大值,Pc_min为重组率的最小值,num_integer为结构的总数,gen+11为当前正在进化的代数 Pc=Pc_max+(Pc_min-Pc_max)*(gen+1)/MAXGEN; [Nind,Lind]=size(OldChrom); NewChrom=OldChrom; Xops = floor(Nind/2); odd = 1:2:Nind-1; even= 2:2:Nind; Alpha = -0.25 + 1.5 * rand(Xops,Lind-num_integer); Alpha=Alpha.*(rand(Xops,Lind-num_integer)<Pc); NewChrom(odd,num_integer+1:Lind) = OldChrom(odd,num_integer+1:Lind) + Alpha .* (OldChrom(even,num_integer+1:Lind) - OldChrom(odd,num_integer+1:Lind)); Alpha = -0.25 + 1.5 * rand(Xops,Lind-num_integer); Alpha=Alpha.*(rand(Xops,Lind-num_integer)<Pc); NewChrom(even,num_integer+1:Lind) = OldChrom(even,num_integer+1:Lind) + Alpha .* (OldChrom(odd,num_integer+1:Lind) - OldChrom(even,num_integer+1:Lind)); end