Program: 20170
Project: 20170
Buggy source:
public void optimizeAlpha(WorkerRunnable[] runnables){
  Arrays.fill(docLengthCounts,0);
  for (int topic=0; topic < topicDocCounts.length; topic++) {
    Arrays.fill(topicDocCounts[topic],0);
  }
  for (int thread=0; thread < numThreads; thread++) {
    int[] sourceLengthCounts=runnables[thread].getDocLengthCounts();
    int[][] sourceTopicCounts=runnables[thread].getTopicDocCounts();
    for (int count=0; count < sourceLengthCounts.length; count++) {
      if (sourceLengthCounts[count] > 0) {
        docLengthCounts[count]+=sourceLengthCounts[count];
        sourceLengthCounts[count]=0;
      }
    }
    for (int topic=0; topic < numTopics; topic++) {
      if (!usingSymmetricAlpha) {
        for (int count=0; count < sourceTopicCounts[topic].length; count++) {
          if (sourceTopicCounts[topic][count] > 0) {
            topicDocCounts[topic][count]+=sourceTopicCounts[topic][count];
            sourceTopicCounts[topic][count]=0;
          }
        }
      }
 else {
        for (int count=0; count < sourceTopicCounts[topic].length; count++) {
          if (sourceTopicCounts[topic][count] > 0) {
            topicDocCounts[0][count]+=sourceTopicCounts[topic][count];
            sourceTopicCounts[topic][count]=0;
          }
        }
      }
    }
  }
  if (usingSymmetricAlpha) {
    alphaSum=Dirichlet.learnSymmetricConcentration(topicDocCounts[0],docLengthCounts,numTopics,alphaSum);
    for (int topic=0; topic < numTopics; topic++) {
      alpha[topic]=alphaSum / numTopics;
    }
  }
 else {
    alphaSum=Dirichlet.learnParameters(alpha,topicDocCounts,docLengthCounts,1.001,1.0,1);
  }
}

Fixed version (ground truth):
public void optimizeAlpha(WorkerRunnable[] runnables){
  Arrays.fill(docLengthCounts,0);
  for (int topic=0; topic < topicDocCounts.length; topic++) {
    Arrays.fill(topicDocCounts[topic],0);
  }
  for (int thread=0; thread < numThreads; thread++) {
    int[] sourceLengthCounts=runnables[thread].getDocLengthCounts();
    int[][] sourceTopicCounts=runnables[thread].getTopicDocCounts();
    for (int count=0; count < sourceLengthCounts.length; count++) {
      if (sourceLengthCounts[count] > 0) {
        docLengthCounts[count]+=sourceLengthCounts[count];
        sourceLengthCounts[count]=0;
      }
    }
    for (int topic=0; topic < numTopics; topic++) {
      if (!usingSymmetricAlpha) {
        for (int count=0; count < sourceTopicCounts[topic].length; count++) {
          if (sourceTopicCounts[topic][count] > 0) {
            topicDocCounts[topic][count]+=sourceTopicCounts[topic][count];
            sourceTopicCounts[topic][count]=0;
          }
        }
      }
 else {
        for (int count=0; count < sourceTopicCounts[topic].length; count++) {
          if (sourceTopicCounts[topic][count] > 0) {
            topicDocCounts[0][count]+=sourceTopicCounts[topic][count];
            sourceTopicCounts[topic][count]=0;
          }
        }
      }
    }
  }
  if (usingSymmetricAlpha) {
    alphaSum=Dirichlet.learnSymmetricConcentration(topicDocCounts[0],docLengthCounts,numTopics,alphaSum);
    for (int topic=0; topic < numTopics; topic++) {
      alpha[topic]=alphaSum / numTopics;
    }
  }
 else {
    try {
      alphaSum=Dirichlet.learnParameters(alpha,topicDocCounts,docLengthCounts,1.001,1.0,1);
    }
 catch (    RuntimeException e) {
      logger.warning("String_Node_Str");
      alphaSum=numTopics;
      for (int topic=0; topic < numTopics; topic++) {
        alpha[topic]=1.0;
      }
    }
  }
}