nus-yam/ex-repair huggingface dataset:
Program: 21597
Project: 21597
Buggy source:
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=1;
}

Fixed version (ground truth):
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=Runtime.getRuntime().availableProcessors();
  this.parallelMode=true;
}
Program: 21598
Project: 21598
Buggy source:
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}
Program: 21599
Project: 21599
Buggy source:
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}
Program: 21600
Project: 21600
Buggy source:
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag,dists);
}
Program: 21601
Project: 21601
Buggy source:
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    Attribute att=vars.get(i).getAttribute();
    String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  Attribute att=vars.get(vars.size() - 1).getAttribute();
  String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}

Fixed version (ground truth):
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
  String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}
Program: 21602
Project: 21602
Buggy source:
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  int pos=0;
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
    pos=pos + numStates;
  }
}

Fixed version (ground truth):
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
  }
}
Program: 21604
Project: 21604
Buggy source:
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setVariables(amidstDBN);
  DBNconverterToHugin.setTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}

Fixed version (ground truth):
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setNodesAndTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}
Program: 21605
Project: 21605
Buggy source:
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  List<Variable> amidstVars=amidstDBN.getDynamicVariables().getListOfDynamicVariables();
  for (  Variable amidstVar : amidstVars) {
    if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) != 0)     throw new IllegalArgumentException("String_Node_Str");
    Node huginVar=this.huginDBN.getNodeByName(amidstVar.getName());
    Multinomial_MultinomialParents dist=amidstDBN.getDistributionTimeT(amidstVar);
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int nStates=amidstVar.getNumberOfStates();
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int i=0; i < numParentAssignments; i++) {
      double[] sourceArray=probabilities[i].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,i * nStates,nStates);
    }
    huginVar.getTable().setData(finalArray);
    if (huginVar.getTemporalClone() != null) {
      Multinomial_MultinomialParents distClone=amidstDBN.getDistributionTime0(amidstVar);
      finalArray=distClone.getProbabilities()[0].getProbabilities();
      huginVar.getTemporalClone().getTable().setData(finalArray);
    }
  }
}

Fixed version (ground truth):
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  Multinomial_MultinomialParents dist=null;
  int nStates=0;
  for (int i=0; i < numNodes; i++) {
    Node huginNode=huginNodes.get(i);
    if (huginNode.getTemporalMaster() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getName());
      dist=amidstDBN.getDistributionTimeT(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    if (huginNode.getTemporalClone() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getTemporalMaster().getName());
      dist=amidstDBN.getDistributionTime0(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int j=0; j < numParentAssignments; j++) {
      double[] sourceArray=probabilities[j].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,j * nStates,nStates);
    }
    huginNode.getTable().setData(finalArray);
  }
}
Program: 21606
Project: 21606
Buggy source:
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
      }
    }
  }
}

Fixed version (ground truth):
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
        Node huginParentClone=huginParent.getTemporalClone();
        Node huginChildClone=huginChild.getTemporalClone();
        huginChildClone.addParent(huginParentClone);
      }
    }
  }
}
Program: 21607
Project: 21607
Buggy source:
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  this.huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  this.amidstBN=ConverterToAMIDST.convertToAmidst(this.huginBN);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  Domain huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  BayesianNetwork amidstBN=ConverterToAMIDST.convertToAmidst(huginBN);
  System.out.println("String_Node_Str");
}
Program: 21608
Project: 21608
Buggy source:
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  int pos=0;
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
    pos=pos + numStates;
  }
}

Fixed version (ground truth):
private void setMultinomial_MultinomialParents(Node huginVar) throws ExceptionHugin {
  int indexNode=this.huginBN.getNodes().indexOf(huginVar);
  Variable amidstVar=this.amidstBN.getStaticVariables().getVariableById(indexNode);
  int numStates=amidstVar.getNumberOfStates();
  double[] huginProbabilities=huginVar.getTable().getData();
  List<Variable> parents=this.amidstBN.getDAG().getParentSet(amidstVar).getParents();
  int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(parents);
  for (int i=0; i < numParentAssignments; i++) {
    double[] amidstProbabilities=new double[numStates];
    for (int k=0; k < numStates; k++) {
      amidstProbabilities[k]=huginProbabilities[i * numStates + k];
    }
    Multinomial_MultinomialParents dist=this.amidstBN.getDistribution(amidstVar);
    dist.getMultinomial(i).setProbabilities(amidstProbabilities);
  }
}
Program: 21610
Project: 21610
Buggy source:
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setVariables(amidstDBN);
  DBNconverterToHugin.setTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}

Fixed version (ground truth):
public static Class convertToHugin(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DBNConverterToHugin DBNconverterToHugin=new DBNConverterToHugin();
  DBNconverterToHugin.setNodesAndTemporalClones(amidstDBN);
  DBNconverterToHugin.setStructure(amidstDBN);
  DBNconverterToHugin.setDistributions(amidstDBN);
  return DBNconverterToHugin.huginDBN;
}
Program: 21611
Project: 21611
Buggy source:
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  List<Variable> amidstVars=amidstDBN.getDynamicVariables().getListOfDynamicVariables();
  for (  Variable amidstVar : amidstVars) {
    if (amidstVar.getDistributionType().compareTo(DistType.MULTINOMIAL) != 0)     throw new IllegalArgumentException("String_Node_Str");
    Node huginVar=this.huginDBN.getNodeByName(amidstVar.getName());
    Multinomial_MultinomialParents dist=amidstDBN.getDistributionTimeT(amidstVar);
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int nStates=amidstVar.getNumberOfStates();
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int i=0; i < numParentAssignments; i++) {
      double[] sourceArray=probabilities[i].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,i * nStates,nStates);
    }
    huginVar.getTable().setData(finalArray);
    if (huginVar.getTemporalClone() != null) {
      Multinomial_MultinomialParents distClone=amidstDBN.getDistributionTime0(amidstVar);
      finalArray=distClone.getProbabilities()[0].getProbabilities();
      huginVar.getTemporalClone().getTable().setData(finalArray);
    }
  }
}

Fixed version (ground truth):
private void setDistributions(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  NodeList huginNodes=this.huginDBN.getNodes();
  int numNodes=huginNodes.size();
  Multinomial_MultinomialParents dist=null;
  int nStates=0;
  for (int i=0; i < numNodes; i++) {
    Node huginNode=huginNodes.get(i);
    if (huginNode.getTemporalMaster() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getName());
      dist=amidstDBN.getDistributionTimeT(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    if (huginNode.getTemporalClone() == null) {
      Variable amidstVar=amidstDBN.getDynamicVariables().getVariableByName(huginNode.getTemporalMaster().getName());
      dist=amidstDBN.getDistributionTime0(amidstVar);
      nStates=amidstVar.getNumberOfStates();
    }
    Multinomial[] probabilities=dist.getProbabilities();
    List<Variable> conditioningVariables=dist.getConditioningVariables();
    int numParentAssignments=MultinomialIndex.getNumberOfPossibleAssignments(conditioningVariables);
    int sizeArray=numParentAssignments * nStates;
    double[] finalArray=new double[sizeArray];
    for (int j=0; j < numParentAssignments; j++) {
      double[] sourceArray=probabilities[j].getProbabilities();
      System.arraycopy(sourceArray,0,finalArray,j * nStates,nStates);
    }
    huginNode.getTable().setData(finalArray);
  }
}
Program: 21612
Project: 21612
Buggy source:
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
      }
    }
  }
}

Fixed version (ground truth):
private void setStructure(DynamicBayesianNetwork amidstDBN) throws ExceptionHugin {
  DynamicDAG dynamicDAG=amidstDBN.getDynamicDAG();
  DynamicVariables dynamicVariables=amidstDBN.getDynamicVariables();
  List<Variable> amidstVars=dynamicVariables.getListOfDynamicVariables();
  for (  Variable amidstChild : amidstVars) {
    List<Variable> amidstParents=dynamicDAG.getParentSetTimeT(amidstChild).getParents();
    Node huginChild=this.huginDBN.getNodeByName(amidstChild.getName());
    for (    Variable amidstParent : amidstParents) {
      if (amidstParent.isTemporalClone()) {
        huginChild.addParent(huginChild.getTemporalClone());
      }
 else {
        Node huginParent=this.huginDBN.getNodeByName(amidstParent.getName());
        huginChild.addParent(huginParent);
        Node huginParentClone=huginParent.getTemporalClone();
        Node huginChildClone=huginChild.getTemporalClone();
        huginChildClone.addParent(huginParentClone);
      }
    }
  }
}
Program: 21613
Project: 21613
Buggy source:
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  this.huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  this.amidstBN=ConverterToAMIDST.convertToAmidst(this.huginBN);
  System.out.println("String_Node_Str");
}

Fixed version (ground truth):
@Before public void setUp() throws ExceptionHugin {
  ParseListener parseListener=new DefaultClassParseListener();
  Domain huginBN=new Domain("String_Node_Str",parseListener);
  System.out.println("String_Node_Str");
  BayesianNetwork amidstBN=ConverterToAMIDST.convertToAmidst(huginBN);
  System.out.println("String_Node_Str");
}
Program: 21614
Project: 21614
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
  this.naturalParameters=vectorNatural;
}
Program: 21615
Project: 21615
Buggy source:
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::serialLearnStatic);
  return LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  MaximumLikelihood.setParallelMode(this.parallelMode);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  return LearningEngine.learnStaticModel(dataBase);
}
Program: 21616
Project: 21616
Buggy source:
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=1;
}

Fixed version (ground truth):
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=Runtime.getRuntime().availableProcessors();
  this.parallelMode=true;
}
Program: 21617
Project: 21617
Buggy source:
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  String dataFile=new String("String_Node_Str");
  DataBase data=new StaticDataOnDiskFromFile(new ARFFDataReader(dataFile));
  ParallelTAN tan=new ParallelTAN();
  tan.setNumCores(4);
  tan.setNumSamplesOnMemory(1000);
  tan.setNameRoot("String_Node_Str");
  tan.setNameTarget("String_Node_Str");
  LearningEngine.setStaticStructuralLearningAlgorithm(tan::learnDAG);
  MaximumLikelihood.setBatchSize(1000);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  BayesianNetwork tanModel=LearningEngine.learnStaticModel(data);
}
Program: 21618
Project: 21618
Buggy source:
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}
Program: 21619
Project: 21619
Buggy source:
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag,dists);
}
Program: 21620
Project: 21620
Buggy source:
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    Attribute att=vars.get(i).getAttribute();
    String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  Attribute att=vars.get(vars.size() - 1).getAttribute();
  String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}

Fixed version (ground truth):
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
  String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}
Program: 21621
Project: 21621
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.stream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
  this.naturalParameters=vectorNatural;
}
Program: 21622
Project: 21622
Buggy source:
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::serialLearnStatic);
  return LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public BayesianNetwork learnBN(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::learnDAG);
  MaximumLikelihood.setParallelMode(this.parallelMode);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  return LearningEngine.learnStaticModel(dataBase);
}
Program: 21623
Project: 21623
Buggy source:
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=1;
}

Fixed version (ground truth):
public ParallelTAN(){
  this.numSamplesOnMemory=10000;
  this.numCores=Runtime.getRuntime().availableProcessors();
  this.parallelMode=true;
}
Program: 21624
Project: 21624
Buggy source:
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::parallelLearnStatic);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}

Fixed version (ground truth):
public void learn(DataBase dataBase){
  LearningEngine.setStaticStructuralLearningAlgorithm(this::staticNaiveBayesStructure);
  LearningEngine.setStaticParameterLearningAlgorithm(MaximumLikelihood::learnParametersStaticModel);
  bnModel=LearningEngine.learnStaticModel(dataBase);
}
Program: 21625
Project: 21625
Buggy source:
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    Attribute att=vars.get(i).getAttribute();
    String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  Attribute att=vars.get(vars.size() - 1).getAttribute();
  String nameState=((FiniteStateSpace)att.getStateSpace()).getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}

Fixed version (ground truth):
default String toARFFString(List<Variable> vars){
  StringBuilder builder=new StringBuilder(vars.size() * 2);
  for (int i=0; i < vars.size() - 1; i++) {
    FiniteStateSpace stateSpace=vars.get(i).getStateSpace();
    String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(i)));
    builder.append(nameState + "String_Node_Str");
  }
  FiniteStateSpace stateSpace=vars.get(vars.size() - 1).getStateSpace();
  String nameState=stateSpace.getStatesName((int)this.getValue(vars.get(vars.size() - 1)));
  builder.append(nameState);
  return builder.toString();
}
Program: 21626
Project: 21626
Buggy source:
public EF_BaseDistribution_MultinomialParents(List<Variable> multinomialParents1,List<E> distributions1){
  if (multinomialParents1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (distributions1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  int size=MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents1);
  if (size != distributions1.size())   throw new IllegalArgumentException("String_Node_Str");
  this.var=distributions1.get(0).getVariable();
  this.multinomialParents=multinomialParents1;
  this.distributions=distributions1;
  this.parents=new ArrayList();
  for (  Variable v : this.multinomialParents)   this.parents.add(v);
  E dist=distributions.get(0);
  if (dist.getClass().getName().equals("String_Node_Str")) {
    EF_ConditionalDistribution distCond=(EF_ConditionalDistribution)dist;
    for (    Variable v : distCond.getConditioningVariables())     this.parents.add(v);
  }
  this.parents=Collections.unmodifiableList(this.parents);
}

Fixed version (ground truth):
public EF_BaseDistribution_MultinomialParents(List<Variable> multinomialParents1,List<E> distributions1){
  if (distributions1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  int size=MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents1);
  if (size != distributions1.size())   throw new IllegalArgumentException("String_Node_Str");
  this.var=distributions1.get(0).getVariable();
  this.multinomialParents=multinomialParents1;
  this.distributions=distributions1;
  this.parents=new ArrayList();
  for (  Variable v : this.multinomialParents)   this.parents.add(v);
  E dist=distributions.get(0);
  if (dist.getClass().getName().equals("String_Node_Str")) {
    EF_ConditionalDistribution distCond=(EF_ConditionalDistribution)dist;
    for (    Variable v : distCond.getConditioningVariables())     this.parents.add(v);
  }
  this.parents=Collections.unmodifiableList(this.parents);
}
Program: 21627
Project: 21627
Buggy source:
@Override public double get(int i){
  i-=nConf;
  return baseVectors[(int)Math.ceil(i / (double)nConf)].get(i % baseSSLength);
}

Fixed version (ground truth):
@Override public double get(int i){
  if (i < nConf) {
    return this.baseConf[i];
  }
 else {
    i-=nConf;
    return baseVectors[Math.floorDiv(i,this.baseSSLength)].get(i % baseSSLength);
  }
}
Program: 21628
Project: 21628
Buggy source:
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position].copy(vec);
}

Fixed version (ground truth):
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position]=vec;
}
Program: 21629
Project: 21629
Buggy source:
@Override public void set(int i,double val){
  if (i < nConf) {
    baseConf[i]=val;
  }
 else {
    i-=nConf;
    baseVectors[(int)Math.ceil(i / (double)nConf)].set(i % baseSSLength,val);
  }
}

Fixed version (ground truth):
@Override public void set(int i,double val){
  if (i < nConf) {
    baseConf[i]=val;
  }
 else {
    i-=nConf;
    baseVectors[Math.floorDiv(i,this.baseSSLength)].set(i % baseSSLength,val);
  }
}
Program: 21630
Project: 21630
Buggy source:
public void updateNaturalFromMomentParameters(){
  CompoundVector<E> globalMomentsParam=(CompoundVector<E>)this.momentParameters;
  for (int i=0; i < numberOfConfigurations(); i++) {
    MomentParameters moment=this.getEF_BaseDistribution(i).createZeroedMomentParameters();
    moment.copy(globalMomentsParam.getVectorByPosition(i));
    moment.divideBy(globalMomentsParam.getBaseConf(i));
    this.getEF_BaseDistribution(i).setMomentParameters(momentParameters);
  }
  CompoundVector<E> vectorNatural=this.createCompoundVector();
  for (int i=0; i < numberOfConfigurations(); i++) {
    vectorNatural.setBaseConf(i,-this.getEF_BaseDistribution(i).computeLogNormalizer());
    vectorNatural.getVectorByPosition(i).copy(this.getEF_BaseDistribution(i).getNaturalParameters());
  }
  this.naturalParameters=vectorNatural;
  return;
}

Fixed version (ground truth):
public void updateNaturalFromMomentParameters(){
  CompoundVector<E> globalMomentsParam=(CompoundVector<E>)this.momentParameters;
  for (int i=0; i < numberOfConfigurations(); i++) {
    MomentParameters moment=(MomentParameters)globalMomentsParam.getVectorByPosition(i);
    moment.divideBy(globalMomentsParam.getBaseConf(i));
    this.getEF_BaseDistribution(i).setMomentParameters(momentParameters);
  }
  CompoundVector<E> vectorNatural=this.createCompoundVector();
  for (int i=0; i < numberOfConfigurations(); i++) {
    vectorNatural.setBaseConf(i,-this.getEF_BaseDistribution(i).computeLogNormalizer());
    vectorNatural.setVectorByPosition(i,this.getEF_BaseDistribution(i).getNaturalParameters());
  }
  this.naturalParameters=vectorNatural;
  return;
}
Program: 21631
Project: 21631
Buggy source:
public EF_BayesianNetwork(DAG dag){
  distributionList=new ArrayList(dag.getStaticVariables().getNumberOfVars());
  sizeSS=0;
  for (  ParentSet parentSet : dag.getParentSets()) {
    ConditionalDistribution dist=DistributionBuilder.newDistribution(parentSet.getMainVar(),parentSet.getParents());
    EF_ConditionalDistribution ef_dist=EF_DistributionBuilder.toEFDistributionGeneral(dist);
    distributionList.set(ef_dist.getVariable().getVarID(),ef_dist);
    sizeSS+=ef_dist.sizeOfSufficientStatistics();
  }
}

Fixed version (ground truth):
public EF_BayesianNetwork(DAG dag){
  distributionList=new ArrayList(dag.getStaticVariables().getNumberOfVars());
  sizeSS=0;
  for (  ParentSet parentSet : dag.getParentSets()) {
    ConditionalDistribution dist=DistributionBuilder.newDistribution(parentSet.getMainVar(),parentSet.getParents());
    EF_ConditionalDistribution ef_dist=EF_DistributionBuilder.toEFDistributionGeneral(dist);
    distributionList.add(ef_dist.getVariable().getVarID(),ef_dist);
    sizeSS+=ef_dist.sizeOfSufficientStatistics();
  }
}
Program: 21632
Project: 21632
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    MomentParameters localMomentParam=w.createZeroedMomentParameters();
    localMomentParam.copy(globalMomentsParam.getVectorByPosition(w.getVariable().getVarID()));
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}
Program: 21633
Project: 21633
Buggy source:
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position].copy(vec);
}

Fixed version (ground truth):
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position]=vec;
}
Program: 21634
Project: 21634
Buggy source:
public BayesianNetwork toBayesianNetwork(DAG dag){
  BayesianNetwork bayesianNetwork=BayesianNetwork.newBayesianNetwork(dag);
  this.distributionList.stream().forEach(dist -> bayesianNetwork.setDistribution(dist.getVariable(),EF_DistributionBuilder.toDistributionGeneral(dist)));
  return bayesianNetwork;
}

Fixed version (ground truth):
public BayesianNetwork toBayesianNetwork(DAG dag){
  ConditionalDistribution[] dists=new ConditionalDistribution[dag.getStaticVariables().getNumberOfVars()];
  this.distributionList.parallelStream().forEach(dist -> dists[dist.getVariable().getVarID()]=EF_DistributionBuilder.toDistributionGeneral(dist));
  return BayesianNetwork.newBayesianNetwork(dag,Arrays.asList(dists));
}
Program: 21635
Project: 21635
Buggy source:
@Override public SufficientStatistics getSufficientStatistics(DataInstance data){
  CompoundVector vectorSS=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    vectorSS.getVectorByPosition(w.getVariable().getVarID()).copy(w.getSufficientStatistics(data));
  }
);
  return vectorSS;
}

Fixed version (ground truth):
@Override public SufficientStatistics getSufficientStatistics(DataInstance data){
  CompoundVector vectorSS=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    vectorSS.setVectorByPosition(w.getVariable().getVarID(),w.getSufficientStatistics(data));
  }
);
  return vectorSS;
}
Program: 21636
Project: 21636
Buggy source:
public static SufficientStatistics sum(SufficientStatistics vec1,SufficientStatistics vec2){
  return (SufficientStatistics)Vector.sum(vec1,vec2);
}

Fixed version (ground truth):
public static SufficientStatistics sum(SufficientStatistics vec1,SufficientStatistics vec2){
  return vec1;
}
Program: 21637
Project: 21637
Buggy source:
public static BayesianNetwork parallelLearnStatic(DAG dag,DataBase dataBase){
  EF_BayesianNetwork efBayesianNetwork=new EF_BayesianNetwork(dag);
  AtomicInteger count=new AtomicInteger(0);
  SufficientStatistics sumSS=dataBase.parallelStream(batchSize).peek(w -> count.getAndIncrement()).map(efBayesianNetwork::getSufficientStatistics).reduce(efBayesianNetwork.createZeroedSufficientStatistics(),SufficientStatistics::sum);
  sumSS.divideBy(count.get());
  efBayesianNetwork.setMomentParameters(sumSS);
  return efBayesianNetwork.toBayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork parallelLearnStatic(DAG dag,DataBase dataBase){
  EF_BayesianNetwork efBayesianNetwork=new EF_BayesianNetwork(dag);
  AtomicInteger count=new AtomicInteger(0);
  SufficientStatistics sumSS=dataBase.parallelStream(batchSize).peek(w -> {
    count.getAndIncrement();
  }
).map(efBayesianNetwork::getSufficientStatistics).reduce(efBayesianNetwork.createZeroedSufficientStatistics(),SufficientStatistics::sum);
  sumSS.divideBy(count.get());
  efBayesianNetwork.setMomentParameters(sumSS);
  return efBayesianNetwork.toBayesianNetwork(dag);
}
Program: 21638
Project: 21638
Buggy source:
public static BayesianNetwork serialLearnStatic(DAG dag,DataBase dataBase){
  EF_BayesianNetwork efBayesianNetwork=new EF_BayesianNetwork(dag);
  AtomicInteger count=new AtomicInteger(0);
  SufficientStatistics sum=dataBase.stream().peek(w -> count.getAndIncrement()).map(efBayesianNetwork::getSufficientStatistics).reduce(efBayesianNetwork.createZeroedSufficientStatistics(),SufficientStatistics::sum);
  sum.divideBy(count.get());
  efBayesianNetwork.setMomentParameters(sum);
  return efBayesianNetwork.toBayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork serialLearnStatic(DAG dag,DataBase dataBase){
  EF_BayesianNetwork efBayesianNetwork=new EF_BayesianNetwork(dag);
  final int[] count={0};
  SufficientStatistics sum=dataBase.stream().peek(w -> {
    count[0]++;
  }
).map(efBayesianNetwork::getSufficientStatistics).reduce(efBayesianNetwork.createZeroedSufficientStatistics(),SufficientStatistics::sum);
  sum.divideBy(count[0]);
  efBayesianNetwork.setMomentParameters(sum);
  return efBayesianNetwork.toBayesianNetwork(dag);
}
Program: 21639
Project: 21639
Buggy source:
private BayesianNetwork(DAG dag){
  this.dag=dag;
  initializeDistributions();
}

Fixed version (ground truth):
private BayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  this.dag=dag;
  this.distributions=dists;
}
Program: 21640
Project: 21640
Buggy source:
public static BayesianNetwork newBayesianNetwork(DAG dag){
  return new BayesianNetwork(dag);
}

Fixed version (ground truth):
public static BayesianNetwork newBayesianNetwork(DAG dag,List<ConditionalDistribution> dists){
  return new BayesianNetwork(dag);
}
Program: 21641
Project: 21641
Buggy source:
public EF_BaseDistribution_MultinomialParents(List<Variable> multinomialParents1,List<E> distributions1){
  if (multinomialParents1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  if (distributions1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  int size=MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents1);
  if (size != distributions1.size())   throw new IllegalArgumentException("String_Node_Str");
  this.var=distributions1.get(0).getVariable();
  this.multinomialParents=multinomialParents1;
  this.distributions=distributions1;
  this.parents=new ArrayList();
  for (  Variable v : this.multinomialParents)   this.parents.add(v);
  E dist=distributions.get(0);
  if (dist.getClass().getName().equals("String_Node_Str")) {
    EF_ConditionalDistribution distCond=(EF_ConditionalDistribution)dist;
    for (    Variable v : distCond.getConditioningVariables())     this.parents.add(v);
  }
  this.parents=Collections.unmodifiableList(this.parents);
}

Fixed version (ground truth):
public EF_BaseDistribution_MultinomialParents(List<Variable> multinomialParents1,List<E> distributions1){
  if (distributions1.size() == 0)   throw new IllegalArgumentException("String_Node_Str");
  int size=MultinomialIndex.getNumberOfPossibleAssignments(multinomialParents1);
  if (size != distributions1.size())   throw new IllegalArgumentException("String_Node_Str");
  this.var=distributions1.get(0).getVariable();
  this.multinomialParents=multinomialParents1;
  this.distributions=distributions1;
  this.parents=new ArrayList();
  for (  Variable v : this.multinomialParents)   this.parents.add(v);
  E dist=distributions.get(0);
  if (dist.getClass().getName().equals("String_Node_Str")) {
    EF_ConditionalDistribution distCond=(EF_ConditionalDistribution)dist;
    for (    Variable v : distCond.getConditioningVariables())     this.parents.add(v);
  }
  this.parents=Collections.unmodifiableList(this.parents);
}
Program: 21642
Project: 21642
Buggy source:
@Override public double get(int i){
  i-=nConf;
  return baseVectors[(int)Math.ceil(i / (double)nConf)].get(i % baseSSLength);
}

Fixed version (ground truth):
@Override public double get(int i){
  if (i < nConf) {
    return this.baseConf[i];
  }
 else {
    i-=nConf;
    return baseVectors[Math.floorDiv(i,this.baseSSLength)].get(i % baseSSLength);
  }
}
Program: 21643
Project: 21643
Buggy source:
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position].copy(vec);
}

Fixed version (ground truth):
public void setVectorByPosition(int position,Vector vec){
  baseVectors[position]=vec;
}
Program: 21644
Project: 21644
Buggy source:
@Override public void set(int i,double val){
  if (i < nConf) {
    baseConf[i]=val;
  }
 else {
    i-=nConf;
    baseVectors[(int)Math.ceil(i / (double)nConf)].set(i % baseSSLength,val);
  }
}

Fixed version (ground truth):
@Override public void set(int i,double val){
  if (i < nConf) {
    baseConf[i]=val;
  }
 else {
    i-=nConf;
    baseVectors[Math.floorDiv(i,this.baseSSLength)].set(i % baseSSLength,val);
  }
}
Program: 21645
Project: 21645
Buggy source:
public void updateNaturalFromMomentParameters(){
  CompoundVector<E> globalMomentsParam=(CompoundVector<E>)this.momentParameters;
  for (int i=0; i < numberOfConfigurations(); i++) {
    MomentParameters moment=this.getEF_BaseDistribution(i).createZeroedMomentParameters();
    moment.copy(globalMomentsParam.getVectorByPosition(i));
    moment.divideBy(globalMomentsParam.getBaseConf(i));
    this.getEF_BaseDistribution(i).setMomentParameters(momentParameters);
  }
  CompoundVector<E> vectorNatural=this.createCompoundVector();
  for (int i=0; i < numberOfConfigurations(); i++) {
    vectorNatural.setBaseConf(i,-this.getEF_BaseDistribution(i).computeLogNormalizer());
    vectorNatural.getVectorByPosition(i).copy(this.getEF_BaseDistribution(i).getNaturalParameters());
  }
  this.naturalParameters=vectorNatural;
  return;
}

Fixed version (ground truth):
public void updateNaturalFromMomentParameters(){
  CompoundVector<E> globalMomentsParam=(CompoundVector<E>)this.momentParameters;
  for (int i=0; i < numberOfConfigurations(); i++) {
    MomentParameters moment=(MomentParameters)globalMomentsParam.getVectorByPosition(i);
    moment.divideBy(globalMomentsParam.getBaseConf(i));
    this.getEF_BaseDistribution(i).setMomentParameters(momentParameters);
  }
  CompoundVector<E> vectorNatural=this.createCompoundVector();
  for (int i=0; i < numberOfConfigurations(); i++) {
    vectorNatural.setBaseConf(i,-this.getEF_BaseDistribution(i).computeLogNormalizer());
    vectorNatural.setVectorByPosition(i,this.getEF_BaseDistribution(i).getNaturalParameters());
  }
  this.naturalParameters=vectorNatural;
  return;
}
Program: 21646
Project: 21646
Buggy source:
public EF_BayesianNetwork(DAG dag){
  distributionList=new ArrayList(dag.getStaticVariables().getNumberOfVars());
  sizeSS=0;
  for (  ParentSet parentSet : dag.getParentSets()) {
    ConditionalDistribution dist=DistributionBuilder.newDistribution(parentSet.getMainVar(),parentSet.getParents());
    EF_ConditionalDistribution ef_dist=EF_DistributionBuilder.toEFDistributionGeneral(dist);
    distributionList.set(ef_dist.getVariable().getVarID(),ef_dist);
    sizeSS+=ef_dist.sizeOfSufficientStatistics();
  }
}

Fixed version (ground truth):
public EF_BayesianNetwork(DAG dag){
  distributionList=new ArrayList(dag.getStaticVariables().getNumberOfVars());
  sizeSS=0;
  for (  ParentSet parentSet : dag.getParentSets()) {
    ConditionalDistribution dist=DistributionBuilder.newDistribution(parentSet.getMainVar(),parentSet.getParents());
    EF_ConditionalDistribution ef_dist=EF_DistributionBuilder.toEFDistributionGeneral(dist);
    distributionList.add(ef_dist.getVariable().getVarID(),ef_dist);
    sizeSS+=ef_dist.sizeOfSufficientStatistics();
  }
}
Program: 21647
Project: 21647
Buggy source:
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    MomentParameters localMomentParam=w.createZeroedMomentParameters();
    localMomentParam.copy(globalMomentsParam.getVectorByPosition(w.getVariable().getVarID()));
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}

Fixed version (ground truth):
@Override public void updateNaturalFromMomentParameters(){
  CompoundVector globalMomentsParam=(CompoundVector)this.momentParameters;
  CompoundVector vectorNatural=this.createCompoundVector();
  this.distributionList.parallelStream().forEach(w -> {
    MomentParameters localMomentParam=(MomentParameters)globalMomentsParam.getVectorByPosition(w.getVariable().getVarID());
    w.setMomentParameters(localMomentParam);
    vectorNatural.setVectorByPosition(w.getVariable().getVarID(),w.getNaturalParameters());
  }
);
}