Program: 9351
Project: 9351
Buggy source:
private void extendNodeProper(ExampleBasedNode node,OWLClassExpression concept,int maxLength,int recDepth){
  if (stop)   return;
  if (recDepth > maxRecDepth)   maxRecDepth=recDepth;
  long refinementCalcTimeNsStart=System.nanoTime();
  Set<OWLClassExpression> 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<OWLClassExpression> toEvaluateConcepts=new TreeSet<OWLClassExpression>();
  Iterator<OWLClassExpression> it=refinements.iterator();
  while (it.hasNext()) {
    OWLClassExpression refinement=it.next();
    if (OWLClassExpressionUtils.getLength(refinement) > node.getHorizontalExpansion()) {
      boolean propernessDetected=false;
      if (useShortConceptConstruction) {
        OWLClassExpression shortConcept=ConceptTransformation.getShortConcept(refinement);
        int n=shortConcept.compareTo(concept);
        if (n == 0) {
          propernessTestsAvoidedByShortConceptConstruction++;
          propernessDetected=true;
        }
      }
      if (!propernessDetected && useTooWeakList) {
        if (refinement instanceof OWLObjectIntersectionOf) {
          boolean tooWeakElement=containsTooWeakElement((OWLObjectIntersectionOf)refinement);
          if (tooWeakElement) {
            propernessTestsAvoidedByTooWeakList++;
            conceptTestsTooWeakList++;
            propernessDetected=true;
            properRefinements.add(refinement);
            tooWeakList.add(refinement);
            ExampleBasedNode newNode=new ExampleBasedNode(refinement,negativeWeight,startNodeBonus,expansionPenaltyFactor,negationPenalty);
            newNode.setHorizontalExpansion(OWLClassExpressionUtils.getLength(refinement) - 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<OWLClassExpression> improperConcepts=null;
  if (toEvaluateConcepts.size() > 0) {
    if (usePropernessChecks) {
      long propCalcReasoningStart=System.nanoTime();
      improperConcepts=rs.isSuperClassOf(toEvaluateConcepts,concept);
      propernessTestsReasoner+=toEvaluateConcepts.size();
      propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart;
    }
  }
  long improperConceptsRemovalTimeNsStart=System.nanoTime();
  if (improperConcepts != null)   toEvaluateConcepts.removeAll(improperConcepts);
  Set<OWLClassExpression> properConcepts=toEvaluateConcepts;
  refinements.removeAll(properConcepts);
  improperConceptsRemovalTimeNs+=System.nanoTime() - improperConceptsRemovalTimeNsStart;
  for (  OWLClassExpression 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,negativeWeight,startNodeBonus,expansionPenaltyFactor,negationPenalty);
      newNode.setHorizontalExpansion(OWLClassExpressionUtils.getLength(refinement) - 1);
      boolean qualityKnown=false;
      int quality=-2;
      if (useOverlyGeneralList && refinement instanceof OWLObjectUnionOf) {
        if (containsOverlyGeneralElement((OWLObjectUnionOf)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<OWLIndividual> coveredPositives=node.getCoveredPositives();
        Set<OWLIndividual> newlyCoveredPositives=new HashSet<OWLIndividual>();
        int misclassifiedPositives=nrOfPositiveExamples - coveredPositives.size();
        for (        OWLIndividual i : coveredPositives) {
          if (quality != -1) {
            boolean covered=rs.hasType(refinement,i);
            if (!covered)             misclassifiedPositives++;
 else             newlyCoveredPositives.add(i);
            if (misclassifiedPositives > allowedMisclassifications)             quality=-1;
          }
        }
        Set<OWLIndividual> newlyCoveredNegatives=null;
        if (quality != -1) {
          Set<OWLIndividual> coveredNegatives=node.getCoveredNegatives();
          newlyCoveredNegatives=new HashSet<OWLIndividual>();
          for (          OWLIndividual i : coveredNegatives) {
            boolean covered=rs.hasType(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) {
          solutions.add(newNode);
        }
        newCandidates.add(newNode);
        if ((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == nrOfNegativeExamples)         overlyGeneralList.add(refinement);
      }
      node.addChild(newNode);
      if (forceRefinementLengthIncrease && !newNode.isTooWeak()) {
        if (OWLClassExpressionUtils.getLength(node.getConcept()) == OWLClassExpressionUtils.getLength(newNode.getConcept())) {
          extendNodeProper(newNode,refinement,maxLength,recDepth + 1);
        }
      }
    }
  }
  for (  OWLClassExpression 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,OWLClassExpression concept,int maxLength,int recDepth){
  if (stop)   return;
  if (recDepth > maxRecDepth)   maxRecDepth=recDepth;
  long refinementCalcTimeNsStart=System.nanoTime();
  Set<OWLClassExpression> 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();
  Set<OWLClassExpression> toEvaluateConcepts=new TreeSet<OWLClassExpression>();
  Iterator<OWLClassExpression> it=refinements.iterator();
  while (it.hasNext()) {
    OWLClassExpression refinement=it.next();
    if (OWLClassExpressionUtils.getLength(refinement) > node.getHorizontalExpansion()) {
      boolean impropernessDetected=false;
      if (useShortConceptConstruction) {
        OWLClassExpression shortConcept=ConceptTransformation.getShortConcept(refinement);
        int n=shortConcept.compareTo(concept);
        if (n == 0) {
          propernessTestsAvoidedByShortConceptConstruction++;
          impropernessDetected=true;
        }
      }
      if (!impropernessDetected && useTooWeakList) {
        if (refinement instanceof OWLObjectIntersectionOf) {
          boolean tooWeakElement=containsTooWeakElement((OWLObjectIntersectionOf)refinement);
          if (tooWeakElement) {
            propernessTestsAvoidedByTooWeakList++;
            conceptTestsTooWeakList++;
            impropernessDetected=true;
            properRefinements.add(refinement);
            tooWeakList.add(refinement);
            ExampleBasedNode newNode=new ExampleBasedNode(refinement,negativeWeight,startNodeBonus,expansionPenaltyFactor,negationPenalty);
            newNode.setHorizontalExpansion(OWLClassExpressionUtils.getLength(refinement) - 1);
            newNode.setTooWeak(true);
            newNode.setQualityEvaluationMethod(ExampleBasedNode.QualityEvaluationMethod.TOO_WEAK_LIST);
            node.addChild(newNode);
            it.remove();
          }
        }
      }
      if (!impropernessDetected) {
        toEvaluateConcepts.add(refinement);
      }
    }
  }
  evaluateSetCreationTimeNs+=System.nanoTime() - evaluateSetCreationTimeNsStart;
  Set<OWLClassExpression> improperConcepts=null;
  if (toEvaluateConcepts.size() > 0) {
    if (usePropernessChecks) {
      long propCalcReasoningStart=System.nanoTime();
      improperConcepts=rs.isSuperClassOf(toEvaluateConcepts,concept);
      propernessTestsReasoner+=toEvaluateConcepts.size();
      propernessCalcReasoningTimeNs+=System.nanoTime() - propCalcReasoningStart;
    }
  }
  long improperConceptsRemovalTimeNsStart=System.nanoTime();
  if (improperConcepts != null)   toEvaluateConcepts.removeAll(improperConcepts);
  Set<OWLClassExpression> properConcepts=toEvaluateConcepts;
  refinements.removeAll(properConcepts);
  improperConceptsRemovalTimeNs+=System.nanoTime() - improperConceptsRemovalTimeNsStart;
  for (  OWLClassExpression 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,negativeWeight,startNodeBonus,expansionPenaltyFactor,negationPenalty);
      newNode.setHorizontalExpansion(OWLClassExpressionUtils.getLength(refinement) - 1);
      boolean qualityKnown=false;
      int quality=-2;
      if (useOverlyGeneralList && refinement instanceof OWLObjectUnionOf) {
        if (containsOverlyGeneralElement((OWLObjectUnionOf)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<OWLIndividual> coveredPositives=node.getCoveredPositives();
        Set<OWLIndividual> newlyCoveredPositives=new HashSet<OWLIndividual>();
        int misclassifiedPositives=nrOfPositiveExamples - coveredPositives.size();
        for (        OWLIndividual i : coveredPositives) {
          if (quality != -1) {
            boolean covered=rs.hasType(refinement,i);
            if (!covered)             misclassifiedPositives++;
 else             newlyCoveredPositives.add(i);
            if (misclassifiedPositives > allowedMisclassifications)             quality=-1;
          }
        }
        Set<OWLIndividual> newlyCoveredNegatives=null;
        if (quality != -1) {
          Set<OWLIndividual> coveredNegatives=node.getCoveredNegatives();
          newlyCoveredNegatives=new HashSet<OWLIndividual>();
          for (          OWLIndividual i : coveredNegatives) {
            boolean covered=rs.hasType(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) {
          solutions.add(newNode);
        }
        newCandidates.add(newNode);
        if ((newNode.getCoveredPositives().size() == nrOfPositiveExamples) && quality == nrOfNegativeExamples)         overlyGeneralList.add(refinement);
      }
      node.addChild(newNode);
      if (forceRefinementLengthIncrease && !newNode.isTooWeak()) {
        if (OWLClassExpressionUtils.getLength(node.getConcept()) == OWLClassExpressionUtils.getLength(newNode.getConcept())) {
          extendNodeProper(newNode,refinement,maxLength,recDepth + 1);
        }
      }
    }
  }
  for (  OWLClassExpression refinement : refinements) {
    long redundancyCheckTimeNsStart=System.nanoTime();
    boolean redundant=properRefinements.contains(refinement);
    redundancyCheckTimeNs+=System.nanoTime() - redundancyCheckTimeNsStart;
    if (!redundant) {
      extendNodeProper(node,refinement,maxLength,recDepth + 1);
    }
  }
}