% fpadelman.m June 2007
% Amber Shoecraft, Jim Dickson 
% This program has not been generalized yet and so doesn't ask
% for inputs. The weights given at the end are generated from
% another file, fpweighter. 
counter=0;
fp=zeros(1,13);
v1=[-1 1;-1 2;-1 3];%3
v2=[1 5;1 4;14 5;14 4;8 4;8 5];%6
v3=[4 6;4 7];%2
v4=[2 9;13 9;10 9;10 8;2 8;6 8;13 8];%7
v6=[7 12;7 11;7 10];%3
v7=[5 14;5 13;12 14;12 13;9 14;9 13];%6
superv=[v1;v2;v3;v4;v6;v7];
for i=1:2
    for j=4:9
        for k=10:11
            for m=12:18
                for n=19:21
                    for o=22:27
                        g=perms([j k m n o]);
                        for b=1:size(g,1)
                            c=find(g(b,:)==20);
                            if c==5 
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=superlistv(:)';
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:12) sl(1)]);
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:12) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                            elseif isempty(c)
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=[superlistv(:)' 11];
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:13) sl(1)]);  
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:13) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                                ord=[i g(b,:)];
                                superlistv=superv(ord,:)';
                                superlistv(:);
                                sl=[superlistv(:)' 3] ;
                                if length(sl)-length(unique(sl))==sum(sl==[sl(2:13) sl(1)]);    
                                    counter=counter+1;
                                    fp(counter,:)=zeros(1,13);
                                    e=ones(1,length(sl));
                                    usl=sl(logical(e-(sl==[sl(2:13) sl(1)])));
                                    fp(counter,1:length(usl))=usl;
                                end
                            end
                        end
                    end
                end
            end
        end
    end
end
ufp=unique(fp, 'rows')
counter
T8=length(find(ufp(:,9)==0))*927744
T9=(length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*103424
T10=(length(find(ufp(:,11)==0))-length(find(ufp(:,10)==0))+length(find(ufp(:,9)==0)))*13888
T11=(length(find(ufp(:,12)==0))-length(find(ufp(:,11)==0))+length(find(ufp(:,10)==0))-length(find(ufp(:,9)==0)))*2048
T12=(length(find(ufp(:,13)==0))-length(find(ufp(:,12)==0))+length(find(ufp(:,11)==0))-length(find(ufp(:,10)==0))+length(find(ufp(:,9)==0)))*288
falsepositves=T8+T9+T10+T11+T12