Program: 54679
Project: 54679
Buggy source:
private void IIS(Dataframe trainingData,Map<List<Object>,Double> EpFj_observed,double Cmax){
  ModelParameters modelParameters=kb().getModelParameters();
  int totalIterations=kb().getTrainingParameters().getTotalIterations();
  Set<Object> classesSet=modelParameters.getClasses();
  Map<List<Object>,Double> lambdas=modelParameters.getLambdas();
  int n=modelParameters.getN();
  DatabaseConnector dbc=kb().getDbc();
  for (int iteration=0; iteration < totalIterations; ++iteration) {
    logger.debug("String_Node_Str",iteration);
    Map<List<Object>,Double> tmp_EpFj_model=dbc.getBigMap("String_Node_Str",MapType.HASHMAP,StorageHint.IN_MEMORY,true,true);
    for (    Record r : trainingData) {
      final AssociativeArray xData=r.getX();
      AssociativeArray classScores=new AssociativeArray(StreamMethods.stream(classesSet.stream(),isParallelized()).collect(Collectors.toMap(Function.identity(),theClass -> calculateClassScore(xData,theClass))));
      Descriptives.normalizeExp(classScores);
      StreamMethods.stream(classScores.entrySet().stream(),isParallelized()).forEach(entry -> {
        Object theClass=entry.getKey();
        Double score=TypeInference.toDouble(entry.getValue());
        double probabilityFraction=score / n;
        for (        Map.Entry<Object,Object> entry2 : r.getX().entrySet()) {
          Double occurrences=TypeInference.toDouble(entry2.getValue());
          if (occurrences == null || occurrences == 0.0) {
            continue;
          }
          Object feature=entry2.getKey();
          List<Object> featureClassTuple=Arrays.<Object>asList(feature,theClass);
          tmp_EpFj_model.put(featureClassTuple,tmp_EpFj_model.getOrDefault(featureClassTuple,0.0) + probabilityFraction);
        }
      }
);
    }
    AtomicBoolean infiniteValuesDetected=new AtomicBoolean(false);
    StreamMethods.stream(tmp_EpFj_model.entrySet().stream(),isParallelized()).forEach(featureClassCounts -> {
      List<Object> tp=featureClassCounts.getKey();
      Double EpFj_observed_value=EpFj_observed.get(tp);
      Double EpFj_model_value=featureClassCounts.getValue();
      if (Math.abs(EpFj_observed_value - EpFj_model_value) <= 1e-8) {
      }
 else       if (EpFj_observed_value == 0.0) {
        lambdas.put(tp,Double.NEGATIVE_INFINITY);
        infiniteValuesDetected.set(true);
      }
 else       if (EpFj_model_value == 0.0) {
        lambdas.put(tp,Double.POSITIVE_INFINITY);
        infiniteValuesDetected.set(true);
      }
 else {
        double deltaJ=Math.log(EpFj_observed_value / EpFj_model_value) / Cmax;
        double newValue=lambdas.get(tp) + deltaJ;
        lambdas.put(tp,newValue);
      }
    }
);
    if (infiniteValuesDetected.get()) {
      Double minimumNonInfiniteLambdaWeight=StreamMethods.stream(lambdas.values().stream(),isParallelized()).filter(v -> Double.isFinite(v)).min(Double::compare).get();
      Double maximumNonInfiniteLambdaWeight=StreamMethods.stream(lambdas.values().stream(),isParallelized()).filter(v -> Double.isFinite(v)).max(Double::compare).get();
      StreamMethods.stream(lambdas.entrySet().stream(),isParallelized()).filter(e -> Double.isInfinite(e.getValue())).forEach(e -> {
        List<Object> featureClass=e.getKey();
        Double value=e.getValue();
        if (value < 0.0) {
          lambdas.put(featureClass,minimumNonInfiniteLambdaWeight);
        }
 else {
          lambdas.put(featureClass,maximumNonInfiniteLambdaWeight);
        }
      }
);
    }
    dbc.dropBigMap("String_Node_Str",tmp_EpFj_model);
  }
}

Fixed version (ground truth):
private void IIS(Dataframe trainingData,Map<List<Object>,Double> EpFj_observed,double Cmax){
  ModelParameters modelParameters=kb().getModelParameters();
  int totalIterations=kb().getTrainingParameters().getTotalIterations();
  Set<Object> classesSet=modelParameters.getClasses();
  Map<List<Object>,Double> lambdas=modelParameters.getLambdas();
  int n=modelParameters.getN();
  DatabaseConnector dbc=kb().getDbc();
  for (int iteration=0; iteration < totalIterations; ++iteration) {
    logger.debug("String_Node_Str",iteration);
    Map<List<Object>,Double> tmp_EpFj_model=dbc.getBigMap("String_Node_Str",MapType.HASHMAP,StorageHint.IN_MEMORY,true,true);
    for (    Record r : trainingData) {
      final AssociativeArray xData=r.getX();
      AssociativeArray classScores=new AssociativeArray(StreamMethods.stream(classesSet.stream(),isParallelized()).collect(Collectors.toMap(Function.identity(),theClass -> calculateClassScore(xData,theClass))));
      Descriptives.normalizeExp(classScores);
      StreamMethods.stream(classScores.entrySet().stream(),isParallelized()).forEach(entry -> {
        Object theClass=entry.getKey();
        Double score=TypeInference.toDouble(entry.getValue());
        double probabilityFraction=score / n;
        for (        Map.Entry<Object,Object> entry2 : r.getX().entrySet()) {
          Double occurrences=TypeInference.toDouble(entry2.getValue());
          if (occurrences == null || occurrences == 0.0) {
            continue;
          }
          Object feature=entry2.getKey();
          List<Object> featureClassTuple=Arrays.<Object>asList(feature,theClass);
          tmp_EpFj_model.put(featureClassTuple,tmp_EpFj_model.getOrDefault(featureClassTuple,0.0) + probabilityFraction);
        }
      }
);
    }
    AtomicBoolean infiniteValuesDetected=new AtomicBoolean(false);
    StreamMethods.stream(tmp_EpFj_model.entrySet().stream(),isParallelized()).forEach(featureClassCounts -> {
      List<Object> tp=featureClassCounts.getKey();
      Double EpFj_observed_value=EpFj_observed.get(tp);
      Double EpFj_model_value=featureClassCounts.getValue();
      if (Math.abs(EpFj_observed_value - EpFj_model_value) <= 1e-8) {
      }
 else       if (EpFj_observed_value == 0.0) {
        lambdas.put(tp,Double.NEGATIVE_INFINITY);
        infiniteValuesDetected.set(true);
      }
 else       if (EpFj_model_value == 0.0) {
        lambdas.put(tp,Double.POSITIVE_INFINITY);
        infiniteValuesDetected.set(true);
      }
 else {
        double deltaJ=Math.log(EpFj_observed_value / EpFj_model_value) / Cmax;
        double newValue=lambdas.get(tp) + deltaJ;
        lambdas.put(tp,newValue);
      }
    }
);
    if (infiniteValuesDetected.get()) {
      Double minimumNonInfiniteLambdaWeight=StreamMethods.stream(lambdas.values().stream(),isParallelized()).filter(v -> Double.isFinite(v)).min(Double::compare).get();
      Double maximumNonInfiniteLambdaWeight=StreamMethods.stream(lambdas.values().stream(),isParallelized()).filter(v -> Double.isFinite(v)).max(Double::compare).get();
      StreamMethods.stream(lambdas.entrySet().stream(),isParallelized()).forEach(e -> {
        List<Object> featureClass=e.getKey();
        Double value=e.getValue();
        if (Double.isInfinite(value)) {
          if (value < 0.0) {
            lambdas.put(featureClass,minimumNonInfiniteLambdaWeight);
          }
 else {
            lambdas.put(featureClass,maximumNonInfiniteLambdaWeight);
          }
        }
      }
);
    }
    dbc.dropBigMap("String_Node_Str",tmp_EpFj_model);
  }
}