nondominated-sort(P) 任意Pop中的个体p,np=0,Sp为空 //初始化 for p in Pop for q in Pop if p支配q Sp = [ Sp q ]; elseif q支配p np = np + 1; endif endfor if np = 0 P1 = [P1 , np]; endif endfor i = 1; while(!Pi) H = []; for p in Pi for q in Sp nq = nq - 1; if nq == 0 H = [H q]; endfor endfor i = i + 1; Pi = H; endwhile
保持解群体分布性和多样性的方法
产生新群体时,通常将优秀且聚集度比较小的个体保留参与下一代进化,聚集密度小的个体聚集距离反而大。
本算法中引入了拥挤距离。
对于一个双目标的算法
计算个体之间的拥挤距离
1 2 3 4 5 6 7 8 9 10
crowding-distance-assignment(P) N = |P| for each i P_distance = 0 for each objective m P = sort(P,m); fori = 2 to (N-1) P[i]_distance = P[i]_distance + (P[i+1]_distance.m-P[i-1]_distance.m) endfor P[0]_distance = P[N]_distance = 无穷;
NSGA2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
初始化随机产生一个初始群体 P_0 Q_0 = make_new_pop(P_0); t = 0; R_t = R_t + Q_t; F = nondominated-sort(R_t); P_t+1 = [] and i = 1; Until(|P_t+1|+|F_i|<=N) P_t=1 = p_t+1 + F_i; i = i + 1; end crowding-distance-assignment(F_i); sort(F_i,>); P_t+1 = P_t+1 + F_i(1:N-|P_t+1|); Q_t+1 = make_new_pop(P_t+1); t = t + 1;