EDA365电子论坛网
标题:
非支配排序算法通用MATLAB代码
[打印本页]
作者:
dapmood
时间:
2020-10-15 15:22
标题:
非支配排序算法通用MATLAB代码
4 Q/ F7 S2 _4 V' k$ v; i
规模为N的种群中的每个个体都要针对M个目标函数和种群中的N-1个个体进行比较,复杂度为O(MN),因此种群中的N个个体都比较结束的复杂度为O(MN2),即每进行一次Pareto分级的时间复杂度为O(MN2)。
* l2 c9 [" l0 q# M5 A3 K; q! F
: B7 j" N2 _; q, b' d) y* w
该算法需要保存两个量:
% f- w) u: W9 R& Q" ?
+ d' w$ _7 D! a; @3 U
(1).支配个数np。该量是在可行解空间中可以支配个体p的所有个体的数量。
+ k( i, b* H' c6 j( K+ D
* v# m: a. P; h7 x+ Z# g
(2).被支配个体集合SP。该量是可行解空间中所有被个体p支配的个体组成的集合。
: C! F: J8 z9 u. d, f
) g& D7 A' h+ P0 H4 v0 f
matlab代码:
1 m% x: E3 t, J8 Z1 T! l, D
2 o5 d; U5 d& l$ P" x( N
(注意PopObj填入的多目标的函数值,如果有两个目标,100个个体,那么就是100*2的矩阵,nSort是前沿面的编号)
$ J% d; r9 X- d2 b. B; ^9 ]
! M# g b: |; h# F U5 I( G
function [FrontNO,MaxFNO] = NDSort(PopObj,nSort)
%NDSort - Do non-dominated sorting on the population by ENS
%
% FrontNO = NDSort(A,s) does non-dominated sorting on A, where A is a
% matrix which stores the objective values of all the individuals in the
% population, and s is the number of individuals being sorted at least.
% FrontNO(i) means the number of front of the i-th individual.
%
% [FrontNO,K] = NDSort(...) also returns the maximum number of fronts,
% except for the value of inf.
%
% In particular, s = 1 stands for find only the first non-dominated
% front, s = size(A,1)/2 stands for sort only half of the population
% (which is often used in the algorithm), and s = inf stands for sort the
% whole population.
%
% Example:
% [FrontNO,MaxFNO] = NDSort(PopObj,1)
[N,M] = size(PopObj);
FrontNO = inf(1,N);
MaxFNO = 0;
[PopObj,rank] = sortrows(PopObj);
while sum(FrontNO<inf) < min(nSort,N)
MaxFNO = MaxFNO + 1;
for i = 1 : N
if FrontNO(i) == inf
Dominated = false;
for j = i-1 : -1 : 1
if FrontNO(j) == MaxFNO
m = 2;
while m <= M && PopObj(i,m) >= PopObj(j,m)
m = m + 1;
end
Dominated = m > M;
if Dominated || M == 2
break;
end
end
end
if ~Dominated
FrontNO(i) = MaxFNO;
end
end
end
end
FrontNO(rank) = FrontNO;
end
% I# U! l* b, k9 d3 s
作者:
youOK
时间:
2020-10-15 16:16
非支配排序算法通用MATLAB代码
欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/)
Powered by Discuz! X3.2