Program: 149564
Project: 149564
Buggy source:
/** 
 * Select the top individual and then the rest using a probability set by their rank. The resulting subset will be at least size 2 (unless the input is smaller or there are not enough valid individuals (fitness above zero)).
 * @param individuals
 * @return the subset
 * @see gdsc.smlm.ga.SelectionStrategy#select(java.util.List)
 */
@Override public List<? extends Chromosome> select(List<? extends Chromosome> individuals){
  if (individuals == null || individuals.size() < 3)   return individuals;
  ArrayList<Chromosome> sorted=new ArrayList<Chromosome>(individuals.size());
  for (  Chromosome c : individuals)   if (c.getFitness() > 0)   sorted.add(c);
  if (sorted.size() < 3)   return sorted;
  ChromosomeComparator.sort(sorted);
  int size=(int)Math.round(sorted.size() * fraction);
  if (size < 2)   size=2;
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>(size);
  int n=sorted.size() - 1;
  subset.add(sorted.get(0));
  long cumulative=((long)n * (n + 1l)) / 2l;
  int[] rank=new int[sorted.size()];
  for (int i=1; i < rank.length; i++)   rank[i]=n--;
  while (subset.size() < size) {
    final long previous=cumulative;
    long next=random.nextLong(1l,cumulative);
    long sum=0;
    for (int i=1; i < rank.length; i++) {
      sum+=rank[i];
      if (next <= sum) {
        subset.add(sorted.get(i));
        cumulative-=rank[i];
        rank[i]=0;
        break;
      }
    }
    if (previous == cumulative)     throw new RuntimeException("String_Node_Str" + subset.size() + "String_Node_Str"+ size);
  }
  return subset;
}

Fixed version (ground truth):
/** 
 * Select the top individual and then the rest using a probability set by their rank. The resulting subset will be at least size 2 (unless the input is smaller or there are not enough valid individuals (fitness above zero)).
 * @param individuals
 * @return the subset
 * @see gdsc.smlm.ga.SelectionStrategy#select(java.util.List)
 */
@Override public List<? extends Chromosome> select(List<? extends Chromosome> individuals){
  if (individuals == null || individuals.size() < 3)   return individuals;
  ArrayList<Chromosome> sorted=new ArrayList<Chromosome>(individuals.size());
  for (  Chromosome c : individuals)   if (c.getFitness() > 0)   sorted.add(c);
  if (sorted.size() < 3)   return sorted;
  int size=(int)Math.round(sorted.size() * fraction);
  if (size < 2)   size=2;
  if (tracker != null)   tracker.progress(0,size);
  ChromosomeComparator.sort(sorted);
  ArrayList<Chromosome> subset=new ArrayList<Chromosome>(size);
  int n=sorted.size() - 1;
  subset.add(sorted.get(0));
  long cumulative=((long)n * (n + 1l)) / 2l;
  int[] rank=new int[sorted.size()];
  for (int i=1; i < rank.length; i++)   rank[i]=n--;
  while (subset.size() < size) {
    if (tracker != null)     tracker.progress(subset.size(),size);
    final long previous=cumulative;
    long next=random.nextLong(1l,cumulative);
    long sum=0;
    for (int i=1; i < rank.length; i++) {
      sum+=rank[i];
      if (next <= sum) {
        subset.add(sorted.get(i));
        cumulative-=rank[i];
        rank[i]=0;
        break;
      }
    }
    if (previous == cumulative)     throw new RuntimeException("String_Node_Str" + subset.size() + "String_Node_Str"+ size);
  }
  if (tracker != null)   tracker.progress(1);
  return subset;
}