Program: 64438
Project: 64438
Buggy source:
@Override public boolean tryToExpand(double splitConfidence,double tieThreshold){
  boolean shouldSplit=false;
  AttributeExpansionSuggestion[] bestSplitSuggestions=this.getBestSplitSuggestions(splitCriterion);
  Arrays.sort(bestSplitSuggestions);
  int[] oldInputs=inputsToLearn.clone();
  inputsToLearn=inputSelector.getNextInputIndices(bestSplitSuggestions);
  Arrays.sort(this.inputsToLearn);
  for (int i=0; i < oldInputs.length; i++) {
    if (attributesMask[oldInputs[i]]) {
      if (Arrays.binarySearch(inputsToLearn,oldInputs[i]) < 0) {
        this.attributeObservers.set(oldInputs[i],null);
      }
    }
  }
  if (bestSplitSuggestions.length < 2) {
    bestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 1];
    shouldSplit=true;
  }
 else {
    double hoeffdingBound=computeHoeffdingBound(splitCriterion.getRangeOfMerit(this.literalStatistics),splitConfidence,weightSeen);
    bestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 1];
    AttributeExpansionSuggestion secondBestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 2];
    if ((((bestSuggestion.merit - secondBestSuggestion.merit)) > hoeffdingBound) || (hoeffdingBound < tieThreshold)) {
      shouldSplit=true;
    }
  }
  if (shouldSplit) {
    DoubleVector[][] resultingStatistics=bestSuggestion.getResultingNodeStatistics();
    double[] branchMerits=splitCriterion.getBranchesSplitMerits(resultingStatistics);
    DoubleVector[] newLiteralStatistics;
    if (branchMerits[1] > branchMerits[0]) {
      bestSuggestion.getPredicate().negateCondition();
      newLiteralStatistics=getBranchStatistics(resultingStatistics,1);
    }
 else {
      newLiteralStatistics=getBranchStatistics(resultingStatistics,0);
    }
    int[] newOutputs=outputSelector.getNextOutputIndices(newLiteralStatistics,literalStatistics,outputsToLearn);
    Arrays.sort(newOutputs);
    otherBranchLearningLiteral=new LearningLiteralRegression();
    otherBranchLearningLiteral.setLearner((MultiLabelLearner)learner.copy());
    otherBranchLearningLiteral.setInstanceTransformer(this.instanceTransformer);
    if (learner instanceof AMRulesFunction) {
      ((AMRulesFunction)learner).resetWithMemory();
      if (newOutputs.length != outputsToLearn.length) {
        int[] otherOutputs=Utils.complementSet(outputsToLearn,newOutputs);
        otherOutputsLearningLiteral=new LearningLiteralRegression(otherOutputs);
        MultiLabelLearner otherOutputsLearner=(MultiLabelLearner)learner.copy();
        int[] indices=newLearnerOutputIndices(outputsToLearn,otherOutputs);
        ((AMRulesFunction)otherOutputsLearner).selectOutputsToLearn(indices);
        otherOutputsLearningLiteral.setLearner(otherOutputsLearner);
        indices=newLearnerOutputIndices(outputsToLearn,newOutputs);
        ((AMRulesFunction)learner).selectOutputsToLearn(indices);
      }
    }
 else {
      if (newOutputs.length != outputsToLearn.length) {
        otherOutputsLearningLiteral=new LearningLiteralRegression();
        MultiLabelLearner otherOutputsLearner=(MultiLabelLearner)learner.copy();
        otherOutputsLearningLiteral.setLearner(otherOutputsLearner);
      }
      learner.resetLearning();
    }
    expandedLearningLiteral=new LearningLiteralRegression(newOutputs);
    expandedLearningLiteral.setLearner((MultiLabelLearner)this.learner.copy());
  }
  return shouldSplit;
}

Fixed version (ground truth):
@Override public boolean tryToExpand(double splitConfidence,double tieThreshold){
  boolean shouldSplit=false;
  AttributeExpansionSuggestion[] bestSplitSuggestions=this.getBestSplitSuggestions(splitCriterion);
  Arrays.sort(bestSplitSuggestions);
  int[] oldInputs=inputsToLearn.clone();
  inputsToLearn=inputSelector.getNextInputIndices(bestSplitSuggestions);
  Arrays.sort(this.inputsToLearn);
  for (int i=0; i < oldInputs.length; i++) {
    if (attributesMask[oldInputs[i]]) {
      if (Arrays.binarySearch(inputsToLearn,oldInputs[i]) < 0) {
        this.attributeObservers.set(oldInputs[i],null);
      }
    }
  }
  if (bestSplitSuggestions.length < 2) {
    bestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 1];
    shouldSplit=true;
  }
 else {
    double hoeffdingBound=computeHoeffdingBound(splitCriterion.getRangeOfMerit(this.literalStatistics),splitConfidence,weightSeen);
    bestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 1];
    AttributeExpansionSuggestion secondBestSuggestion=bestSplitSuggestions[bestSplitSuggestions.length - 2];
    if ((((bestSuggestion.merit - secondBestSuggestion.merit)) > hoeffdingBound) || (hoeffdingBound < tieThreshold)) {
      shouldSplit=true;
    }
  }
  if (shouldSplit) {
    DoubleVector[][] resultingStatistics=bestSuggestion.getResultingNodeStatistics();
    double[] branchMerits=splitCriterion.getBranchesSplitMerits(resultingStatistics);
    DoubleVector[] newLiteralStatistics;
    if (branchMerits[1] > branchMerits[0]) {
      bestSuggestion.getPredicate().negateCondition();
      newLiteralStatistics=getBranchStatistics(resultingStatistics,1);
    }
 else {
      newLiteralStatistics=getBranchStatistics(resultingStatistics,0);
    }
    int[] newOutputs=outputSelector.getNextOutputIndices(newLiteralStatistics,literalStatistics,outputsToLearn);
    Arrays.sort(newOutputs);
    otherBranchLearningLiteral=new LearningLiteralRegression();
    otherBranchLearningLiteral.instanceHeader=instanceHeader;
    otherBranchLearningLiteral.learner=(MultiLabelLearner)learner.copy();
    otherBranchLearningLiteral.instanceTransformer=(InstanceTransformer)this.instanceTransformer;
    if (learner instanceof AMRulesFunction) {
      if (newOutputs.length != outputsToLearn.length) {
        int[] otherOutputs=Utils.complementSet(outputsToLearn,newOutputs);
        int[] indices;
        if (otherOutputs.length > 0) {
          otherOutputsLearningLiteral=new LearningLiteralRegression(otherOutputs);
          MultiLabelLearner otherOutputsLearner=(MultiLabelLearner)learner.copy();
          indices=Utils.getIndexCorrespondence(outputsToLearn,otherOutputs);
          ((AMRulesFunction)otherOutputsLearner).selectOutputsToLearn(indices);
          ((AMRulesFunction)otherOutputsLearner).resetWithMemory();
          otherOutputsLearningLiteral.learner=otherOutputsLearner;
          otherOutputsLearningLiteral.instanceHeader=instanceHeader;
          otherOutputsLearningLiteral.instanceTransformer=new InstanceOutputAttributesSelector(instanceHeader,otherOutputs);
        }
        indices=Utils.getIndexCorrespondence(outputsToLearn,newOutputs);
        ((AMRulesFunction)learner).selectOutputsToLearn(indices);
      }
      ((AMRulesFunction)learner).resetWithMemory();
    }
 else {
      if (newOutputs.length != outputsToLearn.length) {
        int[] otherOutputs=Utils.complementSet(outputsToLearn,newOutputs);
        if (otherOutputs.length > 0) {
          otherOutputsLearningLiteral=new LearningLiteralRegression();
          MultiLabelLearner otherOutputsLearner=(MultiLabelLearner)learner.copy();
          otherOutputsLearner.resetLearning();
          otherOutputsLearningLiteral.learner=otherOutputsLearner;
          otherOutputsLearningLiteral.instanceHeader=instanceHeader;
          otherOutputsLearningLiteral.instanceTransformer=new InstanceOutputAttributesSelector(instanceHeader,otherOutputs);
        }
      }
      learner.resetLearning();
    }
    expandedLearningLiteral=new LearningLiteralRegression(newOutputs);
    expandedLearningLiteral.learner=(MultiLabelLearner)this.learner.copy();
    expandedLearningLiteral.instanceHeader=instanceHeader;
    expandedLearningLiteral.instanceTransformer=new InstanceOutputAttributesSelector(instanceHeader,newOutputs);
  }
  return shouldSplit;
}