Program: 144005
Project: 144005
Buggy source:
Builder addRule(int[] variableIndexes,boolean[] variableNegations,double power,double weight){
  RulePart internalRepresentation=convertRulePartToInternalRepresentation(variableIndexes,variableNegations);
  double ruleMaximumValue=1 + internalRepresentation.observedConstant;
  if (ruleMaximumValue <= 0)   return this;
  if (internalRepresentation.variableIndexes.length == 0)   return this;
  int indexTerm=this.functionTerms.size();
  LinearFunction linearFunction=new LinearFunction(Vectors.dense(internalRepresentation.variableIndexes.length),ruleMaximumValue);
  for (int variable=0; variable < internalRepresentation.variableIndexes.length; variable++) {
    List<Integer> predicateTermIndices=this.externalPredicateIdToTerms.getOrDefault(internalRepresentation.variableIndexes[variable],null);
    if (predicateTermIndices == null) {
      predicateTermIndices=new ArrayList<>(200);
      this.externalPredicateIdToTerms.put(internalRepresentation.variableIndexes[variable],predicateTermIndices);
    }
    predicateTermIndices.add(indexTerm);
    Vector coefficients=Vectors.dense(internalRepresentation.variableIndexes.length);
    if (internalRepresentation.negations[variable]) {
      coefficients.set(variable,1);
      linearFunction=linearFunction.add(new LinearFunction(coefficients,-1));
    }
 else {
      coefficients.set(variable,-1);
      linearFunction=linearFunction.add(new LinearFunction(coefficients,0));
    }
  }
  FunctionTerm term=new FunctionTerm(internalRepresentation.variableIndexes,linearFunction,weight,power);
  functionTerms.add(term);
  return this;
}

Fixed version (ground truth):
Builder addRule(List<GroundedPredicate<Integer,Double>> groundedRulePredicates,boolean[] variableNegations,double power,double weight){
  RulePart internalRepresentation=convertRulePartToInternalRepresentation(groundedRulePredicates,variableNegations);
  double ruleMaximumValue=1 + internalRepresentation.observedConstant;
  if (ruleMaximumValue <= 0)   return this;
  Set<Integer> variableIndexesSet=new HashSet<>(Arrays.asList(ArrayUtils.toObject(internalRepresentation.variableIndexes)));
  int[] variableIndexes=ArrayUtils.toPrimitive(variableIndexesSet.toArray(new Integer[variableIndexesSet.size()]));
  if (variableIndexes.length == 0)   return this;
  int indexTerm=this.functionTerms.size();
  LinearFunction linearFunction=new LinearFunction(Vectors.dense(variableIndexes.length),ruleMaximumValue);
  for (int variable=0; variable < internalRepresentation.variableIndexes.length; variable++) {
    List<Integer> predicateTermIndices=this.externalPredicateIdToTerms.getOrDefault(internalRepresentation.variableIndexes[variable],null);
    if (predicateTermIndices == null) {
      predicateTermIndices=new ArrayList<>(200);
      this.externalPredicateIdToTerms.put(internalRepresentation.variableIndexes[variable],predicateTermIndices);
    }
    predicateTermIndices.add(indexTerm);
    Vector coefficients=Vectors.dense(variableIndexes.length);
    if (internalRepresentation.negations[variable]) {
      coefficients.set(ArrayUtils.indexOf(variableIndexes,internalRepresentation.variableIndexes[variable]),1);
      linearFunction=linearFunction.add(new LinearFunction(coefficients,-1));
    }
 else {
      coefficients.set(ArrayUtils.indexOf(variableIndexes,internalRepresentation.variableIndexes[variable]),-1);
      linearFunction=linearFunction.add(new LinearFunction(coefficients,0));
    }
  }
  FunctionTerm term=new FunctionTerm(variableIndexes,linearFunction,weight,power);
  functionTerms.add(term);
  return this;
}