}
double bestSubScore = Double.MAX_VALUE;
Object[] bestSubOrder = null;
Permutation perms = new Permutation(orderList.toArray());
int exhaustive = regionCount;
//after 16 sources this will be completely greedy. before that it will try to strike a compromise between the exhaustive
//and non-exhaustive searches
if (regionCount > EXHAUSTIVE_SEARCH_GROUPS) {
exhaustive = Math.max(2, EXHAUSTIVE_SEARCH_GROUPS - (int)Math.ceil(Math.sqrt((regionCount - EXHAUSTIVE_SEARCH_GROUPS))));
}
Iterator permIter = perms.generate(exhaustive);
while(permIter.hasNext()) {
Object[] order = (Object[]) permIter.next();
double score = region.scoreRegion(order, 0, metadata, capFinder, context);