################################################################## # generate projects function getRelevant(data, k, relevant, overlap) { # com = "sort -k 1 -r" for(row=1; row<=data[0]; row++) { # printf "ROW(%02s): ",row | com for (col=1; col<=Cols; col++) { # printf data[row,col] | com if (projectContains(data[row,col],col,data)) { overlap[row]++ # printf "*" | com } # else # printf " " | com # printf " " | com } # print overlap[row]-12 | com overlap[row] += 0.01 * rand() rowLookup[overlap[row]] = row } # close(com) m = asort(overlap) # for (i=m; i>0; i--) { # print overlap[i] # } for (i=m; i>=m-k; i--) { relevant[rowLookup[overlap[i]]] = 1 } } function getProjects(minOverlap, data, samples, projects) { if(minOverlap) { rejectProjects(minOverlap,data,samples, projects) printf (Verbose ? "Found "projects[0]" projects out of "data[0]" with "100*minOverlap"% attribute overlap (values contained within project ranges)\n" : "") } else { generateProjects(data,samples, projects) printf (Verbose ? "Generated "samples" samples from project ranges\n" : "") } } function rejectProjects(minOverlap, data, news, new, row,col,pass) { for(row=1; row<=data[0]; row++) { fails = 0 for(col=1; col<=Cols; col++) { if (!projectContains(data[row,col],col,data)) { fails++ # print "Row "row" failed because "Eman[col]"="data[row,col] } } if (fails < (1-minOverlap) * Cols) { new[0]++ for (col=1; col<=Cols; col++) new[new[0],col]=data[row,col] } } #Find mins and maxes of accepted projects for(col=1; col<=Cols; col++) { new["max",col]= -1*Inf new["min",col]= Inf for(row=1;row<=new[0]; row++) { new["max",col] = max(new["max",col], new[row,col]) new["min",col] = min(new["min",col], new[row,col]) } } } function projectContains(value,col,data, numValues,found,i) { numValues = data["range",col,0] found = 0 for (i=1; i<=numValues; i++) { if (value == data["range",col,i]) found = 1 } return found } function generateProjects(data,news,new, row,col,v) { new[0]=news for(col=1;col<=Cols;col++) { new["max",col]= -1*Inf new["min",col]= Inf for(row=1;row<=news;row++) { v = projectValue(data,col) new[row,col] = v new["max",col] = max(new["max",col],v) new["min",col] = min(new["min",col],v) } } } function projectValue(data,a, max,one) { max = data["range",a,0] one = int(rand() * max) + 1 return data["range",a,one] }