Program: 10147
Project: 10147
Buggy source:
private void extendNodeProper(ExampleBasedNode node,Description concept,int maxLength,int recDepth){
  if (stop)   return;
  if (recDepth > maxRecDepth)   maxRecDepth=recDepth;
  long refinementCalcTimeNsStart=System.nanoTime();
  Set<Description> refinements=operator.refine(concept,maxLength,null);
  refinementCalcTimeNs+=System.nanoTime() - refinementCalcTimeNsStart;
  if (refinements.size() > maxNrOfRefinements)   maxNrOfRefinements=refinements.size();
  long childConceptsDeletionTimeNsStart=System.nanoTime();
  refinements.removeAll(node.getChildConcepts());
  childConceptsDeletionTimeNs+=System.nanoTime() - childConceptsDeletionTimeNsStart;
  long evaluateSetCreationTimeNsStart=System.nanoTime();
  TreeSet<Description> toEvaluateConcepts=new TreeSet<Description>(conceptComparator);
  Iterator<Description> it=refinements.iterator();
  while (it.hasNext()) {
    Description refinement=it.next();
    if (refinement.getLength() > node.getHorizontalExpansion()) {
      boolean propernessDetected=false;
      if (useShortConceptConstruction) {
        Description shortConcept=ConceptTransformation.getShortConcept(refinement,conceptComparator);
        int n=conceptComparator.compare(shortConcept,concept);
        if (n == 0) {
          propernessTestsAvoidedByShortConceptConstruction++;
          propernessDetected=true;
        }
      }
      if (!propernessDetected && useTooWeakList) {
        if (refinement instanceof Intersection) {
          boolean tooWeakElement=containsTooWeakElement((Intersection)refinement);
          if (tooWeakElement) {
            propernessTestsAvoidedByTooWeakList++;
            conceptTestsTooWeakList++;
            propernessDetected=true;
            properRefinements.add(refinement);
            tooWeakList.add(refinement);
            ExampleBasedNode newNode=new ExampleBasedNode(refinement);
            newNode.setHorizontalExpansion(refinement.getLength() - 1);
            newNode.setTooWeak(true);
            newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.TOO_WEAK_LIST);
            node.addChild(newNode);
            it.remove();
          }
        }
      }
      if (!propernessDetected) {
        toEvaluateConcepts.add(refinement);
      }
    }
  }
  evaluateSetCreationTimeNs+=System.nanoTime() - evaluateSetCreationTimeNsStart;
  Set<Description> improperConcepts=null;
  if (toEvaluateConcepts.size() > 0) {
    if (usePropernessChecks) {
      long propCalcReasoningStart=System.nanoTime();
      improperConcepts=rs.subsumes(toEvaluateConcepts,concept);
      propernessTestsReasoner+=toEvaluateConcepts.size();
      propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart;
    }
  }
  long improperConceptsRemovalTimeNsStart=System.nanoTime();
  if (improperConcepts != null)   toEvaluateConcepts.removeAll(improperConcepts);
  Set<Description> properConcepts=toEvaluateConcepts;
  refinements.removeAll(properConcepts);
  improperConceptsRemovalTimeNs+=System.nanoTime() - improperConceptsRemovalTimeNsStart;
  for (  Description refinement : properConcepts) {
    long redundancyCheckTimeNsStart=System.nanoTime();
    boolean nonRedundant=properRefinements.add(refinement);
    redundancyCheckTimeNs+=System.nanoTime() - redundancyCheckTimeNsStart;
    if (!nonRedundant)     redundantConcepts++;
    if (nonRedundant) {
      ExampleBasedNode newNode=new ExampleBasedNode(refinement);
      newNode.setHorizontalExpansion(refinement.getLength() - 1);
      boolean qualityKnown=false;
      int quality=-2;
      if (useOverlyGeneralList && refinement instanceof Union) {
        if (containsOverlyGeneralElement((Union)refinement)) {
          conceptTestsOverlyGeneralList++;
          quality=nrOfNegativeExamples;
          qualityKnown=true;
          newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.OVERLY_GENERAL_LIST);
          newNode.setCoveredExamples(positiveExamples,negativeExamples);
        }
      }
      if (!qualityKnown) {
        long propCalcReasoningStart2=System.nanoTime();
        conceptTestsReasoner++;
        Set<Individual> coveredPositives=node.getCoveredPositives();
        Set<Individual> newlyCoveredPositives=new HashSet<Individual>();
        int misclassifiedPositives=nrOfPositiveExamples - coveredPositives.size();
        for (        Individual i : coveredPositives) {
          if (quality != -1) {
            boolean covered=rs.instanceCheck(refinement,i);
            if (!covered)             misclassifiedPositives++;
 else             newlyCoveredPositives.add(i);
            if (misclassifiedPositives > allowedMisclassifications)             quality=-1;
          }
        }
        Set<Individual> newlyCoveredNegatives=null;
        if (quality != -1) {
          Set<Individual> coveredNegatives=node.getCoveredNegatives();
          newlyCoveredNegatives=new HashSet<Individual>();
          for (          Individual i : coveredNegatives) {
            boolean covered=rs.instanceCheck(refinement,i);
            if (covered)             newlyCoveredNegatives.add(i);
          }
        }
        propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart2;
        newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.REASONER);
        if (quality != -1) {
          quality=(nrOfPositiveExamples - newlyCoveredPositives.size()) + newlyCoveredNegatives.size();
          newNode.setCoveredExamples(newlyCoveredPositives,newlyCoveredNegatives);
        }
      }
      if (quality == -1) {
        newNode.setTooWeak(true);
        tooWeakList.add(refinement);
      }
 else {
        if (quality >= 0 && quality <= allowedMisclassifications && !posOnly) {
          solutionFound=true;
          solutions.add(refinement);
        }
        newCandidates.add(newNode);
        if ((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == nrOfNegativeExamples)         overlyGeneralList.add(refinement);
      }
      node.addChild(newNode);
      if (forceRefinementLengthIncrease && !newNode.isTooWeak()) {
        if (node.getConcept().getLength() == newNode.getConcept().getLength()) {
          extendNodeProper(newNode,refinement,maxLength,recDepth + 1);
        }
      }
    }
  }
  for (  Description refinement : refinements) {
    long redundancyCheckTimeNsStart=System.nanoTime();
    boolean redundant=properRefinements.contains(refinement);
    redundancyCheckTimeNs+=System.nanoTime() - redundancyCheckTimeNsStart;
    if (!redundant)     extendNodeProper(node,refinement,maxLength,recDepth + 1);
  }
}

Fixed version (ground truth):
private void extendNodeProper(ExampleBasedNode node,Description concept,int maxLength,int recDepth){
  if (stop)   return;
  if (recDepth > maxRecDepth)   maxRecDepth=recDepth;
  long refinementCalcTimeNsStart=System.nanoTime();
  Set<Description> refinements=operator.refine(concept,maxLength,null);
  refinementCalcTimeNs+=System.nanoTime() - refinementCalcTimeNsStart;
  if (refinements.size() > maxNrOfRefinements)   maxNrOfRefinements=refinements.size();
  long childConceptsDeletionTimeNsStart=System.nanoTime();
  refinements.removeAll(node.getChildConcepts());
  childConceptsDeletionTimeNs+=System.nanoTime() - childConceptsDeletionTimeNsStart;
  long evaluateSetCreationTimeNsStart=System.nanoTime();
  TreeSet<Description> toEvaluateConcepts=new TreeSet<Description>(conceptComparator);
  Iterator<Description> it=refinements.iterator();
  while (it.hasNext()) {
    Description refinement=it.next();
    if (refinement.getLength() > node.getHorizontalExpansion()) {
      boolean propernessDetected=false;
      if (useShortConceptConstruction) {
        Description shortConcept=ConceptTransformation.getShortConcept(refinement,conceptComparator);
        int n=conceptComparator.compare(shortConcept,concept);
        if (n == 0) {
          propernessTestsAvoidedByShortConceptConstruction++;
          propernessDetected=true;
        }
      }
      if (!propernessDetected && useTooWeakList) {
        if (refinement instanceof Intersection) {
          boolean tooWeakElement=containsTooWeakElement((Intersection)refinement);
          if (tooWeakElement) {
            propernessTestsAvoidedByTooWeakList++;
            conceptTestsTooWeakList++;
            propernessDetected=true;
            properRefinements.add(refinement);
            tooWeakList.add(refinement);
            ExampleBasedNode newNode=new ExampleBasedNode(refinement);
            newNode.setHorizontalExpansion(refinement.getLength() - 1);
            newNode.setTooWeak(true);
            newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.TOO_WEAK_LIST);
            node.addChild(newNode);
            it.remove();
          }
        }
      }
      if (!propernessDetected) {
        toEvaluateConcepts.add(refinement);
      }
    }
  }
  evaluateSetCreationTimeNs+=System.nanoTime() - evaluateSetCreationTimeNsStart;
  Set<Description> improperConcepts=null;
  if (toEvaluateConcepts.size() > 0) {
    if (usePropernessChecks) {
      long propCalcReasoningStart=System.nanoTime();
      improperConcepts=rs.subsumes(toEvaluateConcepts,concept);
      propernessTestsReasoner+=toEvaluateConcepts.size();
      propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart;
    }
  }
  long improperConceptsRemovalTimeNsStart=System.nanoTime();
  if (improperConcepts != null)   toEvaluateConcepts.removeAll(improperConcepts);
  Set<Description> properConcepts=toEvaluateConcepts;
  refinements.removeAll(properConcepts);
  improperConceptsRemovalTimeNs+=System.nanoTime() - improperConceptsRemovalTimeNsStart;
  for (  Description refinement : properConcepts) {
    long redundancyCheckTimeNsStart=System.nanoTime();
    boolean nonRedundant=properRefinements.add(refinement);
    redundancyCheckTimeNs+=System.nanoTime() - redundancyCheckTimeNsStart;
    if (!nonRedundant)     redundantConcepts++;
    if (nonRedundant) {
      ExampleBasedNode newNode=new ExampleBasedNode(refinement);
      newNode.setHorizontalExpansion(refinement.getLength() - 1);
      boolean qualityKnown=false;
      int quality=-2;
      if (useOverlyGeneralList && refinement instanceof Union) {
        if (containsOverlyGeneralElement((Union)refinement)) {
          conceptTestsOverlyGeneralList++;
          quality=nrOfNegativeExamples;
          qualityKnown=true;
          newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.OVERLY_GENERAL_LIST);
          newNode.setCoveredExamples(positiveExamples,negativeExamples);
        }
      }
      if (!qualityKnown) {
        long propCalcReasoningStart2=System.nanoTime();
        conceptTestsReasoner++;
        Set<Individual> coveredPositives=node.getCoveredPositives();
        Set<Individual> newlyCoveredPositives=new HashSet<Individual>();
        int misclassifiedPositives=nrOfPositiveExamples - coveredPositives.size();
        for (        Individual i : coveredPositives) {
          if (quality != -1) {
            boolean covered=rs.instanceCheck(refinement,i);
            if (!covered)             misclassifiedPositives++;
 else             newlyCoveredPositives.add(i);
            if (misclassifiedPositives > allowedMisclassifications)             quality=-1;
          }
        }
        Set<Individual> newlyCoveredNegatives=null;
        if (quality != -1) {
          Set<Individual> coveredNegatives=node.getCoveredNegatives();
          newlyCoveredNegatives=new HashSet<Individual>();
          for (          Individual i : coveredNegatives) {
            boolean covered=rs.instanceCheck(refinement,i);
            if (covered)             newlyCoveredNegatives.add(i);
          }
        }
        propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart2;
        newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.REASONER);
        if (quality != -1) {
          quality=(nrOfPositiveExamples - newlyCoveredPositives.size()) + newlyCoveredNegatives.size();
          newNode.setCoveredExamples(newlyCoveredPositives,newlyCoveredNegatives);
        }
      }
      if (quality == -1) {
        newNode.setTooWeak(true);
        tooWeakList.add(refinement);
      }
 else {
        if (quality >= 0 && quality <= allowedMisclassifications && !posOnly) {
          solutionFound=true;
          solutions.add(refinement);
        }
        newCandidates.add(newNode);
        if ((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == nrOfNegativeExamples)         overlyGeneralList.add(refinement);
      }
      node.addChild(newNode);
      if (forceRefinementLengthIncrease && !newNode.isTooWeak()) {
        if (node.getConcept().getLength() == newNode.getConcept().getLength()) {
          extendNodeProper(newNode,refinement,maxLength,recDepth + 1);
        }
      }
    }
  }
  for (  Description refinement : refinements) {
    long redundancyCheckTimeNsStart=System.nanoTime();
    boolean redundant=properRefinements.contains(refinement);
    redundancyCheckTimeNs+=System.nanoTime() - redundancyCheckTimeNsStart;
    if (!redundant) {
      extendNodeProper(node,refinement,maxLength,recDepth + 1);
    }
  }
}