0001
0002
0003
0004 function [Candidates,Discrepancy] = xExcludeOverlap(Candidates,Discrepancy,Limit)
0005
0006 N = length(Candidates(1,:)) - 1;
0007
0008 OK = zeros(size(Candidates(:,1)));
0009 OK(1) = 1;
0010 NumOK = 1;
0011
0012 for i = 2:length(Candidates(:,1)),
0013 AddCand = 1;
0014 if Discrepancy(i) >= 0,
0015 j = 1;
0016 while (j <= NumOK) & (AddCand == 1),
0017 if Candidates(i,N+1) == Candidates(OK(j),N+1),
0018 Both = intersect(Candidates(i,1:N), Candidates(OK(j),1:N));
0019 if length(Both) > N/2,
0020 AddCand = 0;
0021 end
0022 end
0023 j = j + 1;
0024 end
0025 if AddCand == 1,
0026 NumOK = NumOK + 1;
0027 OK(NumOK) = i;
0028 end
0029 end
0030
0031 if NumOK >= Limit,
0032 fprintf('Top %2d distinct candidates retained\n', Limit);
0033 break
0034 end
0035
0036 end
0037
0038 OK = OK(1:NumOK);
0039
0040 Candidates = Candidates(OK,:);
0041 Discrepancy = Discrepancy(OK);