Xcos tests: fix blocks_set.tst after 59f9727d
[scilab.git] / scilab / modules / optimization / macros / genetic / DominationRank.sci
1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2011 - INRIA - Serge STEER
3 //
4 // Copyright (C) 2012 - 2016 - Scilab Enterprises
5 //
6 // This file is hereby licensed under the terms of the GNU GPL v2.0,
7 // pursuant to article 5.3.4 of the CeCILL v.2.1.
8 // This file was originally licensed under the terms of the CeCILL v2.1,
9 // and continues to be available under such terms.
10 // For more information, see the COPYING file which you should have received
11 // along with this program.
12
13 function Rank=DominationRank(All_FObj)
14     Rank  = zeros(All_FObj)
15     if size(All_FObj,2)==1 then
16         [T,Ind]=gsort(All_FObj,"g","i");
17         group_length=diff([0 find(diff(T)>0)]);
18         Ngroup=size(group_length,"*");
19         k=1;
20         for Count=1:Ngroup
21             Rank(k:k+group_length(Count)-1)=Count;
22             k=k+group_length(Count);
23         end
24         Rank(Ind)=Rank;
25     else
26         MO_All_FObj = All_FObj;
27         // Compute the domination rank on all the population
28         Index = 1:size(MO_All_FObj,1);
29         Count = 1;
30         while size(MO_All_FObj,1)>1
31             [tmp1,tmp2,Index_List]  = pareto_filter(MO_All_FObj);
32             Rank(Index(Index_List)) = Count;
33             Count = Count + 1;
34             MO_All_FObj(Index_List,:) = [];
35             Index(Index_List)          = [];
36         end
37     end
38 endfunction